Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

AT90CAN128 CAN device
[Device Drivers]

Collaboration diagram for AT90CAN128 CAN device:


Detailed Description

Driver for Atmel's internal Full CAN controller.


Data Structures

struct  _CANBuffer

Defines

#define MAX_NO_MOB   15
#define RX_MOB   8
#define CAN_BUF_SIZE   64

Typedefs

typedef _CANBuffer CANBuffer

Enumerations

enum  CAN_RESULT {
  CAN_SUCCESS = 0, CAN_TXBUF_FULL = -1, CAN_RXBUF_EMPTY = -2, CAN_ILLEGAL_MOB = -3,
  CAN_INVALID_SPEED = -4
}

Functions

int8_t AtCanGetFreeMob (void)
int8_t AtCanEnableMsgObj (uint8_t mob, uint32_t id, int8_t idIsExt, int8_t idRemTag, uint32_t mask, int8_t maskIsExt, int8_t maskRemTag)
int8_t AtCanEnableRx (uint8_t noOfMsgObjs, uint32_t id, int8_t idIsExt, int8_t idRemTag, uint32_t mask, int8_t maskIsExt, int8_t maskRemTag)
int8_t AtCanSendMsg (CANFRAME *frame)
u_char AtCanRxAvail (NUTDEVICE *dev)
u_char AtCanTxFree (NUTDEVICE *dev)
void AtCanOutput (NUTDEVICE *dev, CANFRAME *frame)
void AtCanInput (NUTDEVICE *dev, CANFRAME *frame)
void AtCanSetAccCode (NUTDEVICE *dev, u_char *ac)
void AtCanSetAccMask (NUTDEVICE *dev, u_char *am)
u_char AtCanSetBaudrate (NUTDEVICE *dev, u_long baudrate)
int AtCanInit (NUTDEVICE *dev)

Variables

NUTDEVICE devAtCan
CANBuffer canRxBuf
CANINFO dcb_atcan
IFCAN ifc_atcan
NUTDEVICE devAtCan


Enumeration Type Documentation

enum CAN_RESULT
 

CAN result codes

Enumeration values:
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.


Function Documentation

int8_t AtCanEnableMsgObj uint8_t  mob,
uint32_t  id,
int8_t  idIsExt,
int8_t  idRemTag,
uint32_t  mask,
int8_t  maskIsExt,
int8_t  maskRemTag
 

Configure a single message object for receiption.

Parameters:
mob Message object index (0-14)
id Acceptance code
idIsExt Flag if acceptance code is extended (0 = standard, 1 = extended)
idRemTag Id's remote tag (0 or 1)
mask Acceptance mask
maskIsExt Flag if acceptance mask is extended (0 = standard, 1 = extended)
maskRemTag Mask's remote tag (0 or 1)
Returns:
Result code. See CAN_RESULT

int8_t AtCanEnableRx uint8_t  noOfMsgObjs,
uint32_t  id,
int8_t  idIsExt,
int8_t  idRemTag,
uint32_t  mask,
int8_t  maskIsExt,
int8_t  maskRemTag
 

Configure message objects for receiption.

Parameters:
noOfMsgObjs Number of message objects used for receiption (1-14). Message objects not configured for receiption are used for transmission. The same acceptance filter and mask is applied to the message objects. If it is required to set-up more complex filtering mechanisms use canEnableMsgObj() instead, which allows setting filters on a per message object basis.
id Acceptance code
idIsExt Flag if acceptance code is extended (0 = standard, 1 = extended)
idRemTag Id's remote tag (0 or 1)
mask Acceptance mask
maskIsExt Flag if acceptance mask is extended (0 = standard, 1 = extended)
maskRemTag Mask's remote tag (0 or 1)
Returns:
Result code. See CAN_RESULT

int8_t AtCanSendMsg CANFRAME frame  ) 
 

Send a CAN message

Parameters:
frame Container for CAN message to be sent
Returns:
Result code. See CAN_RESULT

u_char AtCanRxAvail NUTDEVICE dev  ) 
 

Checks if data is available in input buffer

Parameters:
dev Pointer to the device structure
Returns:
Number of frames available

u_char AtCanTxFree NUTDEVICE dev  ) 
 

Checks if there's still space in output buffer

Parameters:
dev Pointer to the device structure
Returns:
1 if space is available

void AtCanOutput NUTDEVICE dev,
CANFRAME frame
 

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.

Parameters:
dev Pointer to the device structure
frame Pointer to the receive frame

void AtCanInput NUTDEVICE dev,
CANFRAME frame
 

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.

Parameters:
dev Pointer to the device structure
frame Pointer to the receive frame

void AtCanSetAccCode NUTDEVICE dev,
u_char ac
 

Sets the acceptance code

Parameters:
dev Pointer to the device structure
ac 4 byte char array with the acceptance code

void AtCanSetAccMask NUTDEVICE dev,
u_char am
 

Sets the acceptance mask

Parameters:
dev Pointer to the device structure
am 4 byte char array with the acceptance mask

u_char AtCanSetBaudrate NUTDEVICE dev,
u_long  baudrate
 

Sets the CAN baudrate

Parameters:
dev Pointer to the device structure
baudrate Baudrate (One of the defined baudrates. See AtCan.h)
Returns:
0 for success

int AtCanInit NUTDEVICE dev  ) 
 

Initialize CAN interface.

Applications typically do not use this function, but call NutRegisterDevice().

Parameters:
dev Identifies the device to initialize. The structure must be properly set.
Returns:
0 for successful initialisation or -1 in case init failed


Variable Documentation

NUTDEVICE devAtCan
 

Initial value:

 {
    0,                          
    {'a', 't', 'c', 'a', 'n', '0', 0, 0, 0}, 
    IFTYP_CAN,                  
    0,                          
    0,                          
    &ifc_atcan,                 
    &dcb_atcan,                 
    AtCanInit,                  
    0,                          
    0,                          
    0,                          
    0,                          
    0,                          
    0,                          
    0                           
}
Device information structure.

Applications must pass this structure to NutRegisterDevice() to bind this CAN device driver to the Nut/OS kernel.

IFCAN ifc_atcan
 

Initial value:

 {
    CAN_IF_2B,                 
    CAN_SPEED_125K,            
    {0xFF, 0xFF, 0xFF, 0xFF},  
    {0x00, 0x00, 0x00, 0x00},  
    AtCanRxAvail,              
    AtCanTxFree,               
    AtCanInput,                
    AtCanOutput,               
    AtCanSetAccCode,           
    AtCanSetAccMask,           
    AtCanSetBaudrate           
}
Interface information structure.

This structure stores some interface parameters like bit rate, acceptance mask, acceptance code and callback handlers.

NUTDEVICE devAtCan
 

Initial value:

 {
    0,                          
    {'a', 't', 'c', 'a', 'n', '0', 0, 0, 0}, 
    IFTYP_CAN,                  
    0,                          
    0,                          
    &ifc_atcan,                 
    &dcb_atcan,                 
    AtCanInit,                  
    0,                          
    0,                          
    0,                          
    0,                          
    0,                          
    0,                          
    0                           
}
Device information structure.

Applications must pass this structure to NutRegisterDevice() to bind this CAN device driver to the Nut/OS kernel.


© 2000-2006 by egnite Software GmbH - visit http://www.ethernut.de/