66 while ((wait_ack--) &&
110 unsigned *pending_frames)
151 unsigned fifo_id,
unsigned element_id)
201 }
else if (length <= 24) {
202 if ((length % 4) != 0) {
205 return 8 + ((length - 8) / 4);
207 if ((length % 16) != 0) {
210 return 11 + (length / 16);
225 }
else if (dlc <= 12) {
226 return 8 + ((dlc - 8) * 4);
228 return 16 + ((dlc - 12) * 16);
296void fdcan_set_can(uint32_t canport,
bool auto_retry_disable,
bool rx_fifo_locked,
297 bool tx_queue_mode,
bool silent, uint32_t n_sjw, uint32_t n_ts1, uint32_t n_ts2,
311 if (auto_retry_disable) {
344 uint32_t f_sjw, uint32_t f_ts1, uint32_t f_ts2, uint32_t f_br_presc)
419 uint8_t id_list_mode, uint32_t id1, uint32_t id2,
459 uint8_t id_list_mode, uint32_t id1, uint32_t id2,
487 bool fdcan_fmt,
bool btr_switch, uint8_t length,
const uint8_t *data)
490 uint32_t dlc, flags = 0;
532 for (
int q = 0; q < length; q += 4) {
533 tx_buffer->
data[q / 4] = *((uint32_t *) &
data[q]);
562int fdcan_receive(uint32_t canport, uint8_t fifo_id,
bool release, uint32_t *
id,
563 bool *ext,
bool *rtr, uint8_t *fmi, uint8_t *length,
564 uint8_t *
data, uint16_t *timestamp)
566 unsigned pending_frames, get_index, dlc, len;
570 if (pending_frames == 0) {
607 for (
unsigned int q = 0; q < len; q += 4) {
608 *((uint32_t *) &
data[q]) = fifo->
data[q / 4];
630 unsigned pending_frames, get_index;
638 if (pending_frames) {
689 unsigned pending_frames;
694 return (pending_frames != 0);
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.
uint8_t fdcan_dlc_to_length(uint32_t dlc)
Converts DLC value into frame payload length.
int fdcan_cccr_init_cfg(uint32_t canport, bool set, uint32_t timeout)
Routine implementing FDCAN_CCCR's INIT bit manipulation.
struct fdcan_standard_filter * fdcan_get_flssa_addr(uint32_t canport)
Returns standard filter start address in message RAM.
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.
static int fdcan_get_free_txbuf(uint32_t canport)
Return ID of next free Tx buffer.
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.
struct fdcan_tx_event_element * fdcan_get_txevt_addr(uint32_t canport)
Returns transmit event start address in message RAM.
struct fdcan_extended_filter * fdcan_get_flesa_addr(uint32_t canport)
Returns extended filter start address in message RAM.
uint32_t fdcan_length_to_dlc(uint8_t length)
Converts frame length to DLC value.
#define FDCAN_RXFIFO_FL_MASK
#define FDCAN_LFSSA_OFFSET(can_base)
#define FDCAN_DBTP_DTSEG1_SHIFT
DTSEG1[4:0]: Data time segment before sample point.
#define FDCAN_TXBRP(can_base)
#define FDCAN_TXBAR(can_base)
#define FDCAN_TXEVT_OFFSET(can_base)
#define FDCAN_NBTP_NTSEG1_SHIFT
NTSEG1[7:0]: Nominal timing segment before sample point length.
#define FDCAN_FIFO_RXTS_SHIFT
#define FDCAN_FIFO_EID_SHIFT
#define FDCAN_RXFIFO_GI_MASK
#define FDCAN_TEST(can_base)
#define FDCAN_FIFO_SID_SHIFT
#define FDCAN_TXBUF_OFFSET(can_base)
#define FDCAN_DBTP_DSJW_SHIFT
DSJW[3:0]: Synchronization jump width.
#define FDCAN_FIFO_EID_MASK
#define FDCAN_EFID1_SHIFT
#define FDCAN_DBTP_DBRP_SHIFT
DBRP[4:0]: Data bit rate prescaler.
#define FDCAN_FIFO_MM_SHIFT
#define FDCAN_NBTP(can_base)
#define FDCAN_RXFIFO_AI_SHIFT
Rx FIFOs acknowledge index.
#define FDCAN_DBTP(can_base)
#define FDCAN_DBTP_DTSEG2_SHIFT
DTSEG2[3:0]: Data time segment after sample point.
#define FDCAN_SFID1_SHIFT
#define FDCAN_FIFO_MM_MASK
#define FDCAN_FIFO_DLC_SHIFT
#define FDCAN_RXFIA(can_base, fifo_id)
Generic access to Rx FIFO acknowledge registers.
#define FDCAN_NBTP_NTSEG2_SHIFT
NTSEG2[6:0]: Nominal timing segment after sample point length.
#define FDCAN_RXFIFO_OFFSET(can_base, fifo_id)
#define FDCAN_NBTP_NBRP_SHIFT
NBRP[8:0]: Norminal timing bit rate prescaler.
#define FDCAN_ILE(can_base)
#define FDCAN_LFESA_OFFSET(can_base)
#define FDCAN_FIFO_DLC_MASK
#define FDCAN_RXFIFO_GI_SHIFT
Get index of Rx FIFOs.
#define FDCAN_FIFO_RXTS_MASK
#define FDCAN_RXFIS(can_base, fifo_id)
Generic access to Rx FIFO status registers.
#define FDCAN_NBTP_NSJW_SHIFT
NSJW[6:0]: Norminal timing resynchronization jumb width.
#define FDCAN_TXBC(can_base)
#define FDCAN_SFID2_SHIFT
#define FDCAN_FIFO_SID_MASK
#define FDCAN_CCCR(can_base)
#define FDCAN_RXFIFO_FL_SHIFT
Fill level of Rx FIFOs.
#define FDCAN_EFID2_SHIFT
#define FDCAN_E_BUSY
Device is busy: Transmit buffer is full, unable to queue additional message or device is outside of I...
#define FDCAN_E_TIMEOUT
Timeout waiting for FDCAN block to accept INIT bit change.
#define FDCAN_E_OK
No error.
#define FDCAN_E_NOTAVAIL
Receive buffer is empty, unable to read any new message.
#define FDCAN_E_INVALID
Value provided was invalid (FIFO index, FDCAN block base address, length, etc.)
int fdcan_init(uint32_t canport, uint32_t timeout)
Put FDCAN block into INIT mode for setup.
void fdcan_set_fifo_locked_mode(uint32_t canport, bool locked)
Configure FDCAN FIFO lock mode.
bool fdcan_available_tx(uint32_t canport)
Check if there is free transmit buffer.
void fdcan_disable_irq(uint32_t canport, uint32_t irq)
Disable IRQ from FDCAN block.
void fdcan_release_fifo(uint32_t canport, uint8_t fifo_id)
Release receive oldest FIFO entry.
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.
void fdcan_set_test(uint32_t canport, bool testing, bool loopback)
Set FDCAN block testing features.
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.
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.
bool fdcan_available_rx(uint32_t canport, uint8_t fifo)
Tell if there is message waiting in receive FIFO.
void fdcan_enable_irq(uint32_t canport, uint32_t irq)
Enable IRQ from FDCAN block.
int fdcan_get_init_state(uint32_t canport)
Return current FDCAN block operation state.
unsigned fdcan_get_fifo_element_size(uint32_t canport, unsigned fifo_id)
Returns actual size of FIFO entry in FIFO for given CAN port and FIFO.
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.
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.
unsigned fdcan_get_txbuf_element_size(uint32_t canport)
Returns actual size of transmit entry in transmit queue/FIFO for given CAN port.
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.
Structure describing extended ID filters.
uint32_t type_id2
Aggregate of filter type and extended ID or mask.
uint32_t conf_id1
Aggregate of filter action and extended ID.
Structure describing receive FIFO element.
uint32_t filt_fmt_dlc_ts
Aggregate of filter match ID, transfer format, DLC and timestamp.
uint32_t identifier_flags
Aggregate of message identifier and flags.
uint32_t data[64/sizeof(uint32_t)]
Message payload data.
Structure describing standard ID filter.
uint32_t type_id1_conf_id2
Aggregate of filter type, filter action and two IDs
Structure describing transmit buffer element.
uint32_t data[64/sizeof(uint32_t)]
Message payload data.
uint32_t evt_fmt_dlc_res
Aggregate of event ID, transfer format and DLC.
uint32_t identifier_flags
Aggregate of message identifier and flags.
Structure describing transmit event element.