modm API documentation

#include <modm/architecture/interface/can.hpp>

Inheritance diagram for modm::Can:
modm::PeripheralDriver modm::Mcp2515< SPI, CS, INT > modm::platform::Can1 modm::platform::Can2 modm_test::platform::CanDriver

Public Types

enum  Mode : uint8_t { Mode::Normal = 0b00, Mode::ListenOnly = 0b01, Mode::LoopBack = 0b10, Mode::ListenOnlyLoopBack = 0b11 }
 Possible modes of the CAN controller. More...
 
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 ()
 
template<class SystemClock , bitrate_t bitrate = 125_kbps, percent_t tolerance = 1_pct>
static void initialize (Mode startupMode)
 
static bool isMessageAvailable ()
 Returns true if a message can be retrieved by calling getMessage.
 
static bool getMessage (can::Message &message)
 Returns true if a message was copied into the message buffer.
 
static bool isReadyToSend ()
 
static bool sendMessage (const can::Message &message)
 
static uint8_t getReceiveErrorCounter ()
 Get Receive Error Counter.
 
static uint8_t getTransmitErrorCounter ()
 Get Transmit Error Counter.
 
static BusState getBusState ()
 
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
 
static bool getInterruptFlag ()
 Read an interrupt flag.
 
static void getParameter ()
 returns a parameter
 
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 = 16
 Size of the receive buffer.
 
static constexpr size_t TxBufferSize = 16
 Size of the transmit buffer.
 

Detailed Description

Interface to the CAN bus

Member Enumeration Documentation

enum modm::Can::BusState : uint8_t
strong
Enum ValuesDocumentation
Connected 

This bit is set by hardware when the warning limit has been reached (Receive Error Counter or Transmit Error Counter ≥ 96).

ErrorWarning 

This bit is set by hardware when the Error Passive limit has been reached (Receive Error Counter or Transmit Error Counter > 127).

ErrorPassive 

This bit is set by hardware when it enters the bus-off state. The bus-off state is entered on TEC overflow, greater than 255

enum modm::Can::Mode : uint8_t
strong

Possible modes of the CAN controller.

Enum ValuesDocumentation
Normal 

standard operation mode

ListenOnly 

only possible to receive messages

LoopBack 

messages sent are immediately received by own controller

ListenOnlyLoopBack 

combination of both modes

Member Function Documentation

static void modm::PeripheralDriver::acknowledgeInterruptFlag ( )
inheritedstatic

Acknowledge an interrupt flag.

We use acknowledge here, since it describes the intention rather than the actual implementation.

template<uint64_t available, uint64_t requested, percent_t tolerance>
static void modm::PeripheralDriver::assertBaudrateInTolerance ( )
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.

template<class... Signals>
static void modm::Can::connect ( )
static

Configures the Tx and Rx signals and connects them.

Template Parameters
SignalsOne Tx and one Rx signal are required and can be passed out-of-order.
template<class SystemClock , bitrate_t bitrate = 125_kbps, percent_t tolerance = 1_pct>
static void modm::Can::initialize ( Mode  startupMode)
static

Initializes the hardware and sets the baudrate.

Template Parameters
SystemClockthe currently active system clock
bitratethe desired bitrate in Hz
tolerancethe allowed relative tolerance for the resulting baudrate
static bool modm::Can::isReadyToSend ( )
static

The CAN controller has a free slot to send a new message.

Returns
true if a slot is available, false otherwise
static bool modm::Can::sendMessage ( const can::Message message)
static

Send a message over the CAN.

Returns
true if the message was send, false otherwise

The documentation for this class was generated from the following file: