moved PCA9655E port commands from initialization list to Wire.write()
This commit is contained in:
parent
5c8890312d
commit
1f6b052a21
@ -1,17 +1,9 @@
|
||||
#include "PortRead_PCA9655E.h"
|
||||
|
||||
/*
|
||||
configures column port's configuration, input, and pins.
|
||||
*/
|
||||
PortRead_PCA9655E::PortRead_PCA9655E (PortIOE& port, const uint8_t readPins)
|
||||
: port(port), readPins(readPins),
|
||||
configurationByteCommand(port.num + 6), inputByteCommand(port.num)
|
||||
{}
|
||||
|
||||
void PortRead_PCA9655E::begin()
|
||||
{
|
||||
Wire.beginTransmission(port.DEVICE_ADDR);
|
||||
Wire.write(configurationByteCommand);
|
||||
Wire.write(port.num + 6); //configuration byte command
|
||||
Wire.write(readPins); //0=configure as output (for LED), 1=configure as input (for read)
|
||||
Wire.endTransmission();
|
||||
}
|
||||
@ -22,10 +14,10 @@ returns port value
|
||||
uint8_t PortRead_PCA9655E::read()
|
||||
{
|
||||
Wire.beginTransmission(port.DEVICE_ADDR);
|
||||
Wire.write(inputByteCommand); //input immediately before requestFrom
|
||||
Wire.write(port.num); //input byte command
|
||||
Wire.endTransmission(false); //PCA9655E needs false to send a restart
|
||||
|
||||
Wire.requestFrom(port.DEVICE_ADDR, 1u); //request one byte from input port
|
||||
Wire.requestFrom(port.DEVICE_ADDR, 1u); //request one byte from input port
|
||||
|
||||
return Wire.read();
|
||||
}
|
||||
|
@ -30,11 +30,9 @@ class PortRead_PCA9655E : public PortReadInterface
|
||||
private:
|
||||
PortIOE& port;
|
||||
const uint8_t readPins; //bitwise pin configuration, 1 means read pin
|
||||
const uint8_t configurationByteCommand;
|
||||
const uint8_t inputByteCommand;
|
||||
public:
|
||||
//The constructor initialization list is in .cpp
|
||||
PortRead_PCA9655E(PortIOE& port, const uint8_t readPins);
|
||||
PortRead_PCA9655E (PortIOE& port, const uint8_t readPins)
|
||||
: port(port), readPins(readPins) {}
|
||||
void begin();
|
||||
virtual uint8_t read();
|
||||
};
|
||||
|
@ -31,6 +31,8 @@ Diode orientation is explained in keybrd_library_user_guide.md > Diode orientati
|
||||
MCP23S17 data sheet
|
||||
----------------
|
||||
http://www.onsemi.com/pub_link/Collateral/MCP23S17-D.PDF
|
||||
|
||||
WARNING: This class hardcodes Slave Select to Arduino Pin 10 to avoid the speed penalty of digitalWrite
|
||||
*/
|
||||
|
||||
class PortWrite_MCP23S17 : public PortWriteInterface
|
||||
|
@ -1,11 +1,5 @@
|
||||
#include "PortWrite_PCA9655E.h"
|
||||
|
||||
/*
|
||||
configures column port's configuration and output.
|
||||
*/
|
||||
PortWrite_PCA9655E::PortWrite_PCA9655E(PortIOE& port)
|
||||
: port(port), configurationByteCommand(port.num + 6), outputByteCommand(port.num + 2) {}
|
||||
|
||||
/*
|
||||
If PortRead_PCA9655E is instantiated on the same port, do NOT use PortWrite_PCA9655E::begin().
|
||||
Otherwise readPins could be overwritten.
|
||||
@ -13,7 +7,7 @@ Otherwise readPins could be overwritten.
|
||||
void PortWrite_PCA9655E::begin()
|
||||
{
|
||||
Wire.beginTransmission(port.DEVICE_ADDR);
|
||||
Wire.write(configurationByteCommand);
|
||||
Wire.write(port.num + 6); //configuration byte command
|
||||
Wire.write(0); //0=configure as output (for strobe pins and LED)
|
||||
Wire.endTransmission();
|
||||
}
|
||||
@ -36,7 +30,7 @@ void PortWrite_PCA9655E::write(const uint8_t pin, const bool value)
|
||||
}
|
||||
|
||||
Wire.beginTransmission(port.DEVICE_ADDR);
|
||||
Wire.write(outputByteCommand);
|
||||
Wire.write(port.num + 2); //output Byte command
|
||||
Wire.write(port.outputVal);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
@ -37,12 +37,8 @@ class PortWrite_PCA9655E : public PortWriteInterface
|
||||
{
|
||||
private:
|
||||
PortIOE& port;
|
||||
const uint8_t configurationByteCommand;
|
||||
const uint8_t outputByteCommand;
|
||||
|
||||
public:
|
||||
//The constructor initialization list is in .cpp
|
||||
PortWrite_PCA9655E(PortIOE& port);
|
||||
PortWrite_PCA9655E(PortIOE& port) : port(port) {}
|
||||
void begin();
|
||||
|
||||
virtual void write(const uint8_t pin, const bool level);
|
||||
|
Reference in New Issue
Block a user