modm API documentation
modm_test::platform::CanDriver Class Reference

#include </tmp/tmp_ggze249/attiny85v-20su/modm-test/src/modm-test/mock/can_driver.hpp>

Inheritance diagram for modm_test::platform::CanDriver:
modm::Can modm::PeripheralDriver

Public Types

enum  BusState : uint8_t { BusState::Connected = 0, BusState::ErrorWarning = 1, BusState::ErrorPassive = 2, Off = 3 }
 
enum  Mode : uint8_t { Mode::Normal = 0b00, Mode::ListenOnly = 0b01, Mode::LoopBack = 0b10, Mode::ListenOnlyLoopBack = 0b11 }
 Possible modes of the CAN controller. More...
 

Public Member Functions

bool isMessageAvailable ()
 
bool getMessage (modm::can::Message &message)
 
bool isReadyToSend ()
 
bool sendMessage (const modm::can::Message &message)
 

Static Public Member Functions

static uint8_t getReceiveErrorCounter ()
 
static uint8_t getTransmitErrorCounter ()
 
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
 
template<class... Signals>
static void connect ()
 
static bool getInterruptFlag ()
 Read an interrupt flag.
 
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
 

Public Attributes

modm::LinkedList< modm::can::MessagereceiveList
 Messages which should be received.
 
modm::LinkedList< modm::can::MessagesendList
 List of all messages send.
 
uint8_t sendSlots
 number of messages which could be send
 

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

Mock CAN peripheral interface for unittests.

Member Enumeration Documentation

enum modm::Can::BusState : uint8_t
inheritedstrong
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
inheritedstrong

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 ( )
inheritedstatic

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)
inheritedstatic

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

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