Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
Stm32RailcomSender.hxx
Go to the documentation of this file.
1
38#include "dcc/railcom.h"
40
42{
43public:
45 const char *name, USART_TypeDef *base, IRQn_Type interrupt)
46 : Stm32Uart(name, base, interrupt)
47 {
48 }
49
50public:
57 void send_ch1(const DCCFeedback *ch1_pkt) override
58 {
59 ch1Pkt_ = ch1_pkt;
60 }
61
68 void send_ch2(const DCCFeedback *ch2_pkt) override
69 {
70 ch2Pkt_ = ch2_pkt;
71 }
72
73 ssize_t write(File *file, const void *buf, size_t count) override
74 {
75 // We do not support writing through the regular posix API.
76 return -EIO;
77 }
78
79 ssize_t read(File *file, void *buf, size_t count) override
80 {
81 // We do not support reading through the regular posix API.
82 return -EIO;
83 }
84
85private:
86 // ======= DCC driver API ========
88 void feedback_sample() override
89 {
90 }
92 void start_cutout() override;
94 void middle_cutout() override;
96 void end_cutout() override {
97 // We throw away the packets that we got given.
98 //ch1Pkt_ = nullptr;
99 //ch2Pkt_ = nullptr;
100 }
103 void no_cutout() override
104 {
105 // We throw away the packets that we got given.
106 //ch1Pkt_ = nullptr;
107 //ch2Pkt_ = nullptr;
108 }
111 void set_feedback_key(uint32_t key) override
112 {
114 }
115
116private:
120 uintptr_t expectedFeedbackKey_ = 0;
121
123 const DCCFeedback *ch1Pkt_ = nullptr;
125 const DCCFeedback *ch2Pkt_ = nullptr;
126};
const char * name
device name
Definition Devtab.hxx:266
Abstract base class for railcom drivers.
uintptr_t expectedFeedbackKey_
What should be the feedback key in the packet.
void end_cutout() override
Called after the cutout is over.
void start_cutout() override
Called at the beginning of the first window.
ssize_t write(File *file, const void *buf, size_t count) override
Write to a file or device.
void feedback_sample() override
No implementation needed.
void send_ch1(const DCCFeedback *ch1_pkt) override
Specifies what packet should be sent for the channel1 cutout.
const DCCFeedback * ch1Pkt_
The packet to send in channel 1. Externally owned.
void set_feedback_key(uint32_t key) override
Feedback key is set by the DCC decoder driver.
void send_ch2(const DCCFeedback *ch2_pkt) override
Specifies what packet should be sent for the channel2 cutout.
void no_cutout() override
Called instead of start/mid/end-cutout at the end of the current packet if there was no cutout reques...
ssize_t read(File *file, void *buf, size_t count) override
Read from a file or device.
void middle_cutout() override
Called at the beginning of the middle window.
const DCCFeedback * ch2Pkt_
The packet to send in channel 2. Externally owned.
Specialization of Serial driver for STM32F0xx devices.
Definition Stm32Uart.hxx:89
IRQn_Type interrupt
interrupt of this device
Stm32Uart()
Default constructor.
File information.
Definition Devtab.hxx:52