16FXlib
|
Modules | |
Internal configurations (can.cfg.h) | |
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) |
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)) |
uint8_t can_init | ( | uint8_t | prescaler, |
uint8_t | propSeg, | ||
uint8_t | phSeg1, | ||
uint8_t | phSeg2, | ||
uint8_t | jumpWidth, | ||
uint8_t | interrupts | ||
) |
(Re)Initializes I/Os and registers of CAN controller. Defined constants CAN_BAUD_* can be used for bit timing (constants.h).
prescaler | Prescaler () |
propSeg | Number of TQ for Propagation Segment (1 - 8) |
phSeg1 | Number of TQ for the Phase Segment 1 (2 - 8) |
phSeg2 | Number of TQ for Phase Segment 2 (2 - 8) |
jumpWidth | ResynchronizationJumpWidth (in TQ) (1 - 4) |
interrupts | If set CAN interrupts will be enabled |
uint8_t can_config_buffer | ( | uint8_t | buffer, |
uint32_t | id, | ||
uint8_t | options, | ||
uint8_t | maskOptions, | ||
uint32_t | idMask | ||
) |
Configures a CAN message buffer
buffer | Buffer to configure (1 - CAN_BUFFERCOUNT) |
id | CAN-ID to set |
options | Set buffer options. See defines CAN_BUF_OPT_* |
maskOptions | Set mask options. See defines CAN_BUF_MASK_* |
idMask | CAN-ID mask. Only used when CAN_BUF_MASK_USE is given in maskOptions |
Enable or disable automatic replies to appropriate remote-transmit-requests.
buffer | Buffer to configure (1 - CAN_BUFFERCOUNT) |
enable | Enable (1) or disable (0) automatic replies for this buffer |
Set data of buffer
buffer | Buffer to fill data in (1 - CAN_BUFFERCOUNT) |
data | Pointer to data to put in buffer |
len | Number of bytes to put (0 - 8) |
Set data of buffer
buffer | Buffer to send (1 - CAN_BUFFERCOUNT) |
Set data of buffer
buffer | Buffer to check for new data (1 - CAN_BUFFERCOUNT) or 0 to check all buffers |
Get data of buffer
buffer | Buffer to read data from (1 - CAN_BUFFERCOUNT) |
data | Pointer to target memory for data, should be at least 8 bytes long as long as you do not exactly know how many bytes there will be in the buffer |
id | Pointer to target memory for read CAN ID |
#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) |
#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 |
#define CAN_BUF_OPT_ENABLED (_BV(0)) |
Enables the buffer for reception/transmission of frames (Flag for options of can_config_buffer)
#define CAN_BUF_OPT_TRANSMIT (_BV(1)) |
Sets the buffer to be a transmit buffer (can respond automaticly to RTR frames if enabled afterwards) (Flag for options of can_config_buffer)
#define CAN_BUF_OPT_EXTENDED (_BV(2)) |
Sets the buffer to be used for extended frames (Flag for options of can_config_buffer)
#define CAN_BUF_OPT_RX_INTERRUPT (_BV(4)) |
Enables the RX interrupt for the buffer (Flag for options of can_config_buffer)
#define CAN_BUF_OPT_TX_INTERRUPT (_BV(5)) |
Enables the TX interrupt for the buffer (Flag for options of can_config_buffer)
#define CAN_BUF_MASK_USE (_BV(0)) |
Enables the masks for the buffer acceptance filtering (otherwise always the whole header is used for arbitration) (Flag for maskOptions of can_config_buffer)
#define CAN_BUF_MASK_EXTENDED (_BV(1)) |
Selects the extended bit to be checked for acceptance filtering. Only used if CAN_BUF_MASK_USE is also given (Flag for maskOptions of can_config_buffer)
#define CAN_BUF_MASK_DIRECTION (_BV(2)) |
Selects the direction bit to be checked for acceptance filtering. Only used if CAN_BUF_MASK_USE is also given (Flag for maskOptions of can_config_buffer)