Archived
1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
keybrd/src/PortMCP23S17.cpp

17 lines
696 B
C++
Raw Normal View History

#include "PortMCP23S17.h"
/* transfer() writes data to registerAddr, reads portSate from registerAddr, and returns portState.
*/
uint8_t PortMCP23S17::transfer(const uint8_t command, const uint8_t registerAddr, const uint8_t data)
{
uint8_t portState; //bit pattern
digitalWrite(SS, LOW); //enable Slave Select
2016-09-12 06:28:27 +00:00
SPI.transfer(command); //write or read command
SPI.transfer(registerAddr); //register address to write data to
portState = SPI.transfer(data); //write data, read portState
digitalWrite(SS, HIGH); //disable Slave Select
return portState;
}