36#ifndef _DCC_DCCOUTPUT_HXX_
37#define _DCC_DCCOUTPUT_HXX_
145 HW::set_disable_reason(bit);
151 HW::clear_disable_reason(bit);
157 HW::isRailcomCutoutEnabled_ = (uint8_t)cutout;
163 return HW::outputDisableReasons_;
318template <
int N,
class BOOSTER_ENABLE,
class RAILCOM_ENABLE,
319 unsigned DELAY_ON_1,
unsigned DELAY_ON_2,
unsigned DELAY_OFF>
326 BOOSTER_ENABLE::hw_init();
327 BOOSTER_ENABLE::set(
false);
328 RAILCOM_ENABLE::hw_init();
329 RAILCOM_ENABLE::set(
false);
336 BOOSTER_ENABLE::set(
false);
344 RAILCOM_ENABLE::set(
true);
352 RAILCOM_ENABLE::set(
false);
367 BOOSTER_ENABLE::set(
true);
373 BOOSTER_ENABLE::set(
false);
DccOutput * get_dcc_output(DccOutput::Type type)
Public API accessor for applications to get the object representing the output hardware.
Default implementation class of the DccOutput that proxies the calls to a hardware-specific static st...
static const DccOutputImpl< HW > instance_
Default instance to be used.
void clear_disable_output_for_reason(DisableReason bit) override
Removes a disable reason flag.
void set_railcom_cutout_enabled(RailcomCutout cutout) override
Specifies whether there should be a railcom cutout on this output.
void disable_output_for_reason(DisableReason bit) override
Disables the output, marking in a bitmask why.
static constexpr DccOutput * instance()
uint8_t get_disable_output_reasons() override
Virtual base class for controlling outputs.
virtual void disable_output_for_reason(DisableReason bit)=0
Disables the output, marking in a bitmask why.
Type
Enumeration describing different outputs.
@ TRACK
DCC output of the integrated booster.
@ PGM
DCC output of the program track.
@ LCC
DCC output going towards the LCC cable.
virtual void set_railcom_cutout_enabled(RailcomCutout cutout)=0
Specifies whether there should be a railcom cutout on this output.
virtual void clear_disable_output_for_reason(DisableReason bit)=0
Removes a disable reason flag.
virtual uint8_t get_disable_output_reasons()=0
void override_disable_bit_for_reason(DisableReason bit, bool value)
Sets or clears a disable reason.
RailcomCutout
Defines the values for the railcom cutout enabled setting.
@ DISABLED
Generate no railcom cutout.
@ LONG_CUTOUT
Generate long cutout (standard size; ch1+ch2).
@ SHORT_CUTOUT
Generate short cutout (ch1 only).
DisableReason
Values of a bit mask why we might want to disable a given DCC output.
@ GLOBAL_EOFF
A network message requested global emergency off.
@ THERMAL
The system is in thermal shutdown.
@ INITIALIZATION_PENDING
Set as 1 during construction time, to be cleared by the application when the initialization is comple...
@ LOCAL_DISABLE
A local request for disabling the output.
@ SHORTED
Short detector says this output is shorted.
@ CONFIG_SETTING
User decided via a persistent configuration that this output should not be enabled.
@ INVALID_SIGNAL_INPUT
invalid incoming DCC signal
@ PGM_TRACK_LOCKOUT
This output should be off due to the conflict between program track and normal operation mode.
@ USR1
Reserved for application specific use cases.
Interface that the actual outputs have to implement in their hardware-specific classes.
static void stop_railcom_cutout_phase2(void)
Invoked at the end of a railcom cutout.
static unsigned start_railcom_cutout_phase1(void)
Invoked at the beginning of a railcom cutout.
static void enable_output(void)
Called once every packet by the driver, typically before the preamble, if the output is supposed to b...
static bool need_railcom_cutout()
A dummy output never needs a railcom cutout.
static void hw_preinit(void)
Called once during hw_preinit boot state.
static unsigned start_railcom_cutout_phase2(void)
Invoked at the beginning of a railcom cutout after the delay.
static unsigned stop_railcom_cutout_phase1(void)
Invoked at the end of a railcom cutout.
Generic implementation of the actual HW output with a booster enable and a railcom enable GPIO.
static void enable_output(void)
Called once every packet by the driver, typically before the preamble, if the output is supposed to b...
static void hw_preinit(void)
Called once during hw_preinit boot state.
static unsigned start_railcom_cutout_phase2(void)
Invoked at the beginning of a railcom cutout after the delay.
static unsigned start_railcom_cutout_phase1(void)
Invoked at the beginning of a railcom cutout.
static void stop_railcom_cutout_phase2(void)
Invoked at the end of a railcom cutout.
static unsigned stop_railcom_cutout_phase1(void)
Invoked at the end of a railcom cutout.
This structure represents a single output channel for a DCC command station.
static bool need_railcom_cutout()
Called by the driver to decide whether to make this channel participate in the railcom cutout.
static std::atomic_uint_least8_t outputDisableReasons_
Bitmask of why this output should be disabled.
static void set_disable_reason_impl(DccOutput::DisableReason bit)
Set one bit in the disable reasons bit field.
static bool should_be_enabled()
Called once after the railcom cutout is done to decide whether this output should be reenabled.
DccOutputHw()
Private constructor.
static std::atomic_uint_least8_t isRailcomCutoutEnabled_
0 if we should not produce a railcom cutout; 1 for short cutout; 2 for regular cutout.
static uint8_t isRailcomCutoutActive_
1 if we are in a railcom cutout currently.
static void clear_disable_reason(DccOutput::DisableReason bit)
Clears a disable reason.