Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reset port to all MCP23xxx samples (best practice) #474

Merged
merged 1 commit into from
Nov 17, 2022
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 @@ -17,8 +17,9 @@ public class MeadowApp : App<F7FeatherV2>
public override Task Initialize()
{
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeRising);
IDigitalOutputPort resetPort = Device.CreateDigitalOutputPort(Device.Pins.D01);

mcp = new Mcp23008(Device.CreateI2cBus(), 0x20, interruptPort);
mcp = new Mcp23008(Device.CreateI2cBus(), 0x20, interruptPort, resetPort);

return base.Initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class MeadowApp : App<F7FeatherV2>
public override Task Initialize()
{
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeRising);
IDigitalOutputPort resetPort = Device.CreateDigitalOutputPort(Device.Pins.D01);

mcp = new Mcp23009(Device.CreateI2cBus(), 0x20, interruptPort);
mcp = new Mcp23009(Device.CreateI2cBus(), 0x20, interruptPort, resetPort);

return base.Initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class MeadowApp : App<F7FeatherV2>
public override Task Initialize()
{
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeRising);

mcp = new Mcp23017(Device.CreateI2cBus(), 0x20, interruptPort);
IDigitalOutputPort resetPort = Device.CreateDigitalOutputPort(Device.Pins.D01);

mcp = new Mcp23017(Device.CreateI2cBus(), 0x20, interruptPort, resetPort);

return base.Initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class MeadowApp : App<F7FeatherV2>
public override Task Initialize()
{
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeRising);

mcp = new Mcp23018(Device.CreateI2cBus(), 0x20, interruptPort);
IDigitalOutputPort resetPort = Device.CreateDigitalOutputPort(Device.Pins.D01);

mcp = new Mcp23018(Device.CreateI2cBus(), 0x20, interruptPort, resetPort);

return base.Initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public override Task Initialize()
{
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeRising);
IDigitalOutputPort chipSelectPort = Device.CreateDigitalOutputPort(Device.Pins.D01);
IDigitalOutputPort resetPort = Device.CreateDigitalOutputPort(Device.Pins.D02);

mcp = new Mcp23s08(Device.CreateSpiBus(), chipSelectPort, interruptPort);
mcp = new Mcp23s08(Device.CreateSpiBus(), chipSelectPort, interruptPort, resetPort);

return base.Initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public override Task Initialize()
{
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeRising);
IDigitalOutputPort chipSelectPort = Device.CreateDigitalOutputPort(Device.Pins.D01);
IDigitalOutputPort resetPort = Device.CreateDigitalOutputPort(Device.Pins.D02);

mcp = new Mcp23s09(Device.CreateSpiBus(), chipSelectPort, interruptPort);
mcp = new Mcp23s09(Device.CreateSpiBus(), chipSelectPort, interruptPort, resetPort);

return base.Initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public override Task Initialize()
{
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeRising);
IDigitalOutputPort chipSelectPort = Device.CreateDigitalOutputPort(Device.Pins.D01);
IDigitalOutputPort resetPort = Device.CreateDigitalOutputPort(Device.Pins.D02);

mcp = new Mcp23s17(Device.CreateSpiBus(), chipSelectPort, interruptPort);
mcp = new Mcp23s17(Device.CreateSpiBus(), chipSelectPort, interruptPort, resetPort);

return base.Initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public override Task Initialize()
{
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeRising);
IDigitalOutputPort chipSelectPort = Device.CreateDigitalOutputPort(Device.Pins.D01);
IDigitalOutputPort resetPort = Device.CreateDigitalOutputPort(Device.Pins.D02);

mcp = new Mcp23s18(Device.CreateSpiBus(), chipSelectPort, interruptPort);
mcp = new Mcp23s18(Device.CreateSpiBus(), chipSelectPort, interruptPort, resetPort);

return base.Initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ public override Task Initialize()
{
Console.WriteLine("Initializing...");

//we only want to be notified as it goes high
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D02, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown);

// create a new mcp with all the address pins pulled low - address 0x20 (32)
mcp = new Mcp23008(Device.CreateI2cBus(), (byte)Addresses.Address_0x20, interruptPort);

IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown);
IDigitalOutputPort resetPort = Device.CreateDigitalOutputPort(Device.Pins.D01);

// IDigitalOutputPort chipSelectPort = Device.CreateDigitalOutputPort(Device.Pins.D01);
// mcp = new Mcp23s08(Device.CreateSpiBus(), chipSelectPort, interruptPort);
mcp = new Mcp23008(Device.CreateI2cBus(), (byte)Addresses.Address_0x20, interruptPort, resetPort);

return base.Initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@ public override Task Initialize()
{
Console.WriteLine("Initializing...");

//we only want to be notified as it goes high
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D04, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown, TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(1));
IDigitalInputPort interruptPort = Device.CreateDigitalInputPort(Device.Pins.D00, InterruptMode.EdgeBoth, ResistorMode.InternalPullDown);
IDigitalOutputPort resetPort = Device.CreateDigitalOutputPort(Device.Pins.D01);

// create a new mcp with all the address pins pulled low - address 0x20 (32)
mcp = new Mcp23017(Device.CreateI2cBus(), (byte)Addresses.Address_0x20, interruptPort);
mcp = new Mcp23017(Device.CreateI2cBus(), (byte)Addresses.Address_0x20, interruptPort, resetPort);

mcp.InputChanged += Mcp_InputChanged;

// IDigitalOutputPort chipSelectPort = Device.CreateDigitalOutputPort(Device.Pins.D01);
// mcp = new Mcp23s17(Device.CreateSpiBus(), chipSelectPort, interruptPort);

return base.Initialize();
}

Expand Down