16FXlib
can.h File Reference

Go to the source code of this file.

Functions

uint8_t can_init (uint8_t prescaler, uint8_t propSeg, uint8_t phSeg1, uint8_t phSeg2, uint8_t jumpWidth, uint8_t interrupts)
 
uint8_t can_config_buffer (uint8_t buffer, uint32_t id, uint8_t options, uint8_t maskOptions, uint32_t idMask)
 
uint8_t can_set_buffer_autoreply (uint8_t buffer, uint8_t enable)
 
uint8_t can_set_buffer_data (uint8_t buffer, uint8_t *data, uint8_t len)
 
uint8_t can_send_buffer (uint8_t buffer)
 
uint8_t can_buffer_newData (uint8_t buffer)
 
int8_t can_buffer_getData (uint8_t buffer, uint8_t *data, uint32_t *id)
 

Macros

CAN-ID conversions

Defines macros conversion between numeric CAN-IDs and their representations in the CAN engine.

#define ID_TO_STDFRAME(id)   ((id & 0x000007FFL) << 18)
 
#define ID_TO_EXTFRAME(id)   (id & 0x1FFFFFFFL)
 
#define STDFRAME_TO_ID(reg)   (((reg & 0x1FFFFFFFL) >> 18) & 0x000007FFL)
 
#define EXTFRAME_TO_ID(reg)   (reg & 0x1FFFFFFFL)
 
Baudrate selections

Defines for standard baudrates usable with can_init. Values are: prescaler, TQ in propagation segment, TQ phase buffer segment 1, TQ phase buffer segment 2, TQ resynchronization jump width

#define CAN_BAUD_50K   14, 8, 6, 5, 1
 
#define CAN_BAUD_125K   7, 7, 4, 4, 1
 
#define CAN_BAUD_1000K   1, 7, 3, 3, 1
 
Buffer options

Options that can be passed to can_config_buffer as "options". Can be or'ed together.

#define CAN_BUF_OPT_ENABLED   (_BV(0))
 
#define CAN_BUF_OPT_TRANSMIT   (_BV(1))
 
#define CAN_BUF_OPT_EXTENDED   (_BV(2))
 
#define CAN_BUF_OPT_RX_INTERRUPT   (_BV(4))
 
#define CAN_BUF_OPT_TX_INTERRUPT   (_BV(5))
 
Buffer mask options

Options that can be passed to can_config_buffer as "maskOptions". Can be or'ed together.

#define CAN_BUF_MASK_USE   (_BV(0))
 
#define CAN_BUF_MASK_EXTENDED   (_BV(1))
 
#define CAN_BUF_MASK_DIRECTION   (_BV(2))