From 11cfc46390a38525468bc35158cb553c4e226332 Mon Sep 17 00:00:00 2001 From: wolfv6 Date: Sat, 24 Sep 2016 21:03:08 -0600 Subject: [PATCH] rename PortPCA9655E to Port_PCA9655E, and PortMCP23S17 to Port_MCP23S17 --- doc/keybrd_library_developer_guide.md | 13 +++++-------- src/{PortMCP23S17.cpp => Port_MCP23S17.cpp} | 12 ++++++------ src/{PortMCP23S17.h => Port_MCP23S17.h} | 10 +++++----- src/{PortPCA9655E.cpp => Port_PCA9655E.cpp} | 10 +++++----- src/{PortPCA9655E.h => Port_PCA9655E.h} | 12 ++++++------ 5 files changed, 27 insertions(+), 30 deletions(-) rename src/{PortMCP23S17.cpp => Port_MCP23S17.cpp} (89%) rename src/{PortMCP23S17.h => Port_MCP23S17.h} (89%) rename src/{PortPCA9655E.cpp => Port_PCA9655E.cpp} (87%) rename src/{PortPCA9655E.h => Port_PCA9655E.h} (81%) diff --git a/doc/keybrd_library_developer_guide.md b/doc/keybrd_library_developer_guide.md index 2b8b518..dd3f158 100644 --- a/doc/keybrd_library_developer_guide.md +++ b/doc/keybrd_library_developer_guide.md @@ -26,17 +26,14 @@ Keybrd library class inheritance diagram PortIOE - PortWriteInterface - / \ - PortWrite_PCA9655E PortWrite_MCP23S17 (one PortWrite class for each IOE type) + PortInterface + / \ + Port_PCA9655E Port_MCP23S17 (one Port class for each IOE type) - PortReadInterface - / \ - PortRead_PCA9655E PortRead_MCP23S17 (one PortRead class for each IOE type) - _ LED _ + LEDInterface / \ - LED_uC LED_PCA9655E + LED_uC LED_IOE DebouncerInterface diff --git a/src/PortMCP23S17.cpp b/src/Port_MCP23S17.cpp similarity index 89% rename from src/PortMCP23S17.cpp rename to src/Port_MCP23S17.cpp index 3ef7197..541c259 100644 --- a/src/PortMCP23S17.cpp +++ b/src/Port_MCP23S17.cpp @@ -1,4 +1,4 @@ -#include "PortMCP23S17.h" +#include "Port_MCP23S17.h" /* transfer() writes data to registerAddr, reads portSate from registerAddr, and returns portState. @@ -6,7 +6,7 @@ MCP23S17 SPI interface is 10 MHz max. The electrical limitation to bus speed is bus capacitance and the length of the wires involved. Longer wires require lower clock speeds. */ -uint8_t PortMCP23S17::transfer(const uint8_t command, const uint8_t registerAddr, +uint8_t Port_MCP23S17::transfer(const uint8_t command, const uint8_t registerAddr, const uint8_t data) { uint8_t portState; //bit pattern @@ -24,7 +24,7 @@ uint8_t PortMCP23S17::transfer(const uint8_t command, const uint8_t registerAddr /* begin() is called from Scanner_IOE::begin(). Initiates SPI bus. */ -void PortMCP23S17::beginProtocol() +void Port_MCP23S17::beginProtocol() { pinMode(SS, OUTPUT); //configure controller's Slave Select pin to output digitalWrite(SS, HIGH); //disable Slave Select @@ -35,7 +35,7 @@ void PortMCP23S17::beginProtocol() strobeOn is logic level of strobe on, HIGH or LOW configure IODIR and GPPU. */ -void PortMCP23S17::begin(const uint8_t strobeOn) +void Port_MCP23S17::begin(const uint8_t strobeOn) { uint8_t pullUp; //bits, GPPU 0=pull-up disabled, 1=pull-up enabled @@ -57,7 +57,7 @@ pin is bit pattern, where pin being set is 1. logicLevel is HIGH or LOW. write() does not overwrite the other pins. */ -void PortMCP23S17::write(const uint8_t pin, const bool logicLevel) +void Port_MCP23S17::write(const uint8_t pin, const bool logicLevel) { if (logicLevel == LOW) { @@ -73,7 +73,7 @@ void PortMCP23S17::write(const uint8_t pin, const bool logicLevel) /* read() returns portState. Only portState pins with pull resistors are valid. */ -uint8_t PortMCP23S17::read() +uint8_t Port_MCP23S17::read() { return transfer( (deviceAddr << 1) | 1, portNum + 0x12, 0); //read from GPIO } diff --git a/src/PortMCP23S17.h b/src/Port_MCP23S17.h similarity index 89% rename from src/PortMCP23S17.h rename to src/Port_MCP23S17.h index 3b1467e..d0ab22d 100644 --- a/src/PortMCP23S17.h +++ b/src/Port_MCP23S17.h @@ -1,5 +1,5 @@ -#ifndef PORTMCP23S17_H -#define PORTMCP23S17_H +#ifndef PORT_MCP23S17_H +#define PORT_MCP23S17_H #include #include #include @@ -14,7 +14,7 @@ Arduino Pin 10 avoids the speed penalty of digitalWrite. Instantiation ------------ -MCP23S17 datasheet identifies ports by letters, while class PortMCP23S17 uses portNum +MCP23S17 datasheet identifies ports by letters, while class Port_MCP23S17 uses portNum for port A, use portNum=0 for port B, use portNum=1 readPins parameter configures port's pins. @@ -33,7 +33,7 @@ MCP23S17 data sheet ------------------ http://www.onsemi.com/pub_link/Collateral/MCP23S17-D.PDF */ -class PortMCP23S17 : public PortInterface +class Port_MCP23S17 : public PortInterface { private: const uint8_t deviceAddr; @@ -42,7 +42,7 @@ class PortMCP23S17 : public PortInterface const uint8_t readPins; //bit pattern, IODIR 0=output, 1=input uint8_t transfer(const uint8_t command, const uint8_t registerAddr, const uint8_t data); public: - PortMCP23S17(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins) + Port_MCP23S17(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins) : deviceAddr(deviceAddr), portNum(portNum), outputVal(0), readPins(readPins) {} void beginProtocol(); void begin(const uint8_t strobeOn); diff --git a/src/PortPCA9655E.cpp b/src/Port_PCA9655E.cpp similarity index 87% rename from src/PortPCA9655E.cpp rename to src/Port_PCA9655E.cpp index 48bd5fe..053c7bb 100644 --- a/src/PortPCA9655E.cpp +++ b/src/Port_PCA9655E.cpp @@ -1,4 +1,4 @@ -#include "PortPCA9655E.h" +#include "Port_PCA9655E.h" /* begin() is called from Scanner_IOE::begin(). Initiates I2C bus. @@ -7,7 +7,7 @@ The electrical limitation to bus speed is bus capacitance and the length of the Longer wires require lower clock speeds. http://playground.arduino.cc/Main/WireLibraryDetailedReference > Wire.setclock() */ -void PortPCA9655E::beginProtocol() +void Port_PCA9655E::beginProtocol() { Wire.begin(); //initiate I2C bus to 100 kHz //Wire.setClock(400000L); //set I2C bus to 400 kHz (have not tested 400 kHz) @@ -17,7 +17,7 @@ void PortPCA9655E::beginProtocol() Configures read pins to input. strobeOn is not used because PCA9655E has no pull-up resistors. */ -void PortPCA9655E::begin(const uint8_t strobeOn) +void Port_PCA9655E::begin(const uint8_t strobeOn) { Wire.beginTransmission(deviceAddr); Wire.write(portNum + 6); //configuration byte command @@ -30,7 +30,7 @@ pin is bit pattern, where pin being strobed is 1. logicLevel is HIGH or LOW. write() does not overwrite the other pins. */ -void PortPCA9655E::write(const uint8_t pin, const bool logicLevel) +void Port_PCA9655E::write(const uint8_t pin, const bool logicLevel) { if (logicLevel == LOW) { @@ -50,7 +50,7 @@ void PortPCA9655E::write(const uint8_t pin, const bool logicLevel) /* read() returns portState. Only portState bits of readPins are valid. */ -uint8_t PortPCA9655E::read() +uint8_t Port_PCA9655E::read() { Wire.beginTransmission(deviceAddr); Wire.write(portNum); //input byte command diff --git a/src/PortPCA9655E.h b/src/Port_PCA9655E.h similarity index 81% rename from src/PortPCA9655E.h rename to src/Port_PCA9655E.h index ae133bb..4a05242 100644 --- a/src/PortPCA9655E.h +++ b/src/Port_PCA9655E.h @@ -1,5 +1,5 @@ -#ifndef PORTPCA9655E_H -#define PORTPCA9655E_H +#ifndef PORT_PCA9655E_H +#define PORT_PCA9655E_H #include #include #include @@ -21,8 +21,8 @@ Instantiation ------------ Example instantiation: const uint8_t IOE_ADDR = 0x20; //PCA9655E address, all 3 ADDR pins are grounded - PortPCA9655E portB(IOE_ADDR, 1, 0); //all pins are set to output for strobes and LEDs - PortPCA9655E portA(IOE_ADDR, 0, 1<<0 | 1<<1 ); //first two pins are set to input for reading, + Port_PCA9655E portB(IOE_ADDR, 1, 0); //all pins are set to output for strobes and LEDs + Port_PCA9655E portA(IOE_ADDR, 0, 1<<0 | 1<<1 ); //first two pins are set to input for reading, //remaining pins can be used for LEDs Diode orientation @@ -34,7 +34,7 @@ PCA9655E data sheet http://www.onsemi.com/pub_link/Collateral/PCA9655E-D.PDF */ -class PortPCA9655E : public PortInterface +class Port_PCA9655E : public PortInterface { private: const uint8_t deviceAddr; @@ -42,7 +42,7 @@ class PortPCA9655E : public PortInterface uint8_t outputVal; //bit pattern for strobe and LEDs const uint8_t readPins; //bit pattern, IODIR 0=output, 1=input public: - PortPCA9655E(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins) + Port_PCA9655E(const uint8_t deviceAddr, const uint8_t portNum, const uint8_t readPins) : deviceAddr(deviceAddr), portNum(portNum), outputVal(0), readPins(readPins) {} void beginProtocol(); void begin(const uint8_t strobeOn);