MCP23S17 Bufferd

Committer:
ryood
Date:
Fri Nov 04 23:16:41 2016 +0000
Revision:
6:cc3b65d44e9e
Parent:
0:54debc783452
Add: Test ExioBufferedPinDetect

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ryood 0:54debc783452 1 /*
ryood 0:54debc783452 2 * ExioMcp23s17.h
ryood 0:54debc783452 3 * Rapper Class for MCP23S17
ryood 0:54debc783452 4 *
ryood 0:54debc783452 5 * Use MCP23S17 Library:
ryood 0:54debc783452 6 * https://developer.mbed.org/users/stjo2809/code/MCP23S17/
ryood 0:54debc783452 7 *
ryood 0:54debc783452 8 * 割込み処理は未実装
ryood 0:54debc783452 9 *
ryood 0:54debc783452 10 * Created: 2016.10.30
ryood 0:54debc783452 11 *
ryood 0:54debc783452 12 */
ryood 0:54debc783452 13
ryood 0:54debc783452 14 #ifndef _EXIOMCP23S17_H_
ryood 0:54debc783452 15 #define _EXIOMCP23S17_H_
ryood 0:54debc783452 16
ryood 0:54debc783452 17 #include "mbed.h"
ryood 0:54debc783452 18 #include "MCP23S17.h"
ryood 0:54debc783452 19
ryood 0:54debc783452 20 typedef enum { ExioPortA, ExioPortB } ExioPort;
ryood 0:54debc783452 21
ryood 0:54debc783452 22 class ExioMcp23s17 : public MCP23S17 {
ryood 0:54debc783452 23 public:
ryood 0:54debc783452 24 ExioMcp23s17(int hardwareaddress, SPI& spi, PinName nCs, PinName nReset) :
ryood 0:54debc783452 25 MCP23S17(hardwareaddress, spi, nCs, nReset) {}
ryood 0:54debc783452 26
ryood 0:54debc783452 27 ExioMcp23s17(int hardwareaddress, SPI& spi, PinName nCs) :
ryood 0:54debc783452 28 MCP23S17(hardwareaddress, spi, nCs) {}
ryood 0:54debc783452 29
ryood 0:54debc783452 30 uint8_t ioDirection(ExioPort port) { return read(IODIRA_ADDR | port); }
ryood 0:54debc783452 31 void ioDirection(ExioPort port, uint8_t data) { write(IODIRA_ADDR | port, data); }
ryood 0:54debc783452 32
ryood 0:54debc783452 33 uint8_t ioPolarity(ExioPort port) { return read(IPOLA_ADDR | port); }
ryood 0:54debc783452 34 void ioPolarity(ExioPort port, uint8_t data) { write(IPOLA_ADDR | port, data); }
ryood 0:54debc783452 35
ryood 0:54debc783452 36 uint8_t ioPullup(ExioPort port) { return read(GPPUA_ADDR | port); }
ryood 0:54debc783452 37 void ioPullup(ExioPort port, uint8_t data) { write(GPPUA_ADDR | port, data); }
ryood 0:54debc783452 38
ryood 0:54debc783452 39 uint8_t readPort(ExioPort port) { return read(GPIOA_ADDR | port); }
ryood 0:54debc783452 40 void writePort(ExioPort port, uint8_t data) { write(GPIOA_ADDR | port, data); }
ryood 0:54debc783452 41
ryood 0:54debc783452 42 protected:
ryood 0:54debc783452 43 void write(uint8_t reg_address, uint8_t data) { MCP23S17::write(reg_address, data); }
ryood 0:54debc783452 44 uint8_t read(uint8_t reg_address) { return MCP23S17::read(reg_address); }
ryood 0:54debc783452 45 };
ryood 0:54debc783452 46
ryood 0:54debc783452 47 #endif //_EXIOMCP23S17_H_