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/PortRead_MCP23S17.h

38 lines
1.2 KiB
C
Raw Normal View History

2016-09-01 02:29:59 +00:00
#ifndef PORTREAD_MCP23S17_H
#define PORTREAD_MCP23S17_H
#include <Arduino.h>
#include <inttypes.h>
#include <SPI.h>
#include <PortRead.h>
#include "PortIOE.h"
/* One MCP23S17 I/O expander port connected to matrix columns.
Instantiation todo
2016-09-01 02:29:59 +00:00
------------
pullUp parameter is port's bitwise pin configuration
2016-09-01 02:29:59 +00:00
1=configure as input (for pins connected to column)
0=configure as output (for LED or not connected to a column)
Example instantiation for column port 0, with pins 2 and 3 connected to columns:
PortIOE port0(0, 0);
PortRead_MCP23S17 colPort0(port0, 2<<0 | 1<<3 );
Example instantiation for column port 1, with pins 2 and 3 connected to columns:
PortIOE port1(1, 0);
PortRead_MCP23S17 colPort1(port1, 2<<0 | 1<<3 );
pullUp are read from pin 0 on up.
2016-09-01 02:29:59 +00:00
*/
class PortRead_MCP23S17 : public PortRead
{
private:
PortIOE& port;
const uint8_t pullUp; //bitwise, 1 means internal pull-up resistor enabled
2016-09-01 02:29:59 +00:00
public:
PortRead_MCP23S17(PortIOE& port, const uint8_t pullUp) : port(port), pullUp(pullUp) {}
void begin();
2016-09-01 02:29:59 +00:00
virtual uint8_t read();
};
#endif