Dallas Semiconductor DS80C400 C Libraries Home Page

Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

tini400_canbus.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------
00002  * Copyright (C) 2005 Dallas Semiconductor Corporation, All Rights Reserved.
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a
00005  * copy of this software and associated documentation files (the "Software"),
00006  * to deal in the Software without restriction, including without limitation
00007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008  * and/or sell copies of the Software, and to permit persons to whom the
00009  * Software is furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included
00012  * in all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016  * MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017  * IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
00018  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020  * OTHER DEALINGS IN THE SOFTWARE.
00021  *
00022  * Except as contained in this notice, the name of Dallas Semiconductor
00023  * shall not be used except as stated in the Dallas Semiconductor
00024  * Branding Policy.
00025  *---------------------------------------------------------------------------
00026  */
00027 
00028 #ifndef _CANBUS_H
00029 #define _CANBUS_H
00030 
00069 /*
00070  * Definition of typedefs as per ISO C
00071  */
00072 //---------------------------------------------------------------------------
00073 typedef signed char int8_t; 
00074 typedef unsigned char uint8_t; 
00075 typedef signed int int16_t; 
00076 typedef unsigned int uint16_t; 
00077 typedef signed long int32_t; 
00078 typedef unsigned long uint32_t; 
00079 typedef unsigned char boolean; 
00080 
00081 #ifndef TRUE
00082     #define TRUE        1 
00083 #endif
00084 
00085 #ifndef FALSE
00086     #define FALSE       0 
00087 #endif
00088 //---------------------------------------------------------------------------
00089 
00093 #define TINI400_CANBUS_VERSION 3
00094 
00098 //---------------------------------------------------------------------------
00099 typedef struct
00100 {
00104         boolean RemoteFrameRequest;
00108     boolean ExtendedID;
00112     uint32_t ID;
00115     uint8_t Length;
00118     char Data[8];
00119 } CanFrame;
00120 
00124 //---------------------------------------------------------------------------
00125 typedef struct
00126 {
00129     boolean ExtendedID;
00133     uint32_t ID;
00137     boolean MemeEnable;
00141     boolean MdmeEnable;
00142 } MCConfig;
00143 
00152 extern uint16_t can_version(void);
00153 
00164 //---------------------------------------------------------------------------
00165 extern void can_init(void);
00166 
00181 //---------------------------------------------------------------------------
00182 extern int8_t can_resetcontroller  (uint8_t CAN_No);
00183 
00198 //---------------------------------------------------------------------------
00199 extern int8_t can_setsiestamode (uint8_t CAN_No);
00200 
00218 //---------------------------------------------------------------------------
00219 extern int8_t can_disablecontroller (uint8_t CAN_No);
00220 
00237 //---------------------------------------------------------------------------
00238 extern int8_t can_enablecontroller (uint8_t CAN_No);
00239 
00258 //---------------------------------------------------------------------------
00259 extern int8_t can_enablecontrollerpassive (uint8_t CAN_No);
00260 
00278 //---------------------------------------------------------------------------
00279 extern int8_t can_setrxwriteoverenable (uint8_t CAN_No, boolean writeover);
00280 
00299 //---------------------------------------------------------------------------
00300 extern int8_t can_set11bitglobalidmask (uint8_t CAN_No, uint32_t *mask);
00301 
00320 //---------------------------------------------------------------------------
00321 extern int8_t can_set29bitglobalidmask (uint8_t CAN_No, uint32_t *mask);
00322 
00341 //---------------------------------------------------------------------------
00342 extern int8_t can_set11bitmessagecenter15idmask (uint8_t CAN_No, uint32_t *mask);
00343 
00362 //---------------------------------------------------------------------------
00363 extern int8_t can_set29bitmessagecenter15idmask (uint8_t CAN_No, uint32_t *mask);
00364 
00383 //---------------------------------------------------------------------------
00384 extern int8_t can_setmediaidmask (uint8_t CAN_No, uint16_t mask);
00385 
00404 //---------------------------------------------------------------------------
00405 extern int8_t can_setmediaidarbitration (uint8_t CAN_No, uint16_t value);
00406 
00427 //---------------------------------------------------------------------------
00428 extern int8_t can_setbaudrateprescaler (uint8_t CAN_No, uint16_t prescaler);
00429 
00449 //---------------------------------------------------------------------------
00450 extern int8_t can_setsynchronizationjumpwidth (uint8_t CAN_No, uint8_t jumpWidth);
00451 
00470 //---------------------------------------------------------------------------
00471 extern int8_t can_setsamplerate (uint8_t CAN_No, uint8_t sampleRate);
00472 
00491 //---------------------------------------------------------------------------
00492 extern int8_t can_settseg1 (uint8_t CAN_No, uint8_t tseg1);
00493 
00512 //---------------------------------------------------------------------------
00513 extern int8_t can_settseg2 (uint8_t CAN_No, uint8_t tseg2);
00514 
00535 //---------------------------------------------------------------------------
00536 extern int8_t can_enablemessagecenter (uint8_t CAN_No, uint8_t messageCenter);
00537 
00556 //---------------------------------------------------------------------------
00557 extern int8_t can_disablemessagecenter (uint8_t CAN_No, uint8_t messageCenter);
00558 
00581 //---------------------------------------------------------------------------
00582 extern int8_t can_freemessagecenter (uint8_t CAN_No, uint8_t messageCenter);
00583 
00602 //---------------------------------------------------------------------------
00603 extern int8_t can_setmessagecentertx (uint8_t CAN_No, uint8_t messageCenter);
00604 
00623 //---------------------------------------------------------------------------
00624 extern int8_t can_setmessagecenterrx (uint8_t CAN_No, uint8_t messageCenter);
00625 
00647 //---------------------------------------------------------------------------
00648 extern int8_t can_set11bitmessagecenterarbitrationid (uint8_t CAN_No, uint8_t messageCenter, uint32_t *ID);
00649 
00672 //---------------------------------------------------------------------------
00673 extern int8_t can_set29bitmessagecenterarbitrationid (uint8_t CAN_No, uint8_t messageCenter, uint32_t *ID);
00674 
00696 //---------------------------------------------------------------------------
00697 extern int8_t can_setmessagecentermessageidmaskenable (uint8_t CAN_No, uint8_t messageCenter, boolean maskEnable);
00698 
00720 //---------------------------------------------------------------------------
00721 extern int8_t can_setmessagecentermediaidmaskenable (uint8_t CAN_No, uint8_t messageCenter, boolean maskEnable);
00722 
00744 //---------------------------------------------------------------------------
00745 extern int8_t can_sendframe (uint8_t CAN_No, CanFrame *frame);
00746 
00768 //---------------------------------------------------------------------------
00769 extern int8_t can_getrxmessagecenter (uint8_t CAN_No, MCConfig *config);
00770 
00785 //---------------------------------------------------------------------------
00786 extern int8_t can_receiveframesavailable (uint8_t CAN_No);
00787 
00807 //---------------------------------------------------------------------------
00808 extern int8_t can_receiveframe (uint8_t CAN_No, CanFrame *frame);
00809 
00832 //---------------------------------------------------------------------------
00833 extern int8_t can_getautoanswerrfrmessagecenter(uint8_t CAN_No, CanFrame *frame);
00834 
00848 //---------------------------------------------------------------------------
00849 extern int16_t can_gettxerrorcount(uint8_t CAN_No);
00850 
00864 //---------------------------------------------------------------------------
00865 extern int16_t can_getrxerrorcount(uint8_t CAN_No);
00866 
00867 /* 
00868  * Error codes
00869  */
00870 
00873 #define CAN_ERROR_NOERROR                       0
00874 
00877 #define CAN_ERROR_GENERIC                       -1
00878 
00881 #define CAN_ERROR_BUSOFF                        -2
00882 
00885 #define CAN_ERROR_TIMEOUT                       -3
00886 
00889 #define CAN_ERROR_NOT_INITIALIZED       -4
00890 
00893 #define CAN_ERROR_ARGUMENT                      -5
00894 
00897 #define CAN_ERROR_PORT_ENABLED          -6
00898 
00901 #define CAN_ERROR_PORT_DISABLED         -7
00902 
00905 #define CAN_ERROR_MC_ACTIVE                     -8
00906 
00910 #define CAN_ERROR_BIT_STUFF                     -9
00911 
00914 #define CAN_ERROR_FORMAT                        -10
00915 
00919 #define CAN_ERROR_TRANSMIT_NO_ACK       -11
00920 
00923 #define CAN_ERROR_BIT_ONE                       -12
00924 
00927 #define CAN_ERROR_BIT_ZERO                      -13
00928 
00932 #define CAN_ERROR_CRC                           -14
00933 
00938 #define CAN_ERROR_COUNT_EXCEEDED        -15
00939 
00942 #define CAN_ERROR_NOFREEMC                      -16
00943 
00946 #define CAN_ERROR_BUFFULL                       -17
00947 
00950 #define CAN_ERROR_BUFEMPTY                      -18
00951 
00954 #define CAN_ERROR_INVALID_TSEG          -19
00955 
00960 #define CAN_ERROR_FRAMESDROPPED         -20
00961 
00962 #endif

Copyright 2005 Dallas Semiconductor, Inc.. Documentation generated by Doxygen.