AvrIO  1.4.5
Bibliothèque C modulaire pour ATMEL AVR
Bus CAN

Description détaillée

Ce module permet de gérer la communication sur le bus CAN (Control Area Network).
La macro AVRIO_CAN_ENABLE doit être définie dans avrio-config.h et dans ce cas, les options peuvent être définies dans le fichier avrio-board-can.h se trouvant dans le même répertoire.

<ATTENTION>

Module en développement, non fonctionnel !

Auteur
Portions Copyright © 2005-2009 proconX Pty Ltd. All rights reserved.
Portions Copyright © 2004 by Ole Reinhardt ole.r.nosp@m.einh.nosp@m.ardt@.nosp@m.kern.nosp@m.elcon.nosp@m.cept.nosp@m.s.de, Kernelconcepts http://www.kernelconcepts.de
Graphe de collaboration de Bus CAN:

Structures de données

union  xCanArbField
 Champs d'arbitrage. Plus de détails...
 
union  xCanCtrlField
 Champs de contrôle. Plus de détails...
 
struct  xCanFrame
 Trame CAN. Plus de détails...
 

Fonctions

eCanError eCanInit (eCanSpecification eType)
 Initialize CAN interface. Plus de détails...
 
eCanError eCanReceiveFrame (xCanFrame *pxFrame)
 Reads a frame from input buffer. Plus de détails...
 
eCanError eCanSendFrame (const xCanFrame *pxFrame)
 Write a frame from to output buffer. Plus de détails...
 
eCanError eCanSetSpeed (eCanSpeed eBaudrate)
 Sets the CAN baud rate. Plus de détails...
 
eCanError eCanTryReceiveFrame (xCanFrame *pxFrame)
 Réception non bloquante d'une trame.
 
eCanError eCanTrySendFrame (const xCanFrame *pxFrame)
 Transmission non bloquante d'une trame.
 
uint8_t ucCanRxAvail (void)
 Checks if data is available in input buffer. Plus de détails...
 
void vCanSetFilter (uint8_t *pucAcceptanceCode, uint8_t *pucAcceptanceMask)
 Sets the acceptance code and mask. Plus de détails...
 
void vCanSetRxTimeout (uint16_t usTimeout)
 Sets the CAN receive timeout. Plus de détails...
 
bool xCanTxFree (void)
 Checks if there's still space in output buffer. Plus de détails...
 

Définitions de type

typedef union xCanArbField xCanArbField
 
typedef union xCanCtrlField xCanCtrlField
 
typedef struct xCanFrame xCanFrame
 

Énumérations

enum  eCanError {
  CAN_SUCCESS = 0, CAN_TXBUF_FULL = -1, CAN_RXBUF_EMPTY = -2, CAN_ILLEGAL_MOB = -3,
  CAN_INVALID_SPEED = -4, CAN_PASSIVE = -5, CAN_BUS_OFF = -6, CAN_TIMEOUT = -7
}
 Codes d'erreur. Plus de détails...
 
enum  eCanSpecification { CAN_2A = 0x01, CAN_2B = 0x02 }
 Version de bus CAN. Plus de détails...
 
enum  eCanSpeed {
  CAN_SPEED_10K = 0, CAN_SPEED_20K = 1, CAN_SPEED_50K = 2, CAN_SPEED_100K = 3,
  CAN_SPEED_125K = 4, CAN_SPEED_250K = 5, CAN_SPEED_500K = 6, CAN_SPEED_800K = 7,
  CAN_SPEED_1M = 8, CAN_SPEED_CUSTOM = 255
}
 Vitesse bus CAN Baud. Plus de détails...
 

Documentation du type de l'énumération

enum eCanError

Codes d'erreur.

Valeurs énumérées
CAN_SUCCESS 

Successful operation

CAN_TXBUF_FULL 

All TX message objects busy

CAN_RXBUF_EMPTY 

All RX message objects busy

CAN_ILLEGAL_MOB 

Message object index out of range

CAN_INVALID_SPEED 

Invalid baud rate parameter

CAN_PASSIVE 

Bus is in passive state

CAN_BUS_OFF 

Bus is bus-off

CAN_TIMEOUT 

Temps d'attente dépassé

Définition à la ligne 82 du fichier can.h.

82  {
83 
84  CAN_SUCCESS = 0,
85  CAN_TXBUF_FULL = -1,
86  CAN_RXBUF_EMPTY = -2,
87  CAN_ILLEGAL_MOB = -3,
88  CAN_INVALID_SPEED = -4,
89  CAN_PASSIVE = -5,
90  CAN_BUS_OFF = -6,
91  CAN_TIMEOUT = -7
92 } eCanError;
eCanError
Codes d&#39;erreur.
Definition: can.h:82

Version de bus CAN.

Valeurs énumérées
CAN_2A 

Version A du protocole

CAN_2B 

Version B du protocole

Définition à la ligne 55 du fichier can.h.

55  {
56 
57  CAN_2A = 0x01,
58  CAN_2B = 0x02
eCanSpecification
Version de bus CAN.
Definition: can.h:55
Definition: can.h:58
Definition: can.h:57
enum eCanSpeed

Vitesse bus CAN Baud.

Valeurs énumérées
CAN_SPEED_10K 

10 kbit/s, max. cable length 5000 m

CAN_SPEED_20K 

20 kbit/s, max. cable length 2500 m

CAN_SPEED_50K 

50 kbit/s, max. cable length 1000 m

CAN_SPEED_100K 

100 kbit/s, max. cable length 600 m

CAN_SPEED_125K 

125 kbit/s, max. cable length 500 m

CAN_SPEED_250K 

250 kbit/s, max. cable length 250 m

CAN_SPEED_500K 

500 kbit/s, max. cable length 100 m

CAN_SPEED_800K 

800 kbit/s, max. cable length 50 m

CAN_SPEED_1M 

1 Mbit/s, max. cable length 25 m

CAN_SPEED_CUSTOM 

Vitesse personnalisée

Définition à la ligne 65 du fichier can.h.

65  {
66  CAN_SPEED_10K = 0,
67  CAN_SPEED_20K = 1,
68  CAN_SPEED_50K = 2,
69  CAN_SPEED_100K = 3,
70  CAN_SPEED_125K = 4,
71  CAN_SPEED_250K = 5,
72  CAN_SPEED_500K = 6,
73  CAN_SPEED_800K = 7,
74  CAN_SPEED_1M = 8,
75  CAN_SPEED_CUSTOM = 255
76 } eCanSpeed;
eCanSpeed
Vitesse bus CAN Baud.
Definition: can.h:65

Documentation des fonctions

eCanError eCanInit ( eCanSpecification  eType)

Initialize CAN interface.

Renvoie
0 for successful initialisation or -1 in case init failed
eCanError eCanReceiveFrame ( xCanFrame pxFrame)

Reads a frame from input buffer.

This function reads a frame from the input buffer. If the input buffer is empty the function will block unitl new frames are received, or the timeout is reached.

Paramètres
pxFramePointer to the receive frame
Renvoie
-1 if timeout, 0 otherwise
eCanError eCanSendFrame ( const xCanFrame pxFrame)

Write a frame from to output buffer.

This function writes a frame to the output buffer. If the output buffer is full the function will block until frames are send.

Paramètres
pxFramePointer to the receive frame
eCanError eCanSetSpeed ( eCanSpeed  eBaudrate)

Sets the CAN baud rate.

Paramètres
eBaudrateBaud rate (One of the defined baud rates. See AtCan.h)
Renvoie
0 for success
uint8_t ucCanRxAvail ( void  )

Checks if data is available in input buffer.

Renvoie
Number of frames available
void vCanSetFilter ( uint8_t *  pucAcceptanceCode,
uint8_t *  pucAcceptanceMask 
)

Sets the acceptance code and mask.

Paramètres
pucAcceptanceCode4 byte char array with the acceptance mask
void vCanSetRxTimeout ( uint16_t  usTimeout)

Sets the CAN receive timeout.

Paramètres
usTimeoutTimeout in milliseconds, WAIT_INFINITE = no time-out
Avertissement
Timeout values are given in milliseconds and are limited to the granularity of the system timer. To disable timeout, set the parameter to WAIT_INFINITE.
bool xCanTxFree ( void  )

Checks if there's still space in output buffer.

Renvoie
true if space is available