PX4 Firmware
PX4 Autopilot Software http://px4.io
uavcan_stm32::CanInitHelper< RxQueueCapacity > Class Template Reference

Helper class. More...

#include <can.hpp>

Collaboration diagram for uavcan_stm32::CanInitHelper< RxQueueCapacity >:

Public Types

enum  { BitRateAutoDetect = 0 }
 

Public Member Functions

 CanInitHelper ()
 
int init (uavcan::uint32_t bitrate)
 This overload simply configures the provided bitrate. More...
 
template<typename DelayCallable >
int init (DelayCallable delay_callable, uavcan::uint32_t &inout_bitrate=BitRateAutoDetect)
 This function can either initialize the driver at a fixed bit rate, or it can perform automatic bit rate detection. More...
 

Static Public Member Functions

static uavcan::MonotonicDuration getRecommendedListeningDelay ()
 Use this value for listening delay during automatic bit rate detection. More...
 

Public Attributes

CanDriver driver
 

Private Attributes

CanRxItem queue_storage_ [UAVCAN_STM32_NUM_IFACES][RxQueueCapacity]
 

Detailed Description

template<unsigned RxQueueCapacity = 128>
class uavcan_stm32::CanInitHelper< RxQueueCapacity >

Helper class.

Normally only this class should be used by the application. 145 usec per Extended CAN frame @ 1 Mbps, e.g. 32 RX slots * 145 usec –> 4.6 msec before RX queue overruns.

Definition at line 291 of file can.hpp.

Member Enumeration Documentation

◆ anonymous enum

template<unsigned RxQueueCapacity = 128>
anonymous enum
Enumerator
BitRateAutoDetect 

Definition at line 296 of file can.hpp.

Constructor & Destructor Documentation

◆ CanInitHelper()

template<unsigned RxQueueCapacity = 128>
uavcan_stm32::CanInitHelper< RxQueueCapacity >::CanInitHelper ( )
inline

Definition at line 300 of file can.hpp.

Member Function Documentation

◆ getRecommendedListeningDelay()

template<unsigned RxQueueCapacity = 128>
static uavcan::MonotonicDuration uavcan_stm32::CanInitHelper< RxQueueCapacity >::getRecommendedListeningDelay ( )
inlinestatic

Use this value for listening delay during automatic bit rate detection.

Definition at line 367 of file can.hpp.

◆ init() [1/2]

template<unsigned RxQueueCapacity = 128>
int uavcan_stm32::CanInitHelper< RxQueueCapacity >::init ( uavcan::uint32_t  bitrate)
inline

This overload simply configures the provided bitrate.

Auto bit rate detection will not be performed. Bitrate value must be positive.

Returns
Negative value on error; non-negative on success. Refer to constants Err*.

Definition at line 310 of file can.hpp.

References uavcan_stm32::CanDriver::init(), and uavcan_stm32::CanIface::NormalMode.

Referenced by UavcanEsc::start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init() [2/2]

template<unsigned RxQueueCapacity = 128>
template<typename DelayCallable >
int uavcan_stm32::CanInitHelper< RxQueueCapacity >::init ( DelayCallable  delay_callable,
uavcan::uint32_t &  inout_bitrate = BitRateAutoDetect 
)
inline

This function can either initialize the driver at a fixed bit rate, or it can perform automatic bit rate detection.

For theory please refer to the CiA application note #801.

Parameters
delay_callableA callable entity that suspends execution for strictly more than one second. The callable entity will be invoked without arguments. getRecommendedListeningDelay().
inout_bitrateFixed bit rate or zero. Zero invokes the bit rate detection process. If auto detection was used, the function will update the argument with established bit rate. In case of an error the value will be undefined.
Returns
Negative value on error; non-negative on success. Refer to constants Err*.

Definition at line 330 of file can.hpp.

References uavcan_stm32::ErrBitRateNotDetected, uavcan_stm32::CanDriver::getIface(), uavcan_stm32::CanDriver::getNumIfaces(), uavcan_stm32::CanDriver::init(), uavcan_stm32::CanIface::isRxBufferEmpty(), uavcan_stm32::CanIface::NormalMode, and uavcan_stm32::CanIface::SilentMode.

Here is the call graph for this function:

Member Data Documentation

◆ driver

template<unsigned RxQueueCapacity = 128>
CanDriver uavcan_stm32::CanInitHelper< RxQueueCapacity >::driver

Definition at line 298 of file can.hpp.

Referenced by UavcanEsc::start().

◆ queue_storage_

template<unsigned RxQueueCapacity = 128>
CanRxItem uavcan_stm32::CanInitHelper< RxQueueCapacity >::queue_storage_[UAVCAN_STM32_NUM_IFACES][RxQueueCapacity]
private

Definition at line 293 of file can.hpp.


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