libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Go to the source code of this file.
Functions | |
int | fdcan_cccr_init_cfg (uint32_t canport, bool set, uint32_t timeout) |
Routine implementing FDCAN_CCCR's INIT bit manipulation. More... | |
static int | fdcan_get_free_txbuf (uint32_t canport) |
Return ID of next free Tx buffer. More... | |
static void | fdcan_get_fill_rxfifo (uint32_t canport, uint8_t fifo_id, unsigned *get_index, unsigned *pending_frames) |
Returns fill state and next available get index from receive FIFO. More... | |
struct fdcan_standard_filter * | fdcan_get_flssa_addr (uint32_t canport) |
Returns standard filter start address in message RAM. More... | |
struct fdcan_extended_filter * | fdcan_get_flesa_addr (uint32_t canport) |
Returns extended filter start address in message RAM. More... | |
struct fdcan_rx_fifo_element * | fdcan_get_rxfifo_addr (uint32_t canport, unsigned fifo_id, unsigned element_id) |
Returns a pointer to an RX FIFO element in message RAM. More... | |
struct fdcan_tx_event_element * | fdcan_get_txevt_addr (uint32_t canport) |
Returns transmit event start address in message RAM. More... | |
struct fdcan_tx_buffer_element * | fdcan_get_txbuf_addr (uint32_t canport, unsigned element_id) |
Returns a pointer to an TX FIFO element in message RAM. More... | |
uint32_t | fdcan_length_to_dlc (uint8_t length) |
Converts frame length to DLC value. More... | |
uint8_t | fdcan_dlc_to_length (uint32_t dlc) |
Converts DLC value into frame payload length. More... | |
int | fdcan_init (uint32_t canport, uint32_t timeout) |
Put FDCAN block into INIT mode for setup. More... | |
void | fdcan_set_can (uint32_t canport, bool auto_retry_disable, bool rx_fifo_locked, bool tx_queue_mode, bool silent, uint32_t n_sjw, uint32_t n_ts1, uint32_t n_ts2, uint32_t n_br_presc) |
Set essential FDCAN block parameters for plain CAN operation. More... | |
void | fdcan_set_fdcan (uint32_t canport, bool brs_enable, bool fd_op_enable, uint32_t f_sjw, uint32_t f_ts1, uint32_t f_ts2, uint32_t f_br_presc) |
Set FDCAN block parameters for FDCAN transmission. More... | |
void | fdcan_set_test (uint32_t canport, bool testing, bool loopback) |
Set FDCAN block testing features. More... | |
int | fdcan_get_init_state (uint32_t canport) |
Return current FDCAN block operation state. More... | |
void | fdcan_set_std_filter (uint32_t canport, uint32_t nr, uint8_t id_list_mode, uint32_t id1, uint32_t id2, uint8_t action) |
Configure filter rule for standard ID frames. More... | |
void | fdcan_set_ext_filter (uint32_t canport, uint32_t nr, uint8_t id_list_mode, uint32_t id1, uint32_t id2, uint8_t action) |
Configure filter rule for extended ID frames. More... | |
int | fdcan_transmit (uint32_t canport, uint32_t id, bool ext, bool rtr, bool fdcan_fmt, bool btr_switch, uint8_t length, const uint8_t *data) |
Transmit Message using FDCAN. More... | |
int | fdcan_receive (uint32_t canport, uint8_t fifo_id, bool release, uint32_t *id, bool *ext, bool *rtr, uint8_t *fmi, uint8_t *length, uint8_t *data, uint16_t *timestamp) |
Receive Message from FDCAN FIFO. More... | |
void | fdcan_release_fifo (uint32_t canport, uint8_t fifo_id) |
Release receive oldest FIFO entry. More... | |
void | fdcan_enable_irq (uint32_t canport, uint32_t irq) |
Enable IRQ from FDCAN block. More... | |
void | fdcan_disable_irq (uint32_t canport, uint32_t irq) |
Disable IRQ from FDCAN block. More... | |
bool | fdcan_available_tx (uint32_t canport) |
Check if there is free transmit buffer. More... | |
bool | fdcan_available_rx (uint32_t canport, uint8_t fifo) |
Tell if there is message waiting in receive FIFO. More... | |
int fdcan_cccr_init_cfg | ( | uint32_t | canport, |
bool | set, | ||
uint32_t | timeout | ||
) |
Routine implementing FDCAN_CCCR's INIT bit manipulation.
This routine will change INIT bit and wait for it to actually change its value. If change won't happen before timeout, error is signalized. If INIT bit already has value which should be set, this function will return immediately.
[in] | canport | FDCAN block base address. See FDCAN block base addresses. |
[in] | set | new value of INIT, true means set |
[in] | timeout | Amount of busyloop cycles, function will wait for FDCAN to switch it's state. If set to 0, then function returns immediately. |
Definition at line 41 of file fdcan_common.c.
References FDCAN_CCCR, FDCAN_CCCR_INIT, FDCAN_E_OK, and FDCAN_E_TIMEOUT.
Referenced by fdcan_init(), and fdcan_start().
uint8_t fdcan_dlc_to_length | ( | uint32_t | dlc | ) |
Converts DLC value into frame payload length.
Works for both CAN and FDCAN DLC values.
[in] | dlc | DLC value |
Definition at line 221 of file fdcan_common.c.
Referenced by fdcan_get_fifo_element_size(), fdcan_get_txbuf_element_size(), and fdcan_receive().
|
static |
Returns fill state and next available get index from receive FIFO.
Examines FDCAN receive FIFO and returns fill status of FIFO and ID of next message available for reading. If fill status is 0 (FIFO is empty), then get index is undefined.
[in] | canport | FDCAN block base address. See FDCAN block base addresses. |
[in] | fifo_id | ID of fifo queried (currently 0 or 1) |
[out] | get_index | Address of buffer where next get index will be stored |
[out] | pending_frames | Address of buffer where amount of pending frame will be stored. |
Definition at line 109 of file fdcan_common.c.
References FDCAN_RXFIFO_FL_MASK, FDCAN_RXFIFO_FL_SHIFT, FDCAN_RXFIFO_GI_MASK, FDCAN_RXFIFO_GI_SHIFT, and FDCAN_RXFIS.
Referenced by fdcan_receive().
struct fdcan_extended_filter * fdcan_get_flesa_addr | ( | uint32_t | canport | ) |
Returns extended filter start address in message RAM.
[in] | canport | FDCAN block base address. See FDCAN block base addresses. |
Definition at line 136 of file fdcan_common.c.
References CAN_MSG_BASE, and FDCAN_LFESA_OFFSET.
Referenced by fdcan_init_filter(), and fdcan_set_ext_filter().
struct fdcan_standard_filter * fdcan_get_flssa_addr | ( | uint32_t | canport | ) |
Returns standard filter start address in message RAM.
[in] | canport | FDCAN block base address. See FDCAN block base addresses. |
Definition at line 124 of file fdcan_common.c.
References CAN_MSG_BASE, and FDCAN_LFSSA_OFFSET.
Referenced by fdcan_init_filter(), and fdcan_set_std_filter().
|
static |
Return ID of next free Tx buffer.
Examines transmit buffer allocation in message RAM and returns ID of buffer, which is free.
[in] | canport | FDCAN block base address. See FDCAN block base addresses. |
Definition at line 85 of file fdcan_common.c.
References FDCAN_E_BUSY, FDCAN_TXBRP, FDCAN_TXBRP_TRP0, FDCAN_TXBRP_TRP1, and FDCAN_TXBRP_TRP2.
Referenced by fdcan_available_tx(), and fdcan_transmit().
struct fdcan_rx_fifo_element * fdcan_get_rxfifo_addr | ( | uint32_t | canport, |
unsigned | fifo_id, | ||
unsigned | element_id | ||
) |
Returns a pointer to an RX FIFO element in message RAM.
[in] | canport | FDCAN block base address. See FDCAN block base addresses. |
[in] | fifo_id | ID of FIFO whose address is requested |
[in] | element_id | the element number in the fifo we're requesting |
Definition at line 150 of file fdcan_common.c.
References CAN_MSG_BASE, fdcan_get_fifo_element_size(), and FDCAN_RXFIFO_OFFSET.
Referenced by fdcan_receive().
struct fdcan_tx_buffer_element * fdcan_get_txbuf_addr | ( | uint32_t | canport, |
unsigned | element_id | ||
) |
Returns a pointer to an TX FIFO element in message RAM.
[in] | canport | FDCAN block base address. See FDCAN block base addresses. |
[in] | element_id | the element number in the fifo we're requesting |
Definition at line 178 of file fdcan_common.c.
References CAN_MSG_BASE, fdcan_get_txbuf_element_size(), and FDCAN_TXBUF_OFFSET.
Referenced by fdcan_transmit().
struct fdcan_tx_event_element * fdcan_get_txevt_addr | ( | uint32_t | canport | ) |
Returns transmit event start address in message RAM.
[in] | canport | FDCAN block base address. See FDCAN block base addresses. |
Definition at line 165 of file fdcan_common.c.
References CAN_MSG_BASE, and FDCAN_TXEVT_OFFSET.
uint32_t fdcan_length_to_dlc | ( | uint8_t | length | ) |
Converts frame length to DLC value.
Works for both CAN and FDCAN frame lengths. If length is invalid value, then returns 0xFF.
[in] | length | intended frame payload length in bytes |
Definition at line 197 of file fdcan_common.c.
Referenced by fdcan_set_rx_element_size(), fdcan_set_tx_element_size(), and fdcan_transmit().