#include "canard_stm32.h"
#include "_internal_bxcan.h"
#include <unistd.h>
Go to the source code of this file.
◆ BXCAN
◆ canardSTM32ConfigureAcceptanceFilters()
Sets up acceptance filters according to the provided list of ID and masks. Note that when the interface is reinitialized, hardware acceptance filters are reset. Also note that during filter reconfiguration, some RX frames may be lost.
Setting zero filters will result in rejection of all frames. In order to accept all frames, set one filter with ID = Mask = 0, which is also the default configuration.
- Return values
-
Definition at line 449 of file canard_stm32.c.
◆ canardSTM32GetStats()
Returns the running interface statistics.
Definition at line 565 of file canard_stm32.c.
◆ canardSTM32Init()
Initializes the CAN controller at the specified bit rate. The mode can be either normal, silent, or auto-abort on error; in silent mode the controller will be only listening, not affecting the state of the bus; in the auto abort mode the controller will cancel the pending transmissions if a bus error is encountered. The auto abort mode is needed for dynamic node ID allocation procedure; please refer to the UAVCAN specification for more information about this topic.
This function can be invoked any number of times; every invocation re-initializes everything from scratch.
WARNING: The clock of the CAN module must be enabled before this function is invoked! If CAN2 is used, CAN1 must be also enabled!
WARNING: The driver is not thread-safe! It does not use IRQ or critical sections though, so it is safe to invoke its API functions from the IRQ context from the application.
- Return values
-
Definition at line 168 of file canard_stm32.c.
◆ canardSTM32Receive()
int16_t canardSTM32Receive |
( |
CanardCANFrame *const |
out_frame | ) |
|
Reads one frame from the hardware RX FIFO, unless all FIFO are empty. This function does never block.
- Return values
-
1 | Read successfully |
0 | The buffer is empty |
negative | Error |
Definition at line 387 of file canard_stm32.c.
◆ canardSTM32Transmit()
int16_t canardSTM32Transmit |
( |
const CanardCANFrame *const |
frame | ) |
|
Pushes one frame into the TX buffer, if there is space. Note that proper care is taken to ensure that no inner priority inversion is taking place. This function does never block.
- Return values
-
1 | Transmitted successfully |
0 | No space in the buffer |
negative | Error |
Definition at line 281 of file canard_stm32.c.
◆ convertFrameIDCanardToRegister()
static uint32_t convertFrameIDCanardToRegister |
( |
const uint32_t |
id | ) |
|
|
static |
Converts libcanard ID value into the bxCAN TX ID register format.
Definition at line 69 of file canard_stm32.c.
◆ convertFrameIDRegisterToCanard()
static uint32_t convertFrameIDRegisterToCanard |
( |
const uint32_t |
id | ) |
|
|
static |
Converts bxCAN TX/RX (sic! both RX/TX are supported) ID register value into the libcanard ID format.
Definition at line 91 of file canard_stm32.c.
◆ isFramePriorityHigher()
static bool isFramePriorityHigher |
( |
uint32_t |
a, |
|
|
uint32_t |
b |
|
) |
| |
|
static |
◆ processErrorStatus()
static void processErrorStatus |
( |
void |
| ) |
|
|
static |
◆ waitMSRINAKBitStateChange()
static bool waitMSRINAKBitStateChange |
( |
volatile const CanardSTM32CANType *const |
bxcan, |
|
|
const bool |
target_state |
|
) |
| |
|
static |
A properly functioning bus will exhibit 11 consecutive recessive bits at the end of every correct transmission, or while the bus is idle. The 11 consecutive recessive bits are made up of: 1 bit - acknowledgement delimiter 7 bit - end of frame bits 3 bit - inter frame space This adds up to 11; therefore, it is not really necessary to wait longer than a few frame TX intervals.
Definition at line 118 of file canard_stm32.c.
◆ g_abort_tx_on_error
bool g_abort_tx_on_error = false |
|
static |
◆ g_stats