Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
Stm32RailcomDriver< HW > Class Template Reference

Railcom driver for STM32-class microcontrollers using the HAL middleware library. More...

#include <Stm32Railcom.hxx>

Inheritance diagram for Stm32RailcomDriver< HW >:
RailcomDriverBase< HW > RailcomDriver Node RailcomDriver Node

Public Member Functions

 Stm32RailcomDriver (const char *path)
 Constructor.
 
- Public Member Functions inherited from RailcomDriverBase< HW >
 RailcomDriverBase (const char *name)
 Constructor.
 
void os_interrupt_handler ()
 Implementation of the interrupt handler running at the kernel interrupt priority.
 
 RailcomDriverBase (const char *name)
 Constructor.
 
void os_interrupt_handler ()
 Implementation of the interrupt handler running at the kernel interrupt priority.
 
- Public Member Functions inherited from RailcomDriver
virtual void send_ch1 (const DCCFeedback *ch1_pkt)
 Specifies what packet should be sent for the channel1 cutout.
 
virtual void send_ch2 (const DCCFeedback *ch2_pkt)
 Specifies what packet should be sent for the channel2 cutout.
 

Private Member Functions

void int_set_pending (unsigned int_nr) override
 Sets a given software interrupt pending.
 
void enable () OVERRIDE
 This will be called once when reference-count goes from 0 to positive.
 
void disable () override
 This will be called when reference count goes from non-zero to 0.
 
void feedback_sample () override
 Call to the driver for sampling the current sensors.
 
void start_cutout () override
 Instructs the driver that the railcom cutout is starting now.
 
void middle_cutout () override
 Notifies the driver that the railcom cutout has reached the middle point, i.e., the first window is passed and the second window is starting.
 
void end_cutout () override
 Instructs the driver that the railcom cutout is over now.
 
void no_cutout () override
 Called instead of start/mid/end-cutout at the end of the current packet if there was no cutout requested.
 

Static Private Member Functions

static constexpr USART_TypeDef * uart (unsigned i)
 
static constexpr DMA_Channel_TypeDef * dma_ch (unsigned i)
 

Private Attributes

bool inCutout_ = false
 True when we are currently within a cutout.
 

Additional Inherited Members

- Protected Member Functions inherited from RailcomDriverBase< HW >
dcc::Feedbackalloc_new_packet (uint8_t channel)
 Takes a new empty packet at the front of the queue, fills in feedback key and channel information.
 
void add_sample (int sample)
 Adds a sample for a preamble bit.
 
dcc::Feedbackalloc_new_packet (uint8_t channel)
 Takes a new empty packet at the front of the queue, fills in feedback key and channel information.
 
void add_sample (int sample)
 Adds a sample for a preamble bit.
 
- Protected Attributes inherited from RailcomDriverBase< HW >
NotifiablereadableNotifiable_
 Notify this when we have data in our buffers.
 
FixedQueue< dcc::Feedback, HW::Q_SIZE > feedbackQueue_
 The packets we have read so far.
 
uint32_t feedbackKey_
 Stores the key for the next packets to read.
 
dcc::FeedbackreturnedPackets_ [HW::CHANNEL_COUNT]
 Stores pointers to packets we are filling right now, one for each channel.
 

Detailed Description

template<class HW>
class Stm32RailcomDriver< HW >

Railcom driver for STM32-class microcontrollers using the HAL middleware library.

This railcom driver supports parallel polling of multiple UART channels for the railcom data.

Definition at line 166 of file Stm32Railcom.hxx.

Constructor & Destructor Documentation

◆ Stm32RailcomDriver()

template<class HW >
Stm32RailcomDriver< HW >::Stm32RailcomDriver ( const char *  path)
inline

Constructor.

Parameters
pathis the device node path (e.g. "/dev/railcom0").

Definition at line 170 of file Stm32Railcom.hxx.

◆ ~Stm32RailcomDriver()

template<class HW >
Stm32RailcomDriver< HW >::~Stm32RailcomDriver ( )
inline

Definition at line 181 of file Stm32Railcom.hxx.

Member Function Documentation

◆ disable()

template<class HW >
void Stm32RailcomDriver< HW >::disable ( )
inlineoverrideprivatevirtual

This will be called when reference count goes from non-zero to 0.

Called with lock_ held.

Implements Node.

Definition at line 258 of file Stm32Railcom.hxx.

◆ dma_ch()

template<class HW >
static constexpr DMA_Channel_TypeDef * Stm32RailcomDriver< HW >::dma_ch ( unsigned  i)
inlinestaticconstexprprivate
Parameters
ichannel number (0..HW::NUM_CHANNEL)
Returns
dma channel instance for channel i.

Definition at line 201 of file Stm32Railcom.hxx.

◆ enable()

template<class HW >
void Stm32RailcomDriver< HW >::enable ( )
inlineprivatevirtual

This will be called once when reference-count goes from 0 to positive.

Called with lock_ held.

Implements Node.

Definition at line 214 of file Stm32Railcom.hxx.

◆ end_cutout()

template<class HW >
void Stm32RailcomDriver< HW >::end_cutout ( )
inlineoverrideprivatevirtual

Instructs the driver that the railcom cutout is over now.

The driver will use this information to disable the UART receiver.

Implements RailcomDriver.

Definition at line 357 of file Stm32Railcom.hxx.

◆ feedback_sample()

template<class HW >
void Stm32RailcomDriver< HW >::feedback_sample ( )
inlineoverrideprivatevirtual

Call to the driver for sampling the current sensors.

This call is performed repeatedly, in a configurable interval, on the next positive edge.

Implements RailcomDriver.

Definition at line 267 of file Stm32Railcom.hxx.

◆ int_set_pending()

template<class HW >
void Stm32RailcomDriver< HW >::int_set_pending ( unsigned  int_nr)
inlineoverrideprivatevirtual

Sets a given software interrupt pending.

Parameters
int_nrinterrupt number (will be HW::OS_INTERRUPT)

Implements RailcomDriverBase< HW >.

Definition at line 208 of file Stm32Railcom.hxx.

◆ middle_cutout()

template<class HW >
void Stm32RailcomDriver< HW >::middle_cutout ( )
inlineoverrideprivatevirtual

Notifies the driver that the railcom cutout has reached the middle point, i.e., the first window is passed and the second window is starting.

The driver will use this information to separate channel 1 nd channel 2 data.

Implements RailcomDriver.

Definition at line 303 of file Stm32Railcom.hxx.

◆ no_cutout()

template<class HW >
void Stm32RailcomDriver< HW >::no_cutout ( )
inlineoverrideprivatevirtual

Called instead of start/mid/end-cutout at the end of the current packet if there was no cutout requested.

Implements RailcomDriver.

Definition at line 412 of file Stm32Railcom.hxx.

◆ start_cutout()

template<class HW >
void Stm32RailcomDriver< HW >::start_cutout ( )
inlineoverrideprivatevirtual

Instructs the driver that the railcom cutout is starting now.

The driver will use this information to enable the UART receiver.

Implements RailcomDriver.

Definition at line 274 of file Stm32Railcom.hxx.

◆ uart()

template<class HW >
static constexpr USART_TypeDef * Stm32RailcomDriver< HW >::uart ( unsigned  i)
inlinestaticconstexprprivate
Parameters
ichannel number (0..HW::NUM_CHANNEL)
Returns
uart hardware instance for channel i.

Definition at line 194 of file Stm32Railcom.hxx.

Member Data Documentation

◆ inCutout_

template<class HW >
bool Stm32RailcomDriver< HW >::inCutout_ = false
private

True when we are currently within a cutout.

Definition at line 188 of file Stm32Railcom.hxx.


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