Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include "openlcb/SimpleStack.hxx"
#include "openlcb/MultiConfiguredConsumer.hxx"
#include "openlcb/ConfiguredExclusiveConsumer.hxx"
#include "openlcb/ConfiguredProducer.hxx"
#include "openlcb/ServoConsumer.hxx"

Expand Down Expand Up @@ -330,7 +331,7 @@ constexpr const MmapGpio PORTE_LINE6(output_register, 10, true);
constexpr const MmapGpio PORTE_LINE7(output_register, 9, true);
constexpr const MmapGpio PORTE_LINE8(output_register, 8, true);


#if !defined(PORTD_EXCLUSIVE) && !defined(PORTE_EXCLUSIVE)
constexpr const Gpio *const kPortDEGpio[] = {
#ifndef PORTD_SNAP
&PORTD_LINE1, &PORTD_LINE2, &PORTD_LINE3, &PORTD_LINE4, //
Expand All @@ -342,9 +343,57 @@ constexpr const Gpio *const kPortDEGpio[] = {

openlcb::MultiConfiguredConsumer portde_consumers(stack.node(), kPortDEGpio,
ARRAYSIZE(kPortDEGpio), cfg.seg().portde_consumers());
#endif

#ifdef PORTD_SNAP
#ifdef PORTD_EXCLUSIVE
// ======================================================================
// Port D exclusive groups: lines 1-4 and 5-8 are mutually exclusive.
// ======================================================================

/// Port D lines 1, 2, 3, 4 — exclusive group 1.
constexpr const Gpio *const kPortDExcl1Gpio[] = {
&PORTD_LINE1, &PORTD_LINE2, &PORTD_LINE3, &PORTD_LINE4,
};

openlcb::ConfiguredExclusiveConsumer portd_excl_1(stack.node(),
kPortDExcl1Gpio, ARRAYSIZE(kPortDExcl1Gpio),
cfg.seg().portd_excl_1());

/// Port D lines 5, 6, 7, 8 — exclusive group 2.
constexpr const Gpio *const kPortDExcl2Gpio[] = {
&PORTD_LINE5, &PORTD_LINE6, &PORTD_LINE7, &PORTD_LINE8,
};

openlcb::ConfiguredExclusiveConsumer portd_excl_2(stack.node(),
kPortDExcl2Gpio, ARRAYSIZE(kPortDExcl2Gpio),
cfg.seg().portd_excl_2());
#endif

#ifdef PORTE_EXCLUSIVE
// ======================================================================
// Port E exclusive groups: lines 1-4 and 5-8 are mutually exclusive.
// ======================================================================

/// Port E lines 1, 2, 3, 4 — exclusive group 1.
constexpr const Gpio *const kPortEExcl1Gpio[] = {
&PORTE_LINE1, &PORTE_LINE2, &PORTE_LINE3, &PORTE_LINE4,
};

openlcb::ConfiguredExclusiveConsumer porte_excl_1(stack.node(),
kPortEExcl1Gpio, ARRAYSIZE(kPortEExcl1Gpio),
cfg.seg().porte_excl_1());

/// Port E lines 5, 6, 7, 8 — exclusive group 2.
constexpr const Gpio *const kPortEExcl2Gpio[] = {
&PORTE_LINE5, &PORTE_LINE6, &PORTE_LINE7, &PORTE_LINE8,
};

openlcb::ConfiguredExclusiveConsumer porte_excl_2(stack.node(),
kPortEExcl2Gpio, ARRAYSIZE(kPortEExcl2Gpio),
cfg.seg().porte_excl_2());
#endif

#ifdef PORTD_SNAP
openlcb::ConfiguredPulseConsumer turnout_pulse_consumer_1(
stack.node(), cfg.seg().snap_switches().entry<0>(), (const Gpio*)&PORTD_LINE1);
openlcb::ConfiguredPulseConsumer turnout_pulse_consumer_2(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ extern const SimpleNodeStaticValues SNIP_STATIC_DATA = {

//#define PORTD_SNAP

// Exlusive outputs can be configured on any group of general GPIO outputs
// At minimum, 2 outputs would be grouped together. For use to drive a signal head,
// 3 or 4 outputs should be grouped. As the DevKit has 16 total outputs across Port D
// and E, for this example, we are grouping them into 4 outputs to keep this even.
//
#define PORTD_EXCLUSIVE
#define PORTE_EXCLUSIVE

/// Declares a repeated group of a given base group and number of repeats. The
/// ProducerConfig and ConsumerConfig groups represent the configuration layout
/// needed by the ConfiguredProducer and ConfiguredConsumer classes, and come
Expand Down Expand Up @@ -78,7 +86,7 @@ using Ext0PC = RepeatedGroup<PCConfig, 16 * NUM_MCPIOS>;

/// Modify this value every time the EEPROM needs to be cleared on the node
/// after an update.
static constexpr uint16_t CANONICAL_VERSION = 0x11A4 + NUM_MCPIOS;
static constexpr uint16_t CANONICAL_VERSION = 0x11A6 + NUM_MCPIOS;

CDI_GROUP(NucleoGroup, Name("Nucleo peripherals"), Description("These are physically located on the nucleo CPU daughterboard."));
CDI_GROUP_ENTRY(green_led, ConsumerConfig, Name("Nucleo user LED"), Description("Green led (LD2)."));
Expand All @@ -92,24 +100,34 @@ CDI_GROUP(IoBoardSegment, Segment(MemoryConfigDefs::SPACE_CONFIG), Offset(128));
/// optional arguments list.
CDI_GROUP_ENTRY(internal_config, InternalConfigData);
CDI_GROUP_ENTRY(nucleo_onboard, NucleoGroup);
//#ifdef PORTD_SNAP
#ifdef PORTD_SNAP
CDI_GROUP_ENTRY(snap_switches, PulseConsumers, Name("Consumers for snap switches"), Description("These are on port D"), RepName("Line"));
//#endif
#endif
CDI_GROUP_ENTRY(direct_consumers, DirectConsumers, Name("Tortoise/Hi-Power outputs"), RepName("Line"));
CDI_GROUP_ENTRY(servo_consumers, ServoConsumers, Name("Servo Pin outputs"), Description("3-pin servo outputs."), RepName("Line"));
CDI_GROUP_ENTRY(hidden_servo_5_8, ServoConsumers, Hidden(true));
#ifdef PORTD_SNAP
CDI_GROUP_ENTRY(portde_consumers, PortDEConsumers, Name("Port E outputs"), Description("Line 1-4 is port E 5 - 8; offset due to Snap Switches"), RepName("Line"));
#else
CDI_GROUP_ENTRY(portde_consumers, PortDEConsumers, Name("Port D/E outputs"), Description("Line 1-8 is port D, Line 9-16 is port E"), RepName("Line"));
#endif

#ifdef PORTD_EXCLUSIVE
CDI_GROUP_ENTRY(portd_excl_1, ExclusiveGroup4, Name("Port D exclusive group 1"),
Description("Lines 1-4 on port D. Only one output is active at a time."),
RepName("Line"));
CDI_GROUP_ENTRY(portd_excl_2, ExclusiveGroup4, Name("Port D exclusive group 2"),
Description("Lines 5-8 on port D. Only one output is active at a time."),
RepName("Line"));
#endif
#ifdef PORTE_EXCLUSIVE
CDI_GROUP_ENTRY(porte_excl_1, ExclusiveGroup4, Name("Port E exclusive group 1"),
Description("Lines 1-4 on port E. Only one output is active at a time."),
RepName("Line"));
CDI_GROUP_ENTRY(porte_excl_2, ExclusiveGroup4, Name("Port E exclusive group 2"),
Description("Lines 5-8 on port E. Only one output is active at a time."),
RepName("Line"));
#endif
CDI_GROUP_ENTRY(portab_producers, PortABProducers, Name("Port A/B inputs"), Description("Line 1-8 is port A, Line 9-16 is port B"), RepName("Line"));
#if NUM_MCPIOS > 0
CDI_GROUP_ENTRY(ext0_pc, Ext0PC, Name("IO Expansion Board with MCP23017 Lines"),
Expand Down
Loading
Loading