Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
uavcan_stm32::CanIface Class Reference

#include <can.hpp>

Inheritance diagram for uavcan_stm32::CanIface:
Inheritance graph
[legend]

Classes

class  RxQueue
 
struct  Timings
 
struct  TxItem
 

Public Types

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

Public Member Functions

bool canAcceptNewTxFrame (const uavcan::CanFrame &frame) const
 
 CanIface (bxcan::CanType *can, BusEvent &update_event, uavcan::uint8_t self_index, CanRxItem *rx_queue_buffer, uavcan::uint8_t rx_queue_capacity)
 
void discardTimedOutTxMailboxes (uavcan::MonotonicTime current_time)
 
virtual uavcan::uint64_t getErrorCount () const
 
uavcan::uint8_t getPeakNumTxMailboxesUsed () const
 
unsigned getRxQueueLength () const
 
uavcan::uint32_t getRxQueueOverflowCount () const
 
uavcan::uint32_t getVoluntaryTxAbortCount () const
 
bool hadActivity ()
 
void handleRxInterrupt (uavcan::uint8_t fifo_index, uavcan::uint64_t utc_usec)
 
void handleTxInterrupt (uavcan::uint64_t utc_usec)
 
int init (const uavcan::uint32_t bitrate, const OperatingMode mode)
 
bool isRxBufferEmpty () const
 
void pollErrorFlagsFromISR ()
 
- Public Member Functions inherited from uavcan::ICanIface
virtual int16_t receive (CanFrame &out_frame, MonotonicTime &out_ts_monotonic, UtcTime &out_ts_utc, CanIOFlags &out_flags)=0
 
virtual int16_t send (const CanFrame &frame, MonotonicTime tx_deadline, CanIOFlags flags)=0
 
virtual ~ICanIface ()
 

Private Types

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

Private Member Functions

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

Private Attributes

bxcan::CanType *const can_
 
uavcan::uint64_t error_cnt_
 
bool had_activity_
 
uavcan::uint8_t peak_tx_mailbox_index_
 
TxItem pending_tx_ [NumTxMailboxes]
 
RxQueue rx_queue_
 
const uavcan::uint8_t self_index_
 
uavcan::uint32_t served_aborts_cnt_
 
BusEvent & update_event_
 

Static Private Attributes

static const uavcan::uint32_t TSR_ABRQx [NumTxMailboxes]
 

Detailed Description

Single CAN iface. The application shall not use this directly.

Definition at line 47 of file platform_specific_components/stm32/libuavcan/driver/include/uavcan_stm32/can.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
NumTxMailboxes 

Definition at line 110 of file platform_specific_components/stm32/libuavcan/driver/include/uavcan_stm32/can.hpp.

◆ anonymous enum

anonymous enum
private

◆ anonymous enum

anonymous enum
Enumerator
MaxRxQueueCapacity 

Definition at line 143 of file platform_specific_components/stm32/libuavcan/driver/include/uavcan_stm32/can.hpp.

◆ OperatingMode

Enumerator
NormalMode 
SilentMode 

Definition at line 145 of file platform_specific_components/stm32/libuavcan/driver/include/uavcan_stm32/can.hpp.

Constructor & Destructor Documentation

◆ CanIface()

uavcan_stm32::CanIface::CanIface ( bxcan::CanType can,
BusEvent &  update_event,
uavcan::uint8_t  self_index,
CanRxItem rx_queue_buffer,
uavcan::uint8_t  rx_queue_capacity 
)
inline

Member Function Documentation

◆ canAcceptNewTxFrame()

bool uavcan_stm32::CanIface::canAcceptNewTxFrame ( const uavcan::CanFrame frame) const

Definition at line 818 of file uc_stm32_can.cpp.

◆ computeTimings()

int uavcan_stm32::CanIface::computeTimings ( uavcan::uint32_t  target_bitrate,
Timings out_timings 
)
private

Definition at line 195 of file uc_stm32_can.cpp.

◆ configureFilters()

uavcan::int16_t uavcan_stm32::CanIface::configureFilters ( const uavcan::CanFilterConfig filter_configs,
uavcan::uint16_t  num_configs 
)
privatevirtual

Configure the hardware CAN filters. CanFilterConfig.

Returns
0 = success, negative for error.

Implements uavcan::ICanIface.

Definition at line 452 of file uc_stm32_can.cpp.

◆ discardTimedOutTxMailboxes()

void uavcan_stm32::CanIface::discardTimedOutTxMailboxes ( uavcan::MonotonicTime  current_time)

Definition at line 803 of file uc_stm32_can.cpp.

◆ getErrorCount()

uavcan::uint64_t uavcan_stm32::CanIface::getErrorCount ( ) const
virtual

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.

Implements uavcan::ICanIface.

Definition at line 862 of file uc_stm32_can.cpp.

◆ getNumFilters()

virtual uavcan::uint16_t uavcan_stm32::CanIface::getNumFilters ( ) const
inlineprivatevirtual

Number of available hardware filters.

Implements uavcan::ICanIface.

Definition at line 136 of file platform_specific_components/stm32/libuavcan/driver/include/uavcan_stm32/can.hpp.

◆ getPeakNumTxMailboxesUsed()

uavcan::uint8_t uavcan_stm32::CanIface::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 227 of file platform_specific_components/stm32/libuavcan/driver/include/uavcan_stm32/can.hpp.

◆ getRxQueueLength()

unsigned uavcan_stm32::CanIface::getRxQueueLength ( ) const

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

Definition at line 868 of file uc_stm32_can.cpp.

◆ getRxQueueOverflowCount()

uavcan::uint32_t uavcan_stm32::CanIface::getRxQueueOverflowCount ( ) const
inline

Number of RX frames lost due to queue overflow. This is an atomic read, it doesn't require a critical section.

Definition at line 195 of file platform_specific_components/stm32/libuavcan/driver/include/uavcan_stm32/can.hpp.

◆ getVoluntaryTxAbortCount()

uavcan::uint32_t uavcan_stm32::CanIface::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 208 of file platform_specific_components/stm32/libuavcan/driver/include/uavcan_stm32/can.hpp.

◆ hadActivity()

bool uavcan_stm32::CanIface::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.

Definition at line 874 of file uc_stm32_can.cpp.

◆ handleRxInterrupt()

void uavcan_stm32::CanIface::handleRxInterrupt ( uavcan::uint8_t  fifo_index,
uavcan::uint64_t  utc_usec 
)

Definition at line 714 of file uc_stm32_can.cpp.

◆ handleTxInterrupt()

void uavcan_stm32::CanIface::handleTxInterrupt ( uavcan::uint64_t  utc_usec)

Definition at line 684 of file uc_stm32_can.cpp.

◆ handleTxMailboxInterrupt()

void uavcan_stm32::CanIface::handleTxMailboxInterrupt ( uavcan::uint8_t  mailbox_index,
bool  txok,
uavcan::uint64_t  utc_usec 
)
private

Definition at line 668 of file uc_stm32_can.cpp.

◆ init()

int uavcan_stm32::CanIface::init ( const uavcan::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

Definition at line 567 of file uc_stm32_can.cpp.

◆ isRxBufferEmpty()

bool uavcan_stm32::CanIface::isRxBufferEmpty ( ) const

Definition at line 856 of file uc_stm32_can.cpp.

◆ pollErrorFlagsFromISR()

void uavcan_stm32::CanIface::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.

Definition at line 781 of file uc_stm32_can.cpp.

◆ receive()

uavcan::int16_t uavcan_stm32::CanIface::receive ( uavcan::CanFrame out_frame,
uavcan::MonotonicTime out_ts_monotonic,
uavcan::UtcTime out_ts_utc,
uavcan::CanIOFlags out_flags 
)
privatevirtual

Definition at line 435 of file uc_stm32_can.cpp.

◆ send()

uavcan::int16_t uavcan_stm32::CanIface::send ( const uavcan::CanFrame frame,
uavcan::MonotonicTime  tx_deadline,
uavcan::CanIOFlags  flags 
)
privatevirtual

Definition at line 344 of file uc_stm32_can.cpp.

◆ waitMsrINakBitStateChange()

bool uavcan_stm32::CanIface::waitMsrINakBitStateChange ( bool  target_state)
private

Definition at line 536 of file uc_stm32_can.cpp.

Member Data Documentation

◆ can_

bxcan::CanType* const uavcan_stm32::CanIface::can_
private

◆ error_cnt_

uavcan::uint64_t uavcan_stm32::CanIface::error_cnt_
private

◆ had_activity_

bool uavcan_stm32::CanIface::had_activity_
private

◆ peak_tx_mailbox_index_

uavcan::uint8_t uavcan_stm32::CanIface::peak_tx_mailbox_index_
private

◆ pending_tx_

TxItem uavcan_stm32::CanIface::pending_tx_[NumTxMailboxes]
private

◆ rx_queue_

RxQueue uavcan_stm32::CanIface::rx_queue_
private

◆ self_index_

const uavcan::uint8_t uavcan_stm32::CanIface::self_index_
private

◆ served_aborts_cnt_

uavcan::uint32_t uavcan_stm32::CanIface::served_aborts_cnt_
private

◆ TSR_ABRQx

const uavcan::uint32_t uavcan_stm32::CanIface::TSR_ABRQx
staticprivate

◆ update_event_

BusEvent& uavcan_stm32::CanIface::update_event_
private

The documentation for this class was generated from the following files:
uavcan_stm32::bxcan::TSR_ABRQ0
constexpr unsigned long TSR_ABRQ0
Definition: bxcan.hpp:118
uavcan_stm32::bxcan::TSR_ABRQ1
constexpr unsigned long TSR_ABRQ1
Definition: bxcan.hpp:123
uavcan_stm32::bxcan::TSR_ABRQ2
constexpr unsigned long TSR_ABRQ2
Definition: bxcan.hpp:128


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:05