|
modm API documentation
|
#include <modm/platform/can/can_2.hpp>
Public Types | |
| enum | Mode : uint32_t { Normal = 0, ListenOnly = CAN_BTR_SILM, LoopBack = CAN_BTR_LBKM, ListenOnlyLoopBack = CAN_BTR_SILM | CAN_BTR_LBKM } |
| enum | BusState : uint8_t { BusState::Connected = 0, BusState::ErrorWarning = 1, BusState::ErrorPassive = 2, Off = 3 } |
Static Public Member Functions | |
| template<class... Signals> | |
| static void | connect (Gpio::InputType inputType=Gpio::InputType::Floating) |
| template<class SystemClock , bitrate_t bitrate = kbps(125), percent_t tolerance = pct(1)> | |
| static bool | initialize (uint32_t interruptPriority, Mode startupMode=Mode::Normal, bool overwriteOnOverrun=true) |
| static void | setMode (Mode mode) |
| static void | setAutomaticRetransmission (bool retransmission) |
| static bool | isMessageAvailable () |
| static bool | getMessage (can::Message &message, uint8_t *filter_id=nullptr) |
| static bool | isReadyToSend () |
| static bool | sendMessage (const can::Message &message) |
| static uint8_t | getReceiveErrorCounter () |
| static uint8_t | getTransmitErrorCounter () |
| static BusState | getBusState () |
| static void | enableStatusChangeInterrupt (uint32_t interruptEnable, uint32_t interruptPriority) |
| static void | acknowledgeInterruptFlag () |
| template<uint64_t available, uint64_t requested, percent_t tolerance> | |
| static void | assertBaudrateInTolerance () |
| template<double available, double requested, percent_t tolerance> | |
| static void | assertDurationInTolerance () |
| static void | configurePurpose () |
| configures a peripheral for a specific purpose | |
| template<class... Signals> | |
| static void | connect () |
| static bool | getInterruptFlag () |
| Read an interrupt flag. | |
| static bool | getMessage (can::Message &message) |
| Returns true if a message was copied into the message buffer. | |
| static void | getParameter () |
| returns a parameter | |
| template<class SystemClock , bitrate_t bitrate = 125_kbps, percent_t tolerance = 1_pct> | |
| static void | initialize (Mode startupMode) |
| static void | initialize () |
| initializes the peripheral, must be called before use. | |
| static void | setParameter () |
| sets a parameter | |
Static Public Attributes | |
| static constexpr size_t | RxBufferSize = 32 |
| static constexpr size_t | TxBufferSize = 32 |
Basic Extended CAN2.
The Basic Extended CAN peripheral, named bxCAN, interfaces the CAN network. It supports the CAN protocols version 2.0A and B. It has been designed to manage a high number of incoming messages efficiently with a minimum CPU load.
For connectivity line devices there are 28 filter banks, i=0 .. 27, in other devices there are 14 filter banks i = 0 ..13.
The 28 filter banks for the connectivity line devices are shared between CAN1 and CAN2.
You can set the buffer size using the tx_buffer and rx_buffer parameters.
|
inheritedstrong |
|
inheritedstatic |
Acknowledge an interrupt flag.
We use acknowledge here, since it describes the intention rather than the actual implementation.
|
inheritedinlinestatic |
Since baudrates are usually generated by prescaling a system clock, only several distinct values can be generated. This method checks if the user requested baudrate is within error tolerance of the system achievable baudrate.
|
inheritedstatic |
Configures the Tx and Rx signals and connects them.
| Signals | One Tx and one Rx signal are required and can be passed out-of-order. |
|
static |
Enable the error and status change interrupt.
Can be generated by the following events:
You need to create you own interrupt handler for this interrupt. The interrupt handler has a fixed name:
| interruptEnable | Upper 24-bit of the CAN_IER register. E.g.:
|
| interruptPriority | Interrupt vector priority (0=highest to 15=lowest) |
|
inlinestatic |
Get Receive Error Counter.
In case of an error during reception, this counter is incremented by 1 or by 8 depending on the error condition as defined by the CAN standard. After every successful reception the counter is decremented by 1 or reset to 120 if its value was higher than 128. When the counter value exceeds 127, the CAN controller enters the error passive state.
|
inlinestatic |
Get Transmit Error Counter.
|
inheritedstatic |
Initializes the hardware and sets the baudrate.
| SystemClock | the currently active system clock |
| bitrate | the desired bitrate in Hz |
| tolerance | the allowed relative tolerance for the resulting baudrate |
|
nodiscardinlinestatic |
Enables the clock for the CAN controller and resets all settings
| bitrate | CAN bitrate (defined in driver/connectivity/can/message.hpp) |
| interruptPriority | Interrupt vector priority (0=highest to 15=lowest) |
| overwriteOnOverrun | Once a receive FIFO is full the next incoming message will overwrite the previous one if true otherwise the incoming message will be discarded |
|
static |
The the operating mode.
Default after initialization is the normal mode.