libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
CAN Application Programming Interface. More...
Functions | |
void | can_enable (uint32_t canport) |
CAN Enable Enable the CAN peripheral and its associated FIFOs/counters/interrupts. More... | |
void | can_disable (uint32_t canport) |
CAN Disable Disable the CAN peripheral and all associated FIFOs/counters/interrupts. More... | |
void | can_init (uint32_t canport, bool listen_only, uint32_t sjw, uint32_t tseg1, uint32_t tseg2, bool sam3, uint32_t brp) |
CAN Init Initialize the selected CAN peripheral block. More... | |
void | can_filter_clear (uint32_t canport) |
CAN Filter Clear Clear the message filters to receive all messages. More... | |
void | can_filter_dual (uint32_t canport, uint32_t id1, uint32_t id1_mask, uint32_t id2, uint32_t id2_mask, uint8_t db, uint8_t db_mask) |
CAN Dual Filter Standard Frame Notes: More... | |
void | can_filter_single_std (uint32_t canport, uint32_t id, uint32_t id_mask, uint8_t db1, uint8_t db1_mask, uint8_t db2, uint8_t db2_mask) |
CAN Filter Single Standard Frame Notes: More... | |
void | can_filter_single_std_rtr (uint32_t canport, uint32_t id, uint32_t id_mask, uint8_t db1, uint8_t db1_mask, uint8_t db2, uint8_t db2_mask) |
CAN Filter Single Standard Frame w/RTR set Notes: More... | |
void | can_filter_single_ext (uint32_t canport, uint32_t id, uint32_t id_mask) |
CAN Filter Single Extended Frame Notes: More... | |
void | can_filter_single_ext_rtr (uint32_t canport, uint32_t id, uint32_t id_mask) |
CAN Filter Single Extended Frame w/RTR set Notes: More... | |
void | can_enable_irq (uint32_t canport, uint8_t imr) |
CAN Enable IRQ. More... | |
void | can_disable_irq (uint32_t canport, uint8_t imr) |
CAN Disable IRQ. More... | |
bool | can_transmit_std (uint32_t canport, uint32_t id, bool rtr, uint8_t length, const uint8_t *data) |
CAN Transmit Standard Frame. More... | |
bool | can_transmit_ext (uint32_t canport, uint32_t id, bool rtr, uint8_t length, const uint8_t *data) |
CAN Transmit Extended Frame. More... | |
void | can_abort_transmit (uint32_t canport) |
CAN Abort Transmit Aborts the current transmission. More... | |
void | can_receive (uint32_t canport, uint32_t *id, bool *ext, bool *rtr, uint8_t *length, uint8_t *data) |
CAN Receive Message If no data is in the RX buffer, id and length are set to 0. More... | |
CAN Application Programming Interface.
PAC55xxxx CAN Driver
This library supports the CAN module in the PAC55xx SoC from Qorvo.
Note: Acceptance Code Mask Register values of 1 indicate the filter is to ignore the bit. However, standard CAN driver APIs use a positive logic for the mask. The implementations in this file inverts masks as appropriate to the mask to make this more portable/intuitive.
LGPL License Terms libopencm3 License
void can_abort_transmit | ( | uint32_t | canport | ) |
CAN Abort Transmit Aborts the current transmission.
[in] | canport | Unsigned int32. CAN block register base address. |
Definition at line 369 of file can.c.
References CAN_CMR_AT, and CAN_ISR_SR_CMR_MR_SET.
void can_disable | ( | uint32_t | canport | ) |
CAN Disable Disable the CAN peripheral and all associated FIFOs/counters/interrupts.
[in] | canport | Unsigned int32. CAN block register base address. |
Definition at line 50 of file can.c.
References CAN_ISR_SR_CMR_MR_SET, and CAN_MR_RM.
void can_disable_irq | ( | uint32_t | canport, |
uint8_t | irq | ||
) |
CAN Disable IRQ.
[in] | canport | Unsigned int32. CAN block register base address. |
[in] | irq | Unsigned int8. IRQ bit(s). |
Definition at line 278 of file can.c.
References CAN_BTR1_BTR0_RMC_IMR.
void can_enable | ( | uint32_t | canport | ) |
CAN Enable Enable the CAN peripheral and its associated FIFOs/counters/interrupts.
[in] | canport | Unsigned int32. CAN block register base address. |
Definition at line 41 of file can.c.
References CAN_ISR_SR_CMR_MR_CLEAR, and CAN_MR_RM.
void can_enable_irq | ( | uint32_t | canport, |
uint8_t | irq | ||
) |
CAN Enable IRQ.
[in] | canport | Unsigned int32. CAN block register base address. |
[in] | irq | Unsigned int8. IRQ bit(s). |
Definition at line 268 of file can.c.
References CAN_BTR1_BTR0_RMC_IMR.
void can_filter_clear | ( | uint32_t | canport | ) |
CAN Filter Clear Clear the message filters to receive all messages.
[in] | canport | Unsigned int32. CAN block register base address. |
Definition at line 96 of file can.c.
References CAN_ACR, CAN_AMR, CAN_ISR_SR_CMR_MR_SET, and CAN_MR_AFM.
void can_filter_dual | ( | uint32_t | canport, |
uint32_t | id1, | ||
uint32_t | id1_mask, | ||
uint32_t | id2, | ||
uint32_t | id2_mask, | ||
uint8_t | db, | ||
uint8_t | db_mask | ||
) |
CAN Dual Filter Standard Frame Notes:
[in] | canport | Unsigned int32. CAN block register base address. |
[in] | id1 | Unsigned int32. CAN ID 1. Only bits 10:0 are used. |
[in] | id1_mask | Unsigned int32. CAN ID 1 mask. Only bits 10:0 are used. |
[in] | id2 | Unsigned int32. CAN ID 2. Only bits 10:0 are used. |
[in] | id2_mask | Unsigned int32. CAN ID 2 mask. Only bits 10:0 are used. |
[in] | db | bool. CAN first data byte value. |
[in] | db_mask | bool. CAN first data byte mask. |
Definition at line 123 of file can.c.
References CAN_ACR, CAN_ACR_DUAL_DB_LOWER, CAN_ACR_DUAL_DB_UPPER, CAN_ACR_DUAL_ID1, CAN_ACR_DUAL_ID2, CAN_ACR_DUAL_RTR1, CAN_ACR_DUAL_RTR2, CAN_AMR, CAN_ISR_SR_CMR_MR_CLEAR, and CAN_MR_AFM.
void can_filter_single_ext | ( | uint32_t | canport, |
uint32_t | id, | ||
uint32_t | id_mask | ||
) |
CAN Filter Single Extended Frame Notes:
[in] | canport | Unsigned int32. CAN block register base address. |
[in] | id | Unsigned int32. CAN ID. Only bits 28:0 are used. |
[in] | id_mask | Unsigned int32. CAN ID mask. Only bits 28:0 are used. |
Definition at line 227 of file can.c.
References CAN_ACR, CAN_ACR_SINGLE_EXT_ID, CAN_ACR_SINGLE_EXT_RTR, CAN_AMR, CAN_ISR_SR_CMR_MR_SET, and CAN_MR_AFM.
void can_filter_single_ext_rtr | ( | uint32_t | canport, |
uint32_t | id, | ||
uint32_t | id_mask | ||
) |
CAN Filter Single Extended Frame w/RTR set Notes:
[in] | canport | Unsigned int32. CAN block register base address. |
[in] | id | Unsigned int32. CAN ID. Only bits 28:0 are used. |
[in] | id_mask | Unsigned int32. CAN ID mask. Only bits 28:0 are used. |
Definition at line 252 of file can.c.
References CAN_ACR, CAN_ACR_SINGLE_EXT_ID, CAN_ACR_SINGLE_EXT_RTR, CAN_AMR, CAN_ISR_SR_CMR_MR_SET, and CAN_MR_AFM.
void can_filter_single_std | ( | uint32_t | canport, |
uint32_t | id, | ||
uint32_t | id_mask, | ||
uint8_t | db1, | ||
uint8_t | db1_mask, | ||
uint8_t | db2, | ||
uint8_t | db2_mask | ||
) |
CAN Filter Single Standard Frame Notes:
[in] | canport | Unsigned int32. CAN block register base address. |
[in] | id | Unsigned int32. CAN ID. Only bits 10:0 are used. |
[in] | id_mask | Unsigned int32. CAN ID mask. Only bits 10:0 are used. |
[in] | db1 | bool. CAN first data byte value. |
[in] | db1_mask | bool. CAN first data byte mask. |
[in] | db2 | bool. CAN second data byte value. |
[in] | db2_mask | bool. CAN second data byte mask. |
Definition at line 160 of file can.c.
References CAN_ACR, CAN_ACR_DUAL_DB_UPPER, CAN_ACR_SINGLE_STD_DB1, CAN_ACR_SINGLE_STD_DB2, CAN_ACR_SINGLE_STD_ID, CAN_ACR_SINGLE_STD_RTR, CAN_AMR, CAN_ISR_SR_CMR_MR_SET, and CAN_MR_AFM.
void can_filter_single_std_rtr | ( | uint32_t | canport, |
uint32_t | id, | ||
uint32_t | id_mask, | ||
uint8_t | db1, | ||
uint8_t | db1_mask, | ||
uint8_t | db2, | ||
uint8_t | db2_mask | ||
) |
CAN Filter Single Standard Frame w/RTR set Notes:
[in] | canport | Unsigned int32. CAN block register base address. |
[in] | id | Unsigned int32. CAN ID. Only bits 10:0 are used. |
[in] | id_mask | Unsigned int32. CAN ID mask. Only bits 10:0 are used. |
[in] | db1 | bool. CAN first data byte value. |
[in] | db1_mask | bool. CAN first data byte mask. |
[in] | db2 | bool. CAN second data byte value. |
[in] | db2_mask | bool. CAN second data byte mask. |
Definition at line 196 of file can.c.
References CAN_ACR, CAN_ACR_SINGLE_STD_DB1, CAN_ACR_SINGLE_STD_DB2, CAN_ACR_SINGLE_STD_ID, CAN_ACR_SINGLE_STD_RTR, CAN_AMR, CAN_ISR_SR_CMR_MR_SET, and CAN_MR_AFM.
void can_init | ( | uint32_t | canport, |
bool | listen_only, | ||
uint32_t | sjw, | ||
uint32_t | tseg1, | ||
uint32_t | tseg2, | ||
bool | sam3, | ||
uint32_t | brp | ||
) |
CAN Init Initialize the selected CAN peripheral block.
[in] | canport | Unsigned int32. CAN block register base address. |
[in] | listen_only | bool. Enable listen only mode. |
[in] | sjw | Unsigned int32. Resynchronization time quanta jump width. |
[in] | tseg1 | Unsigned int32. Time segment 1 time quanta width. |
[in] | tseg2 | Unsigned int32. Time segment 2 time quanta width. |
[in] | sam3 | bool. Use best 2 out of 3 samples. |
[in] | brp | Unsigned int32. Baud rate prescaler. |
Definition at line 65 of file can.c.
References CAN_ACR, CAN_AMR, CAN_BTR0_BRP, CAN_BTR0_SJW, CAN_BTR1_BTR0_RMC_IMR, CAN_BTR1_SAM, CAN_BTR1_TSEG1, CAN_BTR1_TSEG2, CAN_ISR_SR_CMR_MR, CAN_ISR_SR_CMR_MR_SET, CAN_MR_AFM, CAN_MR_LOM, and CAN_MR_RM.
void can_receive | ( | uint32_t | canport, |
uint32_t * | id, | ||
bool * | ext, | ||
bool * | rtr, | ||
uint8_t * | length, | ||
uint8_t * | data | ||
) |
CAN Receive Message If no data is in the RX buffer, id and length are set to 0.
[in] | canport | Unsigned int32. CAN block register base address. |
[out] | id | Unsigned int32 pointer. Message ID. |
[out] | ext | bool pointer. The message ID is extended. |
[out] | rtr | bool pointer. Remote Request bit value. |
[out] | length | Unsigned int8 pointer. Length of message payload. |
[out] | data | Unsigned int8[]. Message payload data, min length 8. |
Definition at line 384 of file can.c.
References BIT6, BIT7, CAN_BITS_15_8, CAN_BITS_23_16, CAN_BITS_23_21, CAN_BITS_31_24, CAN_BITS_3_0, CAN_BITS_7_3, CAN_ISR_ACKNOWLEDGE, CAN_ISR_RI, CAN_ISR_SR_CMR_MR, CAN_RMC, and CAN_RXBUF.
bool can_transmit_ext | ( | uint32_t | canport, |
uint32_t | id, | ||
bool | rtr, | ||
uint8_t | length, | ||
const uint8_t * | data | ||
) |
CAN Transmit Extended Frame.
[in] | canport | Unsigned int32. CAN block register base address. |
[in] | id | Unsigned int32. Message ID bits 28:0 used. |
[in] | rtr | bool. Remote Request bit value. |
[in] | length | Unsigned int8. Message payload length, 0-8. |
[in] | data | Unsigned int8[]. Message payload data. |
Definition at line 330 of file can.c.
References BIT6, BIT7, CAN_BITS_12_5, CAN_BITS_20_13, CAN_BITS_28_21, CAN_BITS_3_0, CAN_BITS_4_0, CAN_CMR_TR, CAN_ISR_SR_CMR_MR, CAN_ISR_SR_CMR_MR_SET, CAN_SR_TBS, and CAN_TXBUF.
bool can_transmit_std | ( | uint32_t | canport, |
uint32_t | id, | ||
bool | rtr, | ||
uint8_t | length, | ||
const uint8_t * | data | ||
) |
CAN Transmit Standard Frame.
[in] | canport | Unsigned int32. CAN block register base address. |
[in] | id | Unsigned int32. Message ID bits 10:0 used. |
[in] | rtr | bool. Remote Request bit value. |
[in] | length | Unsigned int8. Message payload length. |
[in] | data | Unsigned int8[]. Message payload data. |
Definition at line 292 of file can.c.
References BIT6, CAN_BITS_10_3, CAN_BITS_2_0, CAN_BITS_3_0, CAN_CMR_TR, CAN_ISR_SR_CMR_MR, CAN_ISR_SR_CMR_MR_SET, CAN_SR_TBS, and CAN_TXBUF.