Skip to content

Commit c89757e

Browse files
authored
Add files via upload
1 parent c97d94f commit c89757e

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

src/MCP23017.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void MCP23017::setPin(uint8_t pin, mcp_port port, uint8_t pinLevel){
131131
else if(pinLevel==LOW){
132132
gpioA &= ~(1<<pin);
133133
}
134-
writeMCP23017(GPIOA, gpioA);
134+
writeMCP23017(MCP_GPIOA, gpioA);
135135
}
136136
if(port==B){
137137
if(pinLevel==HIGH){
@@ -140,7 +140,7 @@ void MCP23017::setPin(uint8_t pin, mcp_port port, uint8_t pinLevel){
140140
else if(pinLevel==LOW){
141141
gpioB &= ~(1<<pin);
142142
}
143-
writeMCP23017(GPIOB, gpioB);
143+
writeMCP23017(MCP_GPIOB, gpioB);
144144
}
145145
}
146146

@@ -152,7 +152,7 @@ void MCP23017::togglePin(uint8_t pin, mcp_port port){
152152
else if(((gpioA) & (1<<pin)) >= 1){
153153
gpioA &= ~(1<<pin);
154154
}
155-
writeMCP23017(GPIOA, gpioA);
155+
writeMCP23017(MCP_GPIOA, gpioA);
156156
}
157157
if(port==B){
158158
if(((gpioB) & (1<<pin))==0){
@@ -161,7 +161,7 @@ void MCP23017::togglePin(uint8_t pin, mcp_port port){
161161
else if(((gpioB) & (1<<pin)) >= 1){
162162
gpioB &= ~(1<<pin);
163163
}
164-
writeMCP23017(GPIOB, gpioB);
164+
writeMCP23017(MCP_GPIOB, gpioB);
165165
}
166166
}
167167

@@ -188,7 +188,7 @@ void MCP23017::setPinX(uint8_t pin, mcp_port port, uint8_t pinState, uint8_t pin
188188
}
189189
writeMCP23017(GPPUA, gppu);
190190
writeMCP23017(IODIRA, ~ioDirA);
191-
writeMCP23017(GPIOA, gpioA);
191+
writeMCP23017(MCP_GPIOA, gpioA);
192192
}
193193
if(port==B){
194194
if(pinState==OUTPUT){
@@ -211,7 +211,7 @@ void MCP23017::setPinX(uint8_t pin, mcp_port port, uint8_t pinState, uint8_t pin
211211
}
212212
writeMCP23017(GPPUB, gppu);
213213
writeMCP23017(IODIRB, ~ioDirB);
214-
writeMCP23017(GPIOB, gpioB);
214+
writeMCP23017(MCP_GPIOB, gpioB);
215215
}
216216
}
217217

@@ -223,7 +223,7 @@ void MCP23017::setAllPins(mcp_port port, uint8_t pinLevel){
223223
else if (pinLevel==LOW){
224224
gpioA = 0b00000000;
225225
}
226-
writeMCP23017(GPIOA, gpioA);
226+
writeMCP23017(MCP_GPIOA, gpioA);
227227
}
228228
if(port==B){
229229
if(pinLevel==HIGH){
@@ -232,39 +232,39 @@ void MCP23017::setAllPins(mcp_port port, uint8_t pinLevel){
232232
else if (pinLevel==LOW){
233233
gpioB = 0b00000000;
234234
}
235-
writeMCP23017(GPIOB, gpioB);
235+
writeMCP23017(MCP_GPIOB, gpioB);
236236
}
237237
}
238238

239239
void MCP23017::setPort(uint8_t portLevel, mcp_port port){
240240
if(port==A){
241241
gpioA = portLevel;
242-
writeMCP23017(GPIOA, gpioA);
242+
writeMCP23017(MCP_GPIOA, gpioA);
243243
}
244244
else if(port==B){
245245
gpioB = portLevel;
246-
writeMCP23017(GPIOB, gpioB);
246+
writeMCP23017(MCP_GPIOB, gpioB);
247247
}
248248
}
249249

250250
void MCP23017::setPort(uint8_t portLevelA, uint8_t portLevelB){
251251
gpioA = portLevelA;
252252
gpioB = portLevelB;
253-
writeMCP23017(GPIOA, gpioA, gpioB);
253+
writeMCP23017(MCP_GPIOA, gpioA, gpioB);
254254
}
255255

256256
void MCP23017::setPortX(uint8_t portState, uint8_t portLevel, mcp_port port){
257257
if(port==A){
258258
ioDirA = portState;
259259
gpioA = portLevel;
260260
writeMCP23017(IODIRA, ~ioDirA);
261-
writeMCP23017(GPIOA, gpioA);
261+
writeMCP23017(MCP_GPIOA, gpioA);
262262
}
263263
else if(port==B){
264264
ioDirB = portState;
265265
gpioB = portLevel;
266266
writeMCP23017(IODIRB, ~ioDirB);
267-
writeMCP23017(GPIOB, gpioB);
267+
writeMCP23017(MCP_GPIOB, gpioB);
268268
}
269269
}
270270

@@ -304,14 +304,14 @@ void MCP23017::setInterruptOnChangePin(uint8_t pin, mcp_port port){
304304
ioDirA &= ~(1<<pin);
305305
gpIntEn |= (1<<pin);
306306
writeMCP23017(IODIRA, ~ioDirA);
307-
writeMCP23017(GPIOA, gpioA);
307+
writeMCP23017(MCP_GPIOA, gpioA);
308308
writeMCP23017(GPINTENA, gpIntEn);
309309
}
310310
else if (port==B){
311311
ioDirB &= ~(1<<pin);
312312
gpIntEn |= (1<<pin);
313313
writeMCP23017(IODIRB, ~ioDirB);
314-
writeMCP23017(GPIOB, gpioB);
314+
writeMCP23017(MCP_GPIOB, gpioB);
315315
writeMCP23017(GPINTENB, gpIntEn);
316316
}
317317
}
@@ -327,7 +327,7 @@ void MCP23017::setInterruptOnDefValDevPin(uint8_t pin, mcp_port port, uint8_t pi
327327
if(pinIntLevel==HIGH) defVal |= (1<<pin);
328328
else if(pinIntLevel==LOW) defVal &= ~(1<<pin);
329329
writeMCP23017(IODIRA, ~ioDirA);
330-
writeMCP23017(GPIOA, gpioA);
330+
writeMCP23017(MCP_GPIOA, gpioA);
331331
writeMCP23017(GPINTENA, gpIntEn);
332332
writeMCP23017(INTCONA, intCon);
333333
writeMCP23017(DEFVALA, defVal);
@@ -339,7 +339,7 @@ void MCP23017::setInterruptOnDefValDevPin(uint8_t pin, mcp_port port, uint8_t pi
339339
if(pinIntLevel==HIGH) defVal |= (1<<pin);
340340
else if(pinIntLevel==LOW) defVal &= ~(1<<pin);
341341
writeMCP23017(IODIRB, ~ioDirB);
342-
writeMCP23017(GPIOB, gpioB);
342+
writeMCP23017(MCP_GPIOB, gpioB);
343343
writeMCP23017(GPINTENB, gpIntEn);
344344
writeMCP23017(INTCONB, intCon);
345345
writeMCP23017(DEFVALB, defVal);
@@ -458,10 +458,10 @@ uint8_t MCP23017::getIntFlag(mcp_port port){
458458
bool MCP23017::getPin(uint8_t pin, mcp_port port){
459459
uint8_t result = 0;
460460
if(port==A){
461-
result = readMCP23017(GPIOA);
461+
result = readMCP23017(MCP_GPIOA);
462462
}
463463
else if(port==B){
464-
result = readMCP23017(GPIOB);
464+
result = readMCP23017(MCP_GPIOB);
465465
}
466466
result &= (1<<pin);
467467
if(result) return true;
@@ -471,10 +471,10 @@ bool MCP23017::getPin(uint8_t pin, mcp_port port){
471471
uint8_t MCP23017::getPort(mcp_port port){
472472
uint8_t value = 0;
473473
if(port==A){
474-
value = readMCP23017(GPIOA);
474+
value = readMCP23017(MCP_GPIOA);
475475
}
476476
else if(port==B){
477-
value = readMCP23017(GPIOB);
477+
value = readMCP23017(MCP_GPIOB);
478478
}
479479
return value;
480480
}
@@ -613,11 +613,11 @@ void MCP23017::printAllRegisters(){
613613
Serial.print(buf); printBin(regVal);
614614

615615
regVal = readMCP23017(reg); reg++;
616-
sprintf(buf, "GPIOA : 0x%02X | 0b", regVal);
616+
sprintf(buf, "MCP_GPIOA : 0x%02X | 0b", regVal);
617617
Serial.print(buf); printBin(regVal);
618618

619619
regVal = readMCP23017(reg); reg++;
620-
sprintf(buf, "GPIOB : 0x%02X | 0b", regVal);
620+
sprintf(buf, "MCP_GPIOB : 0x%02X | 0b", regVal);
621621
Serial.print(buf); printBin(regVal);
622622

623623
regVal = readMCP23017(reg); reg++;

src/MCP23017.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,29 @@ typedef enum MCP_ENABLE {OFF, ON} mcp_enable;
4242
class MCP23017{
4343
public:
4444
/* Registers */
45-
static constexpr uint8_t IODIRA {0x00};
46-
static constexpr uint8_t IODIRB {0x01};
47-
static constexpr uint8_t IOCONA {0x0A};
48-
static constexpr uint8_t IOCONB {0x0B};
49-
static constexpr uint8_t INTCAPA {0x10};
50-
static constexpr uint8_t INTCAPB {0x11};
51-
static constexpr uint8_t INTCONA {0x08};
52-
static constexpr uint8_t INTCONB {0x09};
53-
static constexpr uint8_t INTFA {0x0E};
54-
static constexpr uint8_t INTFB {0x0F};
55-
static constexpr uint8_t GPINTENA{0x04};
56-
static constexpr uint8_t GPINTENB{0x05};
57-
static constexpr uint8_t DEFVALA {0x06};
58-
static constexpr uint8_t DEFVALB {0x07};
59-
static constexpr uint8_t IPOLA {0x02};
60-
static constexpr uint8_t GPIOA {0x12};
61-
static constexpr uint8_t GPIOB {0x13};
62-
static constexpr uint8_t INTPOL {0x01};
63-
static constexpr uint8_t INTODR {0x02};
64-
static constexpr uint8_t MIRROR {0x06};
65-
static constexpr uint8_t GPPUA {0x0C};
66-
static constexpr uint8_t GPPUB {0x0D};
67-
static constexpr uint8_t SPI_READ{0x01};
45+
static constexpr uint8_t IODIRA {0x00};
46+
static constexpr uint8_t IODIRB {0x01};
47+
static constexpr uint8_t IOCONA {0x0A};
48+
static constexpr uint8_t IOCONB {0x0B};
49+
static constexpr uint8_t INTCAPA {0x10};
50+
static constexpr uint8_t INTCAPB {0x11};
51+
static constexpr uint8_t INTCONA {0x08};
52+
static constexpr uint8_t INTCONB {0x09};
53+
static constexpr uint8_t INTFA {0x0E};
54+
static constexpr uint8_t INTFB {0x0F};
55+
static constexpr uint8_t GPINTENA {0x04};
56+
static constexpr uint8_t GPINTENB {0x05};
57+
static constexpr uint8_t DEFVALA {0x06};
58+
static constexpr uint8_t DEFVALB {0x07};
59+
static constexpr uint8_t IPOLA {0x02};
60+
static constexpr uint8_t MCP_GPIOA{0x12};
61+
static constexpr uint8_t MCP_GPIOB{0x13};
62+
static constexpr uint8_t INTPOL {0x01};
63+
static constexpr uint8_t INTODR {0x02};
64+
static constexpr uint8_t MIRROR {0x06};
65+
static constexpr uint8_t GPPUA {0x0C};
66+
static constexpr uint8_t GPPUB {0x0D};
67+
static constexpr uint8_t SPI_READ {0x01};
6868

6969
/* constructors */
7070
#ifndef USE_TINY_WIRE_M_

0 commit comments

Comments
 (0)