2016-07-14 04:16:18 +00:00
|
|
|
#include "PortRead_PCA9655E.h"
|
2016-05-09 14:05:08 +00:00
|
|
|
|
2016-09-11 21:23:47 +00:00
|
|
|
/* begin() is called from Scanner_IOE::begin().
|
2016-09-12 06:28:27 +00:00
|
|
|
Configures read pins to input.
|
2016-09-11 15:54:10 +00:00
|
|
|
*/
|
|
|
|
void PortRead_PCA9655E::begin(const uint8_t strobeOn)
|
2016-05-09 14:05:08 +00:00
|
|
|
{
|
2016-09-03 20:25:22 +00:00
|
|
|
Wire.beginTransmission(port.DEVICE_ADDR);
|
2016-09-03 23:22:55 +00:00
|
|
|
Wire.write(port.num + 6); //configuration byte command
|
2016-09-11 21:23:47 +00:00
|
|
|
Wire.write(readPins); //0=output (for LED), 1=input (for read)
|
2016-05-09 14:05:08 +00:00
|
|
|
Wire.endTransmission();
|
|
|
|
}
|
|
|
|
|
2016-09-11 21:23:47 +00:00
|
|
|
/* read() returns portState.
|
|
|
|
Only portState bits of readPins are valid.
|
2016-05-09 14:05:08 +00:00
|
|
|
*/
|
2016-07-14 04:16:18 +00:00
|
|
|
uint8_t PortRead_PCA9655E::read()
|
2016-05-09 14:05:08 +00:00
|
|
|
{
|
2016-09-03 20:25:22 +00:00
|
|
|
Wire.beginTransmission(port.DEVICE_ADDR);
|
2016-09-03 23:22:55 +00:00
|
|
|
Wire.write(port.num); //input byte command
|
2016-05-09 14:05:08 +00:00
|
|
|
Wire.endTransmission(false); //PCA9655E needs false to send a restart
|
|
|
|
|
2016-09-03 23:22:55 +00:00
|
|
|
Wire.requestFrom(port.DEVICE_ADDR, 1u); //request one byte from input port
|
2016-05-09 14:05:08 +00:00
|
|
|
|
2016-07-13 13:17:35 +00:00
|
|
|
return Wire.read();
|
2016-05-09 14:05:08 +00:00
|
|
|
}
|