Updated memory address #defines to avoid clashes with other libraries and f411re board defines
Revision 2:69ce30406dc8, committed 2015-05-14
- Comitter:
- dave93cab
- Date:
- Thu May 14 21:04:13 2015 +0000
- Parent:
- 1:f93b811965d8
- Commit message:
- renamed memory address #defines to avoid clashes with other libraries and f411re board
Changed in this revision
MCP23S17.cpp | Show annotated file Show diff for this revision Revisions of this file |
MCP23S17.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r f93b811965d8 -r 69ce30406dc8 MCP23S17.cpp --- a/MCP23S17.cpp Sun Jan 29 19:11:42 2012 +0000 +++ b/MCP23S17.cpp Thu May 14 21:04:13 2015 +0000 @@ -36,12 +36,12 @@ char MCP23S17::read(Port port) { - return _read(port, GPIOA); + return _read(port, MCP23S17_INTCAPA ); } void MCP23S17::write(Port port, char data) { - _write(port, OLATA, data); + _write(port, MCP23S17_OLATA, data); } void MCP23S17::reset() @@ -59,37 +59,37 @@ void MCP23S17::config_control_register(char data) { - _write(IOCON, data); + _write(MCP23S17_IOCON, data); } void MCP23S17::config_pullups(Port port, char data) { - _write(port, GPPUA, data); + _write(port, MCP23S17_GPPUA, data); } void MCP23S17::config_direction(Port port, char data) { - _write(port, IODIRA, data); + _write(port, MCP23S17_IODIRA, data); } void MCP23S17::config_polarity(Port port, char data) { - _write(port, IPOLA, data); + _write(port, MCP23S17_IPOLA, data); } void MCP23S17::config_interrupt_enable(Port port, char data) { - _write(port, GPINTENA, data); + _write(port, MCP23S17_GPINTENA, data); } void MCP23S17::config_interrupt_control(Port port, char data) { - _write(port, INTCONA, data); + _write(port, MCP23S17_INTCONA , data); } void MCP23S17::config_mirror_interrupt(bool mirror) { - char kopi_iocon = _read(IOCON); + char kopi_iocon = _read(MCP23S17_IOCON); if (mirror) { kopi_iocon = kopi_iocon | INTERRUPT_MIRROR_BIT; @@ -98,17 +98,17 @@ { kopi_iocon = kopi_iocon & ~INTERRUPT_MIRROR_BIT; } - _write(IOCON, kopi_iocon); + _write(MCP23S17_IOCON, kopi_iocon); } void MCP23S17::config_defaultvalue(Port port, char data) { - _write(port, DEFVALA, data); + _write(port, MCP23S17_DEFVALA, data); } void MCP23S17::config_interrupt_polarity(Polarity polarity) { - char kopi_iocon = _read(IOCON); + char kopi_iocon = _read(MCP23S17_IOCON); if (polarity == ACTIVE_LOW) { kopi_iocon = kopi_iocon | INTERRUPT_POLARITY_BIT; @@ -117,17 +117,17 @@ { kopi_iocon = kopi_iocon & ~INTERRUPT_POLARITY_BIT; } - _write(IOCON, kopi_iocon); + _write(MCP23S17_IOCON, kopi_iocon); } char MCP23S17::read_interrupt_flag(Port port) { - return _read(port, INTFA); + return _read(port, MCP23S17_INTFA); } char MCP23S17::read_interrupt_capture(Port port) { - return _read(port, INTCAPA); + return _read(port, MCP23S17_INTCAPA ); } //============================================================================= @@ -136,7 +136,7 @@ void MCP23S17::_initialization() { - _write(IOCON, 0x2A); // setup af control register (BANK = 0, MIRROR = 0, SEQOP = 1, DISSLW = 0, HAEN = 1, ODR = 0, INTPOL = 1, NC = 0) + _write(MCP23S17_IOCON, 0x2A); // setup af control register (BANK = 0, MIRROR = 0, SEQOP = 1, DISSLW = 0, HAEN = 1, ODR = 0, INTPOL = 1, NC = 0) } void MCP23S17::_make_opcode(int _hardwareaddress)
diff -r f93b811965d8 -r 69ce30406dc8 MCP23S17.h --- a/MCP23S17.h Sun Jan 29 19:11:42 2012 +0000 +++ b/MCP23S17.h Thu May 14 21:04:13 2015 +0000 @@ -29,27 +29,27 @@ // All Registers and there Address if BANK = 0 //============================================================================= -#define IODIRA 0x00 // Controls the direction of the data I/O on Port A -#define IODIRB 0x01 // Controls the direction of the data I/O on Port B -#define IPOLA 0x02 // Configure the polarity on the corresponding GPIO (Port A) -#define IPOLB 0x03 // Configure the polarity on the corresponding GPIO (Port B) -#define GPINTENA 0x04 // Controls the interrupt-on change feature for each pin for Port A -#define GPINTENB 0x05 // Controls the interrupt-on change feature for each pin for Port B -#define DEFVALA 0x06 // The default comparison value if the INTCONA is set to "1" for Port A -#define DEFVALB 0x07 // The default comparison value if the INTCONA is set to "1" for Port B -#define INTCONA 0x08 // Controls how the associated pin value is compared for the interrupt-on-change feature for Port A -#define INTCONB 0x09 // Controls how the associated pin value is compared for the interrupt-on-change feature for Port B -#define IOCON 0x0A // Contains several bits for configuring the device -#define GPPUA 0x0C // Controls the pull-up resistors for the port pins for port A -#define GPPUB 0x0D // Controls the pull-up resistors for the port pins for port B -#define INTFA 0x0E // READ ONLY // reflects the interrupt condition on port A pins of any pin that is enabled for interrupts via the GPINTEN register. -#define INTFB 0x0F // READ ONLY // reflects the interrupt condition on port B pins of any pin that is enabled for interrupts via the GPINTEN register. -#define INTCAPA 0x10 // READ ONLY // captures the GPIO port A value at the time the interrupt occurred -#define INTCAPB 0x11 // READ ONLY // captures the GPIO port B value at the time the interrupt occurred -#define GPIOA 0x12 // Reflects the value on the port A (doing write function it only read input) -#define GPIOB 0x13 // Reflects the value on the port B (doing write function it only read input) -#define OLATA 0x14 // A write to this register modifies the output latches that modifies the pins configured as outputs for Port A -#define OLATB 0x15 // A write to this register modifies the output latches that modifies the pins configured as outputs for Port B +#define MCP23S17_IODIRA 0x00 // Controls the direction of the data I/O on Port A +#define MCP23S17_IODIRB 0x01 // Controls the direction of the data I/O on Port B +#define MCP23S17_IPOLA 0x02 // Configure the polarity on the corresponding GPIO (Port A) +#define MCP23S17_IPOLB 0x03 // Configure the polarity on the corresponding GPIO (Port B) +#define MCP23S17_GPINTENA 0x04 // Controls the interrupt-on change feature for each pin for Port A +#define MCP23S17_GPINTENB 0x05 // Controls the interrupt-on change feature for each pin for Port B +#define MCP23S17_DEFVALA 0x06 // The default comparison value if the INTCONA is set to "1" for Port A +#define MCP23S17_DEFVALB 0x07 // The default comparison value if the INTCONA is set to "1" for Port B +#define MCP23S17_INTCONA 0x08 // Controls how the associated pin value is compared for the interrupt-on-change feature for Port A +#define MCP23S17_INTCONB 0x09 // Controls how the associated pin value is compared for the interrupt-on-change feature for Port B +#define MCP23S17_IOCON 0x0A // Contains several bits for configuring the device +#define MCP23S17_GPPUA 0x0C // Controls the pull-up resistors for the port pins for port A +#define MCP23S17_GPPUB 0x0D // Controls the pull-up resistors for the port pins for port B +#define MCP23S17_INTFA 0x0E // READ ONLY // reflects the interrupt condition on port A pins of any pin that is enabled for interrupts via the GPINTEN register. +#define MCP23S17_INTFB 0x0F // READ ONLY // reflects the interrupt condition on port B pins of any pin that is enabled for interrupts via the GPINTEN register. +#define MCP23S17_INTCAPA 0x10 // READ ONLY // captures the GPIO port A value at the time the interrupt occurred +#define MCP23S17_INTCAPB 0x11 // READ ONLY // captures the GPIO port B value at the time the interrupt occurred +#define MCP23S17_GPIOA 0x12 // Reflects the value on the port A (doing write function it only read input) +#define MCP23S17_GPIOB 0x13 // Reflects the value on the port B (doing write function it only read input) +#define MCP23S17_OLATA 0x14 // A write to this register modifies the output latches that modifies the pins configured as outputs for Port A +#define MCP23S17_OLATB 0x15 // A write to this register modifies the output latches that modifies the pins configured as outputs for Port B //============================================================================= // Declaration of variables & custom #defines