Browse Source

rename PortPCA9655E to Port_PCA9655E, and PortMCP23S17 to Port_MCP23S17

tags/v0.6.0
wolfv6 7 years ago
parent
commit
11cfc46390

+ 5
- 8
doc/keybrd_library_developer_guide.md View File

@@ -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

src/PortMCP23S17.cpp → src/Port_MCP23S17.cpp View File

@@ -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
}

src/PortMCP23S17.h → src/Port_MCP23S17.h View File

@@ -1,5 +1,5 @@
#ifndef PORTMCP23S17_H
#define PORTMCP23S17_H
#ifndef PORT_MCP23S17_H
#define PORT_MCP23S17_H
#include <Arduino.h>
#include <inttypes.h>
#include <SPI.h>
@@ -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);

src/PortPCA9655E.cpp → src/Port_PCA9655E.cpp View File

@@ -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

src/PortPCA9655E.h → src/Port_PCA9655E.h View File

@@ -1,5 +1,5 @@
#ifndef PORTPCA9655E_H
#define PORTPCA9655E_H
#ifndef PORT_PCA9655E_H
#define PORT_PCA9655E_H
#include <Arduino.h>
#include <inttypes.h>
#include <Wire.h>
@@ -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);