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

#include <can.hpp>

Inheritance diagram for uavcan_kinetis::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 (flexcan::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::uint32_t rx_iflags, uavcan::uint64_t utc_usec)
 
void handleTxInterrupt (uavcan::uint32_t tx_iflags, 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  { NumTxMesgBuffers = 6 }
 
enum  { NumFilters = 16 }
 

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)
 
uavcan::int16_t doReset (Timings timings)
 
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 setEnable (bool enable_true)
 
void setFreeze (bool freeze_true)
 
void setMCR (uavcan::uint32_t mask, bool target_state)
 
bool waitFreezeAckChange (bool target_state)
 
bool waitMCRChange (uavcan::uint32_t mask, bool target_state)
 
- Private Member Functions inherited from uavcan::Noncopyable
 Noncopyable ()
 
 ~Noncopyable ()
 

Private Attributes

flexcan::CanType *const can_
 
uavcan::uint64_t error_cnt_
 
const uavcan::uint32_t FIFO_IFLAG1 = flexcan::CAN_FIFO_NE | flexcan::CAN_FIFO_WARN | flexcan::CAN_FIFO_OV
 
uavcan::uint64_t fifo_warn_cnt_
 
bool had_activity_
 
uavcan::uint8_t MaxMB
 
uavcan::uint8_t peak_tx_mailbox_index_
 
uavcan::uint32_t pending_aborts_
 
TxItem pending_tx_ [NumTxMesgBuffers]
 
RxQueue rx_queue_
 
const uavcan::uint8_t self_index_
 
uavcan::uint32_t served_aborts_cnt_
 
BusEventupdate_event_
 

Detailed Description

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

Definition at line 51 of file platform_specific_components/kinetis/libuavcan/driver/include/uavcan_kinetis/can.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
NumTxMesgBuffers 

Definition at line 124 of file platform_specific_components/kinetis/libuavcan/driver/include/uavcan_kinetis/can.hpp.

◆ anonymous enum

anonymous enum
private

◆ anonymous enum

anonymous enum
Enumerator
MaxRxQueueCapacity 

Definition at line 167 of file platform_specific_components/kinetis/libuavcan/driver/include/uavcan_kinetis/can.hpp.

◆ OperatingMode

Enumerator
NormalMode 
SilentMode 

Definition at line 169 of file platform_specific_components/kinetis/libuavcan/driver/include/uavcan_kinetis/can.hpp.

Constructor & Destructor Documentation

◆ CanIface()

uavcan_kinetis::CanIface::CanIface ( flexcan::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_kinetis::CanIface::canAcceptNewTxFrame ( const uavcan::CanFrame frame) const

Definition at line 782 of file uc_kinetis_flexcan.cpp.

◆ computeTimings()

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

Definition at line 139 of file uc_kinetis_flexcan.cpp.

◆ configureFilters()

uavcan::int16_t uavcan_kinetis::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 325 of file uc_kinetis_flexcan.cpp.

◆ discardTimedOutTxMailboxes()

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

Definition at line 767 of file uc_kinetis_flexcan.cpp.

◆ doReset()

uavcan::int16_t uavcan_kinetis::CanIface::doReset ( Timings  timings)
private

Definition at line 456 of file uc_kinetis_flexcan.cpp.

◆ getErrorCount()

uavcan::uint64_t uavcan_kinetis::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 820 of file uc_kinetis_flexcan.cpp.

◆ getNumFilters()

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

Number of available hardware filters.

Implements uavcan::ICanIface.

Definition at line 152 of file platform_specific_components/kinetis/libuavcan/driver/include/uavcan_kinetis/can.hpp.

◆ getPeakNumTxMailboxesUsed()

uavcan::uint8_t uavcan_kinetis::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 258 of file platform_specific_components/kinetis/libuavcan/driver/include/uavcan_kinetis/can.hpp.

◆ getRxQueueLength()

unsigned uavcan_kinetis::CanIface::getRxQueueLength ( ) const

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

Definition at line 826 of file uc_kinetis_flexcan.cpp.

◆ getRxQueueOverflowCount()

uavcan::uint32_t uavcan_kinetis::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 222 of file platform_specific_components/kinetis/libuavcan/driver/include/uavcan_kinetis/can.hpp.

◆ getVoluntaryTxAbortCount()

uavcan::uint32_t uavcan_kinetis::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 237 of file platform_specific_components/kinetis/libuavcan/driver/include/uavcan_kinetis/can.hpp.

◆ hadActivity()

bool uavcan_kinetis::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 832 of file uc_kinetis_flexcan.cpp.

◆ handleRxInterrupt()

void uavcan_kinetis::CanIface::handleRxInterrupt ( uavcan::uint32_t  rx_iflags,
uavcan::uint64_t  utc_usec 
)

Definition at line 661 of file uc_kinetis_flexcan.cpp.

◆ handleTxInterrupt()

void uavcan_kinetis::CanIface::handleTxInterrupt ( uavcan::uint32_t  tx_iflags,
uavcan::uint64_t  utc_usec 
)

Definition at line 614 of file uc_kinetis_flexcan.cpp.

◆ handleTxMailboxInterrupt()

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

Definition at line 598 of file uc_kinetis_flexcan.cpp.

◆ init()

int uavcan_kinetis::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 500 of file uc_kinetis_flexcan.cpp.

◆ isRxBufferEmpty()

bool uavcan_kinetis::CanIface::isRxBufferEmpty ( ) const

Definition at line 814 of file uc_kinetis_flexcan.cpp.

◆ pollErrorFlagsFromISR()

void uavcan_kinetis::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 736 of file uc_kinetis_flexcan.cpp.

◆ receive()

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

Definition at line 308 of file uc_kinetis_flexcan.cpp.

◆ send()

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

Definition at line 211 of file uc_kinetis_flexcan.cpp.

◆ setEnable()

bool uavcan_kinetis::CanIface::setEnable ( bool  enable_true)
private

Definition at line 451 of file uc_kinetis_flexcan.cpp.

◆ setFreeze()

void uavcan_kinetis::CanIface::setFreeze ( bool  freeze_true)
private

Definition at line 432 of file uc_kinetis_flexcan.cpp.

◆ setMCR()

void uavcan_kinetis::CanIface::setMCR ( uavcan::uint32_t  mask,
bool  target_state 
)
private

Definition at line 414 of file uc_kinetis_flexcan.cpp.

◆ waitFreezeAckChange()

bool uavcan_kinetis::CanIface::waitFreezeAckChange ( bool  target_state)
private

Definition at line 427 of file uc_kinetis_flexcan.cpp.

◆ waitMCRChange()

bool uavcan_kinetis::CanIface::waitMCRChange ( uavcan::uint32_t  mask,
bool  target_state 
)
private

Definition at line 399 of file uc_kinetis_flexcan.cpp.

Member Data Documentation

◆ can_

flexcan::CanType* const uavcan_kinetis::CanIface::can_
private

◆ error_cnt_

uavcan::uint64_t uavcan_kinetis::CanIface::error_cnt_
private

◆ FIFO_IFLAG1

const uavcan::uint32_t uavcan_kinetis::CanIface::FIFO_IFLAG1 = flexcan::CAN_FIFO_NE | flexcan::CAN_FIFO_WARN | flexcan::CAN_FIFO_OV
private

◆ fifo_warn_cnt_

uavcan::uint64_t uavcan_kinetis::CanIface::fifo_warn_cnt_
private

◆ had_activity_

bool uavcan_kinetis::CanIface::had_activity_
private

◆ MaxMB

uavcan::uint8_t uavcan_kinetis::CanIface::MaxMB
private

◆ peak_tx_mailbox_index_

uavcan::uint8_t uavcan_kinetis::CanIface::peak_tx_mailbox_index_
private

◆ pending_aborts_

uavcan::uint32_t uavcan_kinetis::CanIface::pending_aborts_
private

◆ pending_tx_

TxItem uavcan_kinetis::CanIface::pending_tx_[NumTxMesgBuffers]
private

◆ rx_queue_

RxQueue uavcan_kinetis::CanIface::rx_queue_
private

◆ self_index_

const uavcan::uint8_t uavcan_kinetis::CanIface::self_index_
private

◆ served_aborts_cnt_

uavcan::uint32_t uavcan_kinetis::CanIface::served_aborts_cnt_
private

◆ update_event_

BusEvent& uavcan_kinetis::CanIface::update_event_
private

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


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