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

#include <CAN.h>

Inheritance diagram for PX4::PX4CAN:
[legend]
Collaboration diagram for PX4::PX4CAN:
[legend]

Classes

struct  Timings
 
struct  TxItem
 

Public Types

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

Public Member Functions

 PX4CAN (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

◆ PX4CAN()

PX4::PX4CAN::PX4CAN ( 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 PX4::PX4CAN::available ( )
override

◆ begin()

bool PX4::PX4CAN::begin ( uint32_t  bitrate)
override

◆ canAcceptNewTxFrame()

bool PX4::PX4CAN::canAcceptNewTxFrame ( const uavcan::CanFrame &  frame) const

◆ computeTimings()

int PX4::PX4CAN::computeTimings ( uint32_t  target_bitrate,
Timings out_timings 
)
private

◆ configureFilters()

virtual int16_t PX4::PX4CAN::configureFilters ( const uavcan::CanFilterConfig *  filter_configs,
uint16_t  num_configs 
)
overrideprivatevirtual

◆ discardTimedOutTxMailboxes()

void PX4::PX4CAN::discardTimedOutTxMailboxes ( uavcan::MonotonicTime  current_time)

◆ end()

void PX4::PX4CAN::end ( )
inlineoverride

Definition at line 246 of file CAN.h.

Here is the call graph for this function:

◆ getErrorCount()

virtual uint64_t PX4::PX4CAN::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 PX4::PX4CAN::getNumFilters ( ) const
inlineoverrideprivatevirtual

Definition at line 149 of file CAN.h.

◆ getPeakNumTxMailboxesUsed()

uint8_t PX4::PX4CAN::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 PX4::PX4CAN::getRxQueueLength ( ) const

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

◆ getVoluntaryTxAbortCount()

uint32_t PX4::PX4CAN::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 PX4::PX4CAN::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 PX4::PX4CAN::handleRxInterrupt ( uint8_t  fifo_index,
uint64_t  utc_usec 
)

◆ handleTxInterrupt()

void PX4::PX4CAN::handleTxInterrupt ( uint64_t  utc_usec)

◆ handleTxMailboxInterrupt()

void PX4::PX4CAN::handleTxMailboxInterrupt ( uint8_t  mailbox_index,
bool  txok,
uint64_t  utc_usec 
)
private

◆ init()

int PX4::PX4CAN::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 PX4::PX4CAN::is_initialized ( )
override

◆ isRxBufferEmpty()

bool PX4::PX4CAN::isRxBufferEmpty ( ) const

◆ pollErrorFlagsFromISR()

void PX4::PX4CAN::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 PX4::PX4CAN::receive ( uavcan::CanFrame &  out_frame,
uavcan::MonotonicTime &  out_ts_monotonic,
uavcan::UtcTime &  out_ts_utc,
uavcan::CanIOFlags &  out_flags 
)
overrideprivatevirtual

◆ reset()

void PX4::PX4CAN::reset ( )
override

◆ send()

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

◆ set_update_event()

void PX4::PX4CAN::set_update_event ( BusEvent update_event)
inline

Definition at line 185 of file CAN.h.

◆ tx_pending()

int32_t PX4::PX4CAN::tx_pending ( )
override

◆ waitMsrINakBitStateChange()

bool PX4::PX4CAN::waitMsrINakBitStateChange ( bool  target_state)
private

Member Data Documentation

◆ bitrate_

uint32_t PX4::PX4CAN::bitrate_
private

Definition at line 137 of file CAN.h.

◆ can_

bxcan::CanType* const PX4::PX4CAN::can_
private

Definition at line 127 of file CAN.h.

◆ error_cnt_

uint64_t PX4::PX4CAN::error_cnt_
private

Definition at line 128 of file CAN.h.

◆ had_activity_

bool PX4::PX4CAN::had_activity_
private

Definition at line 135 of file CAN.h.

◆ initialized_

bool PX4::PX4CAN::initialized_
private

Definition at line 158 of file CAN.h.

◆ peak_tx_mailbox_index_

uint8_t PX4::PX4CAN::peak_tx_mailbox_index_
private

Definition at line 132 of file CAN.h.

◆ pending_tx_

TxItem PX4::PX4CAN::pending_tx_[NumTxMailboxes]
private

Definition at line 131 of file CAN.h.

◆ rx_queue_

ObjectBuffer<CanRxItem> PX4::PX4CAN::rx_queue_
private

Definition at line 126 of file CAN.h.

◆ self_index_

const uint8_t PX4::PX4CAN::self_index_
private

Definition at line 133 of file CAN.h.

◆ served_aborts_cnt_

uint32_t PX4::PX4CAN::served_aborts_cnt_
private

Definition at line 129 of file CAN.h.

◆ TSR_ABRQx

const uint32_t PX4::PX4CAN::TSR_ABRQx[NumTxMailboxes]
staticprivate

Definition at line 124 of file CAN.h.

◆ update_event_

BusEvent* PX4::PX4CAN::update_event_
private

Definition at line 130 of file CAN.h.


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