Christian Lerche
/
PCA9532
This program is for writing to PCA9532 on the LPCXpresso Base Board.
PCA9532.cpp@0:8dffae878f54, 2010-02-06 (annotated)
- Committer:
- Lerche
- Date:
- Sat Feb 06 06:32:14 2010 +0000
- Revision:
- 0:8dffae878f54
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lerche | 0:8dffae878f54 | 1 | #include "PCA9532.h" |
Lerche | 0:8dffae878f54 | 2 | #include "mbed.h" |
Lerche | 0:8dffae878f54 | 3 | using namespace mbed; |
Lerche | 0:8dffae878f54 | 4 | PCA9532::PCA9532(PinName sda, PinName scl, int addr) |
Lerche | 0:8dffae878f54 | 5 | : _i2c(sda,scl) { |
Lerche | 0:8dffae878f54 | 6 | _addr = addr; |
Lerche | 0:8dffae878f54 | 7 | } |
Lerche | 0:8dffae878f54 | 8 | |
Lerche | 0:8dffae878f54 | 9 | int PCA9532::read(void) { |
Lerche | 0:8dffae878f54 | 10 | char foo[1]; |
Lerche | 0:8dffae878f54 | 11 | _i2c.read(_addr,foo,1); |
Lerche | 0:8dffae878f54 | 12 | return (foo[0]); |
Lerche | 0:8dffae878f54 | 13 | } |
Lerche | 0:8dffae878f54 | 14 | |
Lerche | 0:8dffae878f54 | 15 | void PCA9532::write(int command, int data) { |
Lerche | 0:8dffae878f54 | 16 | char foo[2]; |
Lerche | 0:8dffae878f54 | 17 | foo[0] = command; |
Lerche | 0:8dffae878f54 | 18 | foo[1] = data; |
Lerche | 0:8dffae878f54 | 19 | _i2c.write(_addr,foo,2); |
Lerche | 0:8dffae878f54 | 20 | return; |
Lerche | 0:8dffae878f54 | 21 | } |