|
Open Model Railroad Network (OpenMRN)
|
Device driver for decoding a DCC signal on a TI Tiva class microcontroller. More...
#include <TivaDCCDecoder.hxx>
Public Types | |
| using | NRZ_Pin = typename HW::NRZ_Pin |
| Exports the input pin to the driver on the module interface. | |
Public Member Functions | |
| DISALLOW_COPY_AND_ASSIGN (TivaDccTimerModule) | |
Static Public Member Functions | |
| static uint32_t | get_ticks_per_usec () |
| static void | module_init () |
| Called once during construction time. | |
| static void | module_enable () |
| Called inline with Device::enable(). | |
| static void | module_disable () |
| Called inline with Device::disable(). | |
| static void | trigger_os_interrupt () |
| Calls a software interrupt. | |
| static void | dcc_before_cutout_hook () |
| hook | |
| static void | dcc_packet_finished_hook () |
| hook | |
| static void | after_feedback_hook () |
| hook | |
| static int | time_delta_railcom_pre_usec () |
| How many usec later should the railcom cutout start happen. | |
| static int | time_delta_railcom_mid_usec () |
| How many usec later should the railcom cutout middle happen. | |
| static int | time_delta_railcom_end_usec () |
| How many usec later should the railcom cutout middle happen. | |
| static bool | int_get_and_clear_capture_event () |
| Called from the capture interrupt handler. | |
| static uint32_t | get_capture_counter () |
| Called from the interrupt handler if int_get_and_clear_capture_event said yes. | |
| static bool | int_get_and_clear_delay_event () |
| Called from the timeout interrupt handler. | |
| static void | set_cap_timer_delay_usec (int usec) |
| Delays a give number of usec using the capture timer feature. | |
| static void | set_cap_timer_capture () |
| Sets the timer to capture mode. | |
| static void | set_cap_timer_time () |
| Sets the timer to oneshot (timer) mode. | |
| static void | stop_cap_timer_time () |
| Called once inline in an interrupt. | |
Static Public Attributes | |
| static constexpr uint32_t | TIMER_MAX_VALUE = HW::TIMER_MAX_VALUE |
| This is the counter from which the timer starts counting down. | |
| static constexpr uint32_t | SAMPLE_PERIOD_CLOCKS = HW::SAMPLE_PERIOD_CLOCKS |
| After how many timer counts we should take one sample. | |
| static constexpr unsigned | Q_SIZE = HW::Q_SIZE |
| Length of the device queue. | |
Device driver for decoding a DCC signal on a TI Tiva class microcontroller.
This driver exports a filesystem device node, but that file node is not usable for reading or writing anything at the moment. The only feature supported by this device driver right now is that it is able to tell a RailcomDriver when the railcom cutout is supposed to start, when we're in the middle and when it is over. This is necessary for the correct functionality of the railcom driver.
Usage: Define a structure declaring your hardware information. See below for what you need to define in there. Instantiate the device driver and pass the pointer to the railcom driver to the constructor. There is no need to touch the device from the application layer.
Example hardware definitions:
struct DCCDecode { static const auto TIMER_BASE = WTIMER4_BASE; static const auto TIMER_PERIPH = SYSCTL_PERIPH_WTIMER4; static const auto TIMER_INTERRUPT = INT_WTIMER4A; static const auto TIMER = TIMER_A; static const auto CFG_CAP_TIME_UP = TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP | TIMER_CFG_B_ONE_SHOT; Interrupt bits. static const auto TIMER_CAP_EVENT = TIMER_CAPA_EVENT; static const auto TIMER_TIM_TIMEOUT = TIMER_TIMA_TIMEOUT;
static const auto OS_INTERRUPT = INT_WTIMER4B; DECL_PIN(NRZPIN, D, 4); static const auto NRZPIN_CONFIG = GPIO_PD4_WT4CCP0;
static const uint32_t TIMER_MAX_VALUE = 0x8000000UL;
static const int Q_SIZE = 16;
};
Definition at line 84 of file TivaDCCDecoder.hxx.
| using TivaDccTimerModule< HW >::NRZ_Pin = typename HW::NRZ_Pin |
Exports the input pin to the driver on the module interface.
Definition at line 88 of file TivaDCCDecoder.hxx.
|
inlinestatic |
hook
Definition at line 134 of file TivaDCCDecoder.hxx.
|
inlinestatic |
hook
Definition at line 122 of file TivaDCCDecoder.hxx.
|
inlinestatic |
hook
Definition at line 128 of file TivaDCCDecoder.hxx.
|
inlinestatic |
Called from the interrupt handler if int_get_and_clear_capture_event said yes.
Definition at line 283 of file TivaDCCDecoder.hxx.
|
inlinestatic |
Definition at line 101 of file TivaDCCDecoder.hxx.
|
inlinestatic |
Called from the capture interrupt handler.
Checks interrupt status, clears interrupt.
Definition at line 269 of file TivaDCCDecoder.hxx.
|
inlinestatic |
Called from the timeout interrupt handler.
Checks interrupt status, clears timer expired interrupt.
Definition at line 288 of file TivaDCCDecoder.hxx.
|
static |
Called inline with Device::disable().
Definition at line 259 of file TivaDCCDecoder.hxx.
|
static |
Called inline with Device::enable().
Definition at line 242 of file TivaDCCDecoder.hxx.
|
static |
Called once during construction time.
Definition at line 235 of file TivaDCCDecoder.hxx.
|
inlinestatic |
Sets the timer to capture mode.
Needed for the digitization of DCC signal bits.
Definition at line 187 of file TivaDCCDecoder.hxx.
|
inlinestatic |
Delays a give number of usec using the capture timer feature.
Needed for the timing of the railcom cutout.
| usec | how much to delay. |
Definition at line 177 of file TivaDCCDecoder.hxx.
|
inlinestatic |
Sets the timer to oneshot (timer) mode.
Called once, then set_cap_timer_delay_usec() will be called multiple times, expecting each to deliver an rcom_interrupt().
Definition at line 209 of file TivaDCCDecoder.hxx.
|
inlinestatic |
Called once inline in an interrupt.
Signals that the delay timer is not needed anymore.
Definition at line 227 of file TivaDCCDecoder.hxx.
|
inlinestatic |
How many usec later should the railcom cutout middle happen.
Definition at line 152 of file TivaDCCDecoder.hxx.
|
inlinestatic |
How many usec later should the railcom cutout middle happen.
Definition at line 146 of file TivaDCCDecoder.hxx.
|
inlinestatic |
How many usec later should the railcom cutout start happen.
Definition at line 140 of file TivaDCCDecoder.hxx.
|
inlinestatic |
Calls a software interrupt.
Definition at line 116 of file TivaDCCDecoder.hxx.
|
staticconstexpr |
Length of the device queue.
Definition at line 98 of file TivaDCCDecoder.hxx.
|
staticconstexpr |
After how many timer counts we should take one sample.
Definition at line 96 of file TivaDCCDecoder.hxx.
|
staticconstexpr |
This is the counter from which the timer starts counting down.
When the timer overflows, it starts from this value.
Definition at line 94 of file TivaDCCDecoder.hxx.