AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
can.h
1 
23 #ifndef _AVRIO_CAN_H_
24 # define _AVRIO_CAN_H_
25 
26 # include <avrio/defs.h>
27 
28 __BEGIN_C_DECLS
29  /* ======================================================================== */
50  /* constants ============================================================== */
55  typedef enum {
56 
57  CAN_2A = 0x01,
58  CAN_2B = 0x02
60 
65 typedef enum {
76 } eCanSpeed;
77 
82 typedef enum {
83 
89  CAN_PASSIVE = -5,
90  CAN_BUS_OFF = -6,
92 } eCanError;
93 
94 /* structures =============================================================== */
101 typedef union xCanArbField {
102 
103  uint32_t xValue;
104  struct {
105  uint32_t xIde:1;
106  uint32_t xRtr:1;
107  uint32_t xUnused:1;
108  uint32_t xId:29;
109  };
110 } xCanArbField;
111 
116 typedef union xCanCtrlField {
117 
118  uint8_t xValue;
119  struct {
120 
121  uint8_t xUnused:2;
122  uint8_t xR1:1;
123  uint8_t xR0:1;
124  uint8_t xDlc:4;
125  };
126 } xCanCtrlField;
127 
132 typedef struct xCanFrame {
133 
136  uint8_t ucData[8];
137 } xCanFrame;
138 
139 /* internal public functions ================================================ */
145 
151 eCanError eCanSetSpeed (eCanSpeed eBaudrate);
152 
157 void vCanSetFilter (uint8_t * pucAcceptanceCode, uint8_t * pucAcceptanceMask);
158 
167 eCanError eCanSendFrame (const xCanFrame * pxFrame);
168 
173 bool xCanTxFree (void);
174 
178 eCanError eCanTrySendFrame (const xCanFrame * pxFrame);
179 
191 
196 uint8_t ucCanRxAvail (void);
197 
202 
212 void vCanSetRxTimeout (uint16_t usTimeout);
213 
214 # if defined(__DOXYGEN__)
215 /*
216  * __DOXYGEN__ defined
217  * Partie documentation ne devant pas être compilée.
218  * =============================================================================
219  */
220 
225 # else
226 /*
227  * __DOXYGEN__ not defined
228  * Partie ne devant pas être documentée.
229  * =============================================================================
230  */
231 
232 # endif /* __DOXYGEN__ not defined */
233 /* ========================================================================== */
234 __END_C_DECLS
235 #endif /* _AVRIO_CAN_H_ */
eCanError eCanSendFrame(const xCanFrame *pxFrame)
Write a frame from to output buffer.
eCanSpeed
Vitesse bus CAN Baud.
Definition: can.h:65
eCanError eCanInit(eCanSpecification eType)
Initialize CAN interface.
eCanError eCanTrySendFrame(const xCanFrame *pxFrame)
Transmission non bloquante d&#39;une trame.
void vCanSetFilter(uint8_t *pucAcceptanceCode, uint8_t *pucAcceptanceMask)
Sets the acceptance code and mask.
eCanError eCanTryReceiveFrame(xCanFrame *pxFrame)
Réception non bloquante d&#39;une trame.
void vCanSetRxTimeout(uint16_t usTimeout)
Sets the CAN receive timeout.
Trame CAN.
Definition: can.h:132
Champs d&#39;arbitrage.
Definition: can.h:101
eCanError
Codes d&#39;erreur.
Definition: can.h:82
eCanError eCanSetSpeed(eCanSpeed eBaudrate)
Sets the CAN baud rate.
xCanArbField xArb
Definition: can.h:134
uint32_t xRtr
Definition: can.h:106
xCanCtrlField xCtrl
Definition: can.h:135
uint8_t ucCanRxAvail(void)
Checks if data is available in input buffer.
eCanError eCanReceiveFrame(xCanFrame *pxFrame)
Reads a frame from input buffer.
Champs de contrôle.
Definition: can.h:116
uint32_t xId
Definition: can.h:108
eCanSpecification
Version de bus CAN.
Definition: can.h:55
Definition: can.h:58
uint32_t xIde
Definition: can.h:105
Definition: can.h:57
bool xCanTxFree(void)
Checks if there&#39;s still space in output buffer.