Driver for IO expander
PCA9534.h@0:fe2b1519a978, 2014-04-02 (annotated)
- Committer:
- sam_grove
- Date:
- Wed Apr 02 03:49:20 2014 +0000
- Revision:
- 0:fe2b1519a978
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 0:fe2b1519a978 | 1 | |
sam_grove | 0:fe2b1519a978 | 2 | #ifndef PCA9534_H |
sam_grove | 0:fe2b1519a978 | 3 | #define PCA9534_H |
sam_grove | 0:fe2b1519a978 | 4 | |
sam_grove | 0:fe2b1519a978 | 5 | #include "mbed.h" |
sam_grove | 0:fe2b1519a978 | 6 | |
sam_grove | 0:fe2b1519a978 | 7 | class PCA9534 |
sam_grove | 0:fe2b1519a978 | 8 | { |
sam_grove | 0:fe2b1519a978 | 9 | private: |
sam_grove | 0:fe2b1519a978 | 10 | I2C *_i2c; |
sam_grove | 0:fe2b1519a978 | 11 | InterruptIn *_irq; |
sam_grove | 0:fe2b1519a978 | 12 | int _address; |
sam_grove | 0:fe2b1519a978 | 13 | |
sam_grove | 0:fe2b1519a978 | 14 | enum BIT_LOC { |
sam_grove | 0:fe2b1519a978 | 15 | B0, B1, B2, B3, B4, B5, B6, B7 |
sam_grove | 0:fe2b1519a978 | 16 | }; |
sam_grove | 0:fe2b1519a978 | 17 | |
sam_grove | 0:fe2b1519a978 | 18 | private: |
sam_grove | 0:fe2b1519a978 | 19 | char readRegister(char reg); |
sam_grove | 0:fe2b1519a978 | 20 | int writeRegister(char reg, char val); |
sam_grove | 0:fe2b1519a978 | 21 | void irqHandler(void); |
sam_grove | 0:fe2b1519a978 | 22 | |
sam_grove | 0:fe2b1519a978 | 23 | public: |
sam_grove | 0:fe2b1519a978 | 24 | PCA9534(I2C &i2c, char address, InterruptIn &irq); |
sam_grove | 0:fe2b1519a978 | 25 | int input(char val); |
sam_grove | 0:fe2b1519a978 | 26 | int input(BIT_LOC bit); |
sam_grove | 0:fe2b1519a978 | 27 | int output(char val); |
sam_grove | 0:fe2b1519a978 | 28 | int output(BIT_LOC bit); |
sam_grove | 0:fe2b1519a978 | 29 | int read(void); |
sam_grove | 0:fe2b1519a978 | 30 | int read(BIT_LOC bit); |
sam_grove | 0:fe2b1519a978 | 31 | int write(char val); |
sam_grove | 0:fe2b1519a978 | 32 | int write(BIT_LOC bit); |
sam_grove | 0:fe2b1519a978 | 33 | |
sam_grove | 0:fe2b1519a978 | 34 | }; |
sam_grove | 0:fe2b1519a978 | 35 | |
sam_grove | 0:fe2b1519a978 | 36 | #endif |