Skip to content

Commit

Permalink
Finalized and tested MCP configuration on F303. Support for up to 8 M…
Browse files Browse the repository at this point in the history
…CP chips on DevKit exposed I2C bus.
  • Loading branch information
Rick Lull committed Jul 18, 2020
1 parent a1d4deb commit 5e5bf67
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
OVERRIDE_CONST(gc_generate_newlines, 1);
// Specifies how much RAM (in bytes) we allocate to the stack of the main
// thread. Useful tuning parameter in case the application runs out of memory.
OVERRIDE_CONST(main_thread_stack_size, 1300);
OVERRIDE_CONST(main_thread_stack_size, 2500);

// Specifies the 48-bit OpenLCB node identifier. This must be unique for every
// hardware manufactured, so in production this should be replaced by some
Expand Down Expand Up @@ -708,27 +708,22 @@ constexpr const Gpio *const kPortExt0[] = {
&IOEXT0_A4, &IOEXT0_A5, &IOEXT0_A6, &IOEXT0_A7, //
&IOEXT0_B0, &IOEXT0_B1, &IOEXT0_B2, &IOEXT0_B3, //
&IOEXT0_B4, &IOEXT0_B5, &IOEXT0_B6, &IOEXT0_B7, //

&IOEXT1_A0, &IOEXT1_A1, &IOEXT1_A2, &IOEXT1_A3, //
&IOEXT1_A4, &IOEXT1_A5, &IOEXT1_A6, &IOEXT1_A7, //
&IOEXT1_B0, &IOEXT1_B1, &IOEXT1_B2, &IOEXT1_B3, //
&IOEXT1_B4, &IOEXT1_B5, &IOEXT1_B6, &IOEXT1_B7, //

&IOEXT10_A0, &IOEXT10_A1, &IOEXT10_A2, &IOEXT10_A3, //
&IOEXT10_A4, &IOEXT10_A5, &IOEXT10_A6, &IOEXT10_A7, //
&IOEXT10_B0, &IOEXT10_B1, &IOEXT10_B2, &IOEXT10_B3, //
&IOEXT10_B4, &IOEXT10_B5, &IOEXT10_B6, &IOEXT10_B7, //

&IOEXT11_A0, &IOEXT11_A1, &IOEXT11_A2, &IOEXT11_A3, //
&IOEXT11_A4, &IOEXT11_A5, &IOEXT11_A6, &IOEXT11_A7, //
&IOEXT11_B0, &IOEXT11_B1, &IOEXT11_B2, &IOEXT11_B3, //
&IOEXT11_B4, &IOEXT11_B5, &IOEXT11_B6, &IOEXT11_B7, //

&IOEXT20_A0, &IOEXT20_A1, &IOEXT20_A2, &IOEXT20_A3, //
&IOEXT20_A4, &IOEXT20_A5, &IOEXT20_A6, &IOEXT20_A7, //
&IOEXT20_B0, &IOEXT20_B1, &IOEXT20_B2, &IOEXT20_B3, //
&IOEXT20_B4, &IOEXT20_B5, &IOEXT20_B6, &IOEXT20_B7, //

&IOEXT21_A0, &IOEXT21_A1, &IOEXT21_A2, &IOEXT21_A3, //
&IOEXT21_A4, &IOEXT21_A5, &IOEXT21_A6, &IOEXT21_A7, //
&IOEXT21_B0, &IOEXT21_B1, &IOEXT21_B2, &IOEXT21_B3, //
Expand Down Expand Up @@ -916,9 +911,6 @@ constexpr const Gpio *const kPortExt0[] = {
&IOEXT11_A4, &IOEXT11_A5, &IOEXT11_A6, &IOEXT11_A7, //
&IOEXT11_B0, &IOEXT11_B1, &IOEXT11_B2, &IOEXT11_B3, //
&IOEXT11_B4, &IOEXT11_B5, &IOEXT11_B6, &IOEXT11_B7,
//};
//
//constexpr const Gpio *const kPortExt1[] = {
&IOEXT20_A0, &IOEXT20_A1, &IOEXT20_A2, &IOEXT20_A3, //
&IOEXT20_A4, &IOEXT20_A5, &IOEXT20_A6, &IOEXT20_A7, //
&IOEXT20_B0, &IOEXT20_B1, &IOEXT20_B2, &IOEXT20_B3, //
Expand All @@ -941,20 +933,13 @@ constexpr const Gpio *const kPortExt0[] = {
openlcb::MultiConfiguredPC ext0_pcs(
stack.node(), kPortExt0, ARRAYSIZE(kPortExt0), cfg.seg().ext0_pc());

//openlcb::MultiConfiguredPC ext1_pcs(
// stack.node(), kPortExt1, ARRAYSIZE(kPortExt1), cfg.seg().ext0_pc());

#endif // if NUM_MCPIOS = 8

openlcb::RefreshLoop loopab(stack.node(),
{
#if NUM_MCPIOS > 0
ext0_pcs.polling(), //
#endif
//#if NUM_MCPIOS > 6
// ext1_pcs.polling(),
//#endif

producer_a1.polling(), producer_a2.polling(), //
producer_a3.polling(), producer_a4.polling(), //
producer_a5.polling(), producer_a6.polling(), //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ extern const SimpleNodeStaticValues SNIP_STATIC_DATA = {

#define NUM_OUTPUTS 16
#define NUM_INPUTS 1
// Input/Output Expansion via DevKit IO Expansion boards with MCP23017s.
// Support from 0 to 8 MCPs (8 is full address space available for MCPs - 3 address bits available)
// Set number from 0 to 8; even numbers only.
#define NUM_MCPIOS 8

// Snap switches and LED lights conflict on same port. When GPIO pin has
Expand Down Expand Up @@ -69,10 +72,8 @@ using Ext0PC = RepeatedGroup<PCConfig, 32>;
using Ext0PC = RepeatedGroup<PCConfig, 64>;
#elif NUM_MCPIOS == 6
using Ext0PC = RepeatedGroup<PCConfig, 64>;
//using Ext1PC = RepeatedGroup<PCConfig, 32>;
#elif NUM_MCPIOS == 8
using Ext0PC = RepeatedGroup<PCConfig, 128>;
//using Ext1PC = RepeatedGroup<PCConfig, 64>;
#endif


Expand Down Expand Up @@ -101,23 +102,13 @@ CDI_GROUP_ENTRY(hidden_servo_5_8, ServoConsumers, Hidden(true));
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"));
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("Expansion board 0 lines"),
CDI_GROUP_ENTRY(ext0_pc, Ext0PC, Name("IO Expansion Board with MCP23017 Lines"),
Description("Line 1-8 is port Even/A, Line 9-16 is port Even/B, Line 17-24 "
"is Odd/A, Line 25-32 is Odd/B. Additional MCPs follow "
"this similar paradigm. "),
RepName("Line"));
CDI_GROUP_END();
#endif
/*
* #if NUMC_MCPIOS > 6
CDI_GROUP_ENTRY(ext0_pc, Ext1PC, Name("Expansion board 1 lines"),
Description("Line 1-8 is port Even/A, Line 9-16 is port Even/B, Line 17-24 "
"is Odd/A, Line 25-32 is Odd/B. Additional MCPs follow "
"this similar paradigm. "),
RepName("Line"));
CDI_GROUP_END();
#endif
*/

/// This segment is only needed temporarily until there is program code to set
/// the ACDI user data version byte.
Expand Down

0 comments on commit 5e5bf67

Please sign in to comment.