Skip to content

Commit 7fe183a

Browse files
committed
Merge branch 'types'
2 parents bb0ed4f + d2dd8b9 commit 7fe183a

File tree

4 files changed

+196
-143
lines changed

4 files changed

+196
-143
lines changed

examples/PortCopyOnInterrupt/PortCopyOnInterrupt.ino

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ void setup() {
1919
Serial.begin(115200);
2020

2121
mcp.init();
22-
mcp.portMode(0, 0); //Port A as ouput
23-
mcp.portMode(1, 0b11111111);//Port B as input
22+
mcp.portMode(MCP23017_PORT::A, 0); //Port A as ouput
23+
mcp.portMode(MCP23017_PORT::B, 0b11111111);//Port B as input
2424

25-
mcp.interruptMode(OR);
26-
mcp.interrupt(1, FALLING);
25+
mcp.interruptMode(MCP23017_INTMODE::SEPARATED);
26+
mcp.interrupt(MCP23017_PORT::B, FALLING);
2727

28-
mcp.writeRegister(GPIOA, 0x00);
29-
mcp.writeRegister(GPIOB, 0x00);
28+
mcp.writeRegister(MCP23017_REGISTER::GPIOA, 0x00);
29+
mcp.writeRegister(MCP23017_REGISTER::GPIOB, 0x00);
3030

3131
mcp.clearInterrupts();
3232
attachInterrupt(1, userInput, FALLING);
3333
}
3434

3535
void loop() {
36-
byte conf, a, b;
37-
byte captureA, captureB;
38-
byte currentA, currentB;
36+
uint8_t conf, a, b;
37+
uint8_t captureA, captureB;
38+
uint8_t currentA, currentB;
3939

4040
if(!interrupted) return;
4141

@@ -45,10 +45,10 @@ void loop() {
4545

4646
mcp.interruptedBy(a, b);
4747
mcp.clearInterrupts(captureA, captureB);
48-
currentB = mcp.readPort(1);
48+
currentB = mcp.readPort(MCP23017_PORT::B);
4949

5050
if((b & ~currentB) == (b & ~captureB)) {
51-
byte currentA = mcp.readPort(0);
52-
mcp.writeRegister(GPIOA, currentA ^ b);
51+
uint8_t currentA = mcp.readPort(MCP23017_PORT::A);
52+
mcp.writeRegister(MCP23017_REGISTER::GPIOA, currentA ^ b);
5353
}
5454
}

examples/RegistersDumper/RegistersDumper.ino

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,57 @@ void setup() {
88
mcp.init();
99

1010
Serial.begin(115200);
11-
byte conf = mcp.readRegister(IODIRA);
11+
uint8_t conf = mcp.readRegister(MCP23017_REGISTER::IODIRA);
1212
Serial.print("IODIRA : ");
1313
Serial.print(conf, BIN);
1414
Serial.println();
1515

16-
conf = mcp.readRegister(IODIRB);
16+
conf = mcp.readRegister(MCP23017_REGISTER::IODIRB);
1717
Serial.print("IODIRB : ");
1818
Serial.print(conf, BIN);
1919
Serial.println();
2020

21-
conf = mcp.readRegister(IPOLA);
21+
conf = mcp.readRegister(MCP23017_REGISTER::IPOLA);
2222
Serial.print("IPOLA : ");
2323
Serial.print(conf, BIN);
2424
Serial.println();
2525

26-
conf = mcp.readRegister(IPOLB);
26+
conf = mcp.readRegister(MCP23017_REGISTER::IPOLB);
2727
Serial.print("IPOLB : ");
2828
Serial.print(conf, BIN);
2929
Serial.println();
3030

31-
conf = mcp.readRegister(GPINTENA);
31+
conf = mcp.readRegister(MCP23017_REGISTER::GPINTENA);
3232
Serial.print("GPINTENA : ");
3333
Serial.print(conf, BIN);
3434
Serial.println();
3535

36-
conf = mcp.readRegister(GPINTENB);
36+
conf = mcp.readRegister(MCP23017_REGISTER::GPINTENB);
3737
Serial.print("GPINTENB : ");
3838
Serial.print(conf, BIN);
3939
Serial.println();
4040

41-
conf = mcp.readRegister(DEFVALA);
41+
conf = mcp.readRegister(MCP23017_REGISTER::DEFVALA);
4242
Serial.print("DEFVALA : ");
4343
Serial.print(conf, BIN);
4444
Serial.println();
4545

46-
conf = mcp.readRegister(DEFVALB);
46+
conf = mcp.readRegister(MCP23017_REGISTER::DEFVALB);
4747
Serial.print("DEFVALB : ");
4848
Serial.print(conf, BIN);
4949
Serial.println();
5050

51-
conf = mcp.readRegister(INTCONA);
51+
conf = mcp.readRegister(MCP23017_REGISTER::INTCONA);
5252
Serial.print("INTCONA : ");
5353
Serial.print(conf, BIN);
5454
Serial.println();
5555

56-
conf = mcp.readRegister(INTCONB);
56+
conf = mcp.readRegister(MCP23017_REGISTER::INTCONB);
5757
Serial.print("INTCONB : ");
5858
Serial.print(conf, BIN);
5959
Serial.println();
6060

61-
conf = mcp.readRegister(IOCON);
61+
conf = mcp.readRegister(MCP23017_REGISTER::IOCON);
6262
Serial.print("IOCON : ");
6363
Serial.print(conf, BIN);
6464
Serial.println();
@@ -68,52 +68,52 @@ void setup() {
6868
//Serial.print(conf, BIN);
6969
//Serial.println();
7070

71-
conf = mcp.readRegister(GPPUA);
71+
conf = mcp.readRegister(MCP23017_REGISTER::GPPUA);
7272
Serial.print("GPPUA : ");
7373
Serial.print(conf, BIN);
7474
Serial.println();
7575

76-
conf = mcp.readRegister(GPPUB);
76+
conf = mcp.readRegister(MCP23017_REGISTER::GPPUB);
7777
Serial.print("GPPUB : ");
7878
Serial.print(conf, BIN);
7979
Serial.println();
8080

81-
conf = mcp.readRegister(INTFA);
81+
conf = mcp.readRegister(MCP23017_REGISTER::INTFA);
8282
Serial.print("INTFA : ");
8383
Serial.print(conf, BIN);
8484
Serial.println();
8585

86-
conf = mcp.readRegister(INTFB);
86+
conf = mcp.readRegister(MCP23017_REGISTER::INTFB);
8787
Serial.print("INTFB : ");
8888
Serial.print(conf, BIN);
8989
Serial.println();
9090

91-
conf = mcp.readRegister(INTCAPA);
91+
conf = mcp.readRegister(MCP23017_REGISTER::INTCAPA);
9292
Serial.print("INTCAPA : ");
9393
Serial.print(conf, BIN);
9494
Serial.println();
9595

96-
conf = mcp.readRegister(INTCAPB);
96+
conf = mcp.readRegister(MCP23017_REGISTER::INTCAPB);
9797
Serial.print("INTCAPB : ");
9898
Serial.print(conf, BIN);
9999
Serial.println();
100100

101-
conf = mcp.readRegister(GPIOA);
101+
conf = mcp.readRegister(MCP23017_REGISTER::GPIOA);
102102
Serial.print("GPIOA : ");
103103
Serial.print(conf, BIN);
104104
Serial.println();
105105

106-
conf = mcp.readRegister(GPIOB);
106+
conf = mcp.readRegister(MCP23017_REGISTER::GPIOB);
107107
Serial.print("GPIOB : ");
108108
Serial.print(conf, BIN);
109109
Serial.println();
110110

111-
conf = mcp.readRegister(OLATA);
111+
conf = mcp.readRegister(MCP23017_REGISTER::OLATA);
112112
Serial.print("OLATA : ");
113113
Serial.print(conf, BIN);
114114
Serial.println();
115115

116-
conf = mcp.readRegister(OLATB);
116+
conf = mcp.readRegister(MCP23017_REGISTER::OLATB);
117117
Serial.print("OLATB : ");
118118
Serial.print(conf, BIN);
119119
Serial.println();

0 commit comments

Comments
 (0)