Forked from romilly. Changed the way SPI handler is injected in constructor
Fork of MCP23S17 by
Diff: MCP23S17.h
- Revision:
- 8:841b19734955
- Parent:
- 7:53498e24592c
- Child:
- 9:068b1e8909bb
--- a/MCP23S17.h Sun Aug 22 15:37:25 2010 +0000 +++ b/MCP23S17.h Mon Aug 23 10:57:59 2010 +0000 @@ -2,7 +2,7 @@ * Copyright (c) 2010 Romilly Cocking * Released under the MIT License: http://mbed.org/license/mit * -* version 0.2 +* version 0.3 */ #include "mbed.h" @@ -33,27 +33,26 @@ #define IOCON_HAEN 0x08 // Hardware address enable enum Polarity { ACTIVE_LOW , ACTIVE_HIGH }; +enum Port { PORT_A, PORT_B }; class MCP23S17 { public: MCP23S17(SPI& spi, PinName ncs, char writeOpcode); - void directionA(char direction); - void directionB(char direction); - void interruptEnableA(char interruptsEnabledMask); - void interruptEnableB(char interruptsEnabledMask); + void direction(Port port, char direction); + void interruptEnable(Port port, char interruptsEnabledMask); void interruptPolarity(Polarity polarity); void mirrorInterrupts(bool mirror); - void defaultValueA(char valuesToCompare); - void interruptControlA(char interruptContolBits); - char inputA(); - char inputB(); - void outputA(char byte); - void outputB(char byte); + void defaultValue(Port port, char valuesToCompare); + void interruptControl(Port port, char interruptContolBits); + char read(Port port); + void write(Port port, char byte); protected: SPI& _spi; DigitalOut _ncs; void _init(); + void _write(Port port, char address, char data); void _write(char address, char data); + char _read(Port port, char address); char _read(char address); char _readOpcode; char _writeOpcode;