APM:Libraries
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
VRBRAIN::VRBRAINCAN Class Reference

#include <CAN.h>

Inheritance diagram for VRBRAIN::VRBRAINCAN:
[legend]
Collaboration diagram for VRBRAIN::VRBRAINCAN:
[legend]

Classes

struct  Timings
 
struct  TxItem
 

Public Types

enum  { MaxRxQueueCapacity = 254 }
 
enum  OperatingMode { NormalMode, SilentMode }
 

Public Member Functions

 VRBRAINCAN (bxcan::CanType *can, BusEvent *update_event, uint8_t self_index, uint8_t rx_queue_capacity)
 
int init (const uint32_t bitrate, const OperatingMode mode)
 
void set_update_event (BusEvent *update_event)
 
void handleTxInterrupt (uint64_t utc_usec)
 
void handleRxInterrupt (uint8_t fifo_index, uint64_t utc_usec)
 
void pollErrorFlagsFromISR ()
 
void discardTimedOutTxMailboxes (uavcan::MonotonicTime current_time)
 
bool canAcceptNewTxFrame (const uavcan::CanFrame &frame) const
 
bool isRxBufferEmpty () const
 
virtual uint64_t getErrorCount () const override
 
uint32_t getVoluntaryTxAbortCount () const
 
unsigned getRxQueueLength () const
 
bool hadActivity ()
 
uint8_t getPeakNumTxMailboxesUsed () const
 
bool begin (uint32_t bitrate) override
 
void end () override
 
void reset () override
 
int32_t tx_pending () override
 
int32_t available () override
 
bool is_initialized () override
 

Private Types

enum  { NumTxMailboxes = 3 }
 
enum  { NumFilters = 14 }
 

Private Member Functions

int computeTimings (uint32_t target_bitrate, Timings &out_timings)
 
virtual int16_t send (const uavcan::CanFrame &frame, uavcan::MonotonicTime tx_deadline, uavcan::CanIOFlags flags) override
 
virtual int16_t receive (uavcan::CanFrame &out_frame, uavcan::MonotonicTime &out_ts_monotonic, uavcan::UtcTime &out_ts_utc, uavcan::CanIOFlags &out_flags) override
 
virtual int16_t configureFilters (const uavcan::CanFilterConfig *filter_configs, uint16_t num_configs) override
 
virtual uint16_t getNumFilters () const override
 
void handleTxMailboxInterrupt (uint8_t mailbox_index, bool txok, uint64_t utc_usec)
 
bool waitMsrINakBitStateChange (bool target_state)
 

Private Attributes

ObjectBuffer< CanRxItemrx_queue_
 
bxcan::CanType *const can_
 
uint64_t error_cnt_
 
uint32_t served_aborts_cnt_
 
BusEventupdate_event_
 
TxItem pending_tx_ [NumTxMailboxes]
 
uint8_t peak_tx_mailbox_index_
 
const uint8_t self_index_
 
bool had_activity_
 
uint32_t bitrate_
 
bool initialized_
 

Static Private Attributes

static const uint32_t TSR_ABRQx [NumTxMailboxes]
 

Detailed Description

Definition at line 88 of file CAN.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
NumTxMailboxes 

Definition at line 117 of file CAN.h.

◆ anonymous enum

anonymous enum
private
Enumerator
NumFilters 

Definition at line 120 of file CAN.h.

◆ anonymous enum

anonymous enum
Enumerator
MaxRxQueueCapacity 

Definition at line 160 of file CAN.h.

◆ OperatingMode

Enumerator
NormalMode 
SilentMode 

Definition at line 164 of file CAN.h.

Constructor & Destructor Documentation

◆ VRBRAINCAN()

VRBRAIN::VRBRAINCAN::VRBRAINCAN ( bxcan::CanType can,
BusEvent update_event,
uint8_t  self_index,
uint8_t  rx_queue_capacity 
)
inline

Definition at line 168 of file CAN.h.

Here is the call graph for this function:

Member Function Documentation

◆ available()

int32_t VRBRAIN::VRBRAINCAN::available ( )
override

◆ begin()

bool VRBRAIN::VRBRAINCAN::begin ( uint32_t  bitrate)
override

◆ canAcceptNewTxFrame()

bool VRBRAIN::VRBRAINCAN::canAcceptNewTxFrame ( const uavcan::CanFrame &  frame) const

◆ computeTimings()

int VRBRAIN::VRBRAINCAN::computeTimings ( uint32_t  target_bitrate,
Timings out_timings 
)
private

◆ configureFilters()

virtual int16_t VRBRAIN::VRBRAINCAN::configureFilters ( const uavcan::CanFilterConfig *  filter_configs,
uint16_t  num_configs 
)
overrideprivatevirtual

◆ discardTimedOutTxMailboxes()

void VRBRAIN::VRBRAINCAN::discardTimedOutTxMailboxes ( uavcan::MonotonicTime  current_time)

◆ end()

void VRBRAIN::VRBRAINCAN::end ( )
inlineoverride

Definition at line 246 of file CAN.h.

Here is the call graph for this function:

◆ getErrorCount()

virtual uint64_t VRBRAIN::VRBRAINCAN::getErrorCount ( ) const
overridevirtual

Total number of hardware failures and other kinds of errors (e.g. queue overruns). May increase continuously if the interface is not connected to the bus.

◆ getNumFilters()

virtual uint16_t VRBRAIN::VRBRAINCAN::getNumFilters ( ) const
inlineoverrideprivatevirtual

Definition at line 149 of file CAN.h.

◆ getPeakNumTxMailboxesUsed()

uint8_t VRBRAIN::VRBRAINCAN::getPeakNumTxMailboxesUsed ( ) const
inline

Peak number of TX mailboxes used concurrently since initialization. Range is [1, 3]. Value of 3 suggests that priority inversion could be taking place.

Definition at line 240 of file CAN.h.

◆ getRxQueueLength()

unsigned VRBRAIN::VRBRAINCAN::getRxQueueLength ( ) const

Returns the number of frames pending in the RX queue. This is intended for debug use only.

◆ getVoluntaryTxAbortCount()

uint32_t VRBRAIN::VRBRAINCAN::getVoluntaryTxAbortCount ( ) const
inline

Number of times the driver exercised library's requirement to abort transmission on first error. This is an atomic read, it doesn't require a critical section. See uavcan::CanIOFlagAbortOnError.

Definition at line 218 of file CAN.h.

◆ hadActivity()

bool VRBRAIN::VRBRAINCAN::hadActivity ( )

Whether this iface had at least one successful IO since the previous call of this method. This is designed for use with iface activity LEDs.

◆ handleRxInterrupt()

void VRBRAIN::VRBRAINCAN::handleRxInterrupt ( uint8_t  fifo_index,
uint64_t  utc_usec 
)

◆ handleTxInterrupt()

void VRBRAIN::VRBRAINCAN::handleTxInterrupt ( uint64_t  utc_usec)

◆ handleTxMailboxInterrupt()

void VRBRAIN::VRBRAINCAN::handleTxMailboxInterrupt ( uint8_t  mailbox_index,
bool  txok,
uint64_t  utc_usec 
)
private

◆ init()

int VRBRAIN::VRBRAINCAN::init ( const uint32_t  bitrate,
const OperatingMode  mode 
)

Initializes the hardware CAN controller. Assumes:

  • Iface clock is enabled
  • Iface has been resetted via RCC
  • Caller will configure NVIC by itself

◆ is_initialized()

bool VRBRAIN::VRBRAINCAN::is_initialized ( )
override

◆ isRxBufferEmpty()

bool VRBRAIN::VRBRAINCAN::isRxBufferEmpty ( ) const

◆ pollErrorFlagsFromISR()

void VRBRAIN::VRBRAINCAN::pollErrorFlagsFromISR ( )

This method is used to count errors and abort transmission on error if necessary. This functionality used to be implemented in the SCE interrupt handler, but that approach was generating too much processing overhead, especially on disconnected interfaces.

Should be called from RX ISR, TX ISR, and select(); interrupts must be enabled.

◆ receive()

virtual int16_t VRBRAIN::VRBRAINCAN::receive ( uavcan::CanFrame &  out_frame,
uavcan::MonotonicTime &  out_ts_monotonic,
uavcan::UtcTime &  out_ts_utc,
uavcan::CanIOFlags &  out_flags 
)
overrideprivatevirtual

◆ reset()

void VRBRAIN::VRBRAINCAN::reset ( )
override

◆ send()

virtual int16_t VRBRAIN::VRBRAINCAN::send ( const uavcan::CanFrame &  frame,
uavcan::MonotonicTime  tx_deadline,
uavcan::CanIOFlags  flags 
)
overrideprivatevirtual

◆ set_update_event()

void VRBRAIN::VRBRAINCAN::set_update_event ( BusEvent update_event)
inline

Definition at line 185 of file CAN.h.

◆ tx_pending()

int32_t VRBRAIN::VRBRAINCAN::tx_pending ( )
override

◆ waitMsrINakBitStateChange()

bool VRBRAIN::VRBRAINCAN::waitMsrINakBitStateChange ( bool  target_state)
private

Member Data Documentation

◆ bitrate_

uint32_t VRBRAIN::VRBRAINCAN::bitrate_
private

Definition at line 137 of file CAN.h.

◆ can_

bxcan::CanType* const VRBRAIN::VRBRAINCAN::can_
private

Definition at line 127 of file CAN.h.

◆ error_cnt_

uint64_t VRBRAIN::VRBRAINCAN::error_cnt_
private

Definition at line 128 of file CAN.h.

◆ had_activity_

bool VRBRAIN::VRBRAINCAN::had_activity_
private

Definition at line 135 of file CAN.h.

◆ initialized_

bool VRBRAIN::VRBRAINCAN::initialized_
private

Definition at line 158 of file CAN.h.

◆ peak_tx_mailbox_index_

uint8_t VRBRAIN::VRBRAINCAN::peak_tx_mailbox_index_
private

Definition at line 132 of file CAN.h.

◆ pending_tx_

TxItem VRBRAIN::VRBRAINCAN::pending_tx_[NumTxMailboxes]
private

Definition at line 131 of file CAN.h.

◆ rx_queue_

ObjectBuffer<CanRxItem> VRBRAIN::VRBRAINCAN::rx_queue_
private

Definition at line 126 of file CAN.h.

◆ self_index_

const uint8_t VRBRAIN::VRBRAINCAN::self_index_
private

Definition at line 133 of file CAN.h.

◆ served_aborts_cnt_

uint32_t VRBRAIN::VRBRAINCAN::served_aborts_cnt_
private

Definition at line 129 of file CAN.h.

◆ TSR_ABRQx

const uint32_t VRBRAIN::VRBRAINCAN::TSR_ABRQx[NumTxMailboxes]
staticprivate

Definition at line 124 of file CAN.h.

◆ update_event_

BusEvent* VRBRAIN::VRBRAINCAN::update_event_
private

Definition at line 130 of file CAN.h.


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