PCA9555
Dependents: Telliskivi2_2014 PowerManagementBoard_Rev_A_2017
PCA9555.cpp@0:011622696878, 2013-07-29 (annotated)
- Committer:
- Reiko
- Date:
- Mon Jul 29 20:36:59 2013 +0000
- Revision:
- 0:011622696878
- Child:
- 1:a6699cd826bb
Created PCA9555 library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Reiko | 0:011622696878 | 1 | #include "PCA9555.h" |
Reiko | 0:011622696878 | 2 | #include "mbed.h" |
Reiko | 0:011622696878 | 3 | |
Reiko | 0:011622696878 | 4 | PCA9555::PCA9555(PinName sda, PinName scl, int address) |
Reiko | 0:011622696878 | 5 | : _i2c(sda, scl) { |
Reiko | 0:011622696878 | 6 | _address = address; |
Reiko | 0:011622696878 | 7 | } |
Reiko | 0:011622696878 | 8 | |
Reiko | 0:011622696878 | 9 | int PCA9555::read() { |
Reiko | 0:011622696878 | 10 | char foo[2]; |
Reiko | 0:011622696878 | 11 | _i2c.read(_address, foo, 2); |
Reiko | 0:011622696878 | 12 | return (foo[1] << 8) | foo[0]; |
Reiko | 0:011622696878 | 13 | } |
Reiko | 0:011622696878 | 14 | |
Reiko | 0:011622696878 | 15 | void PCA9555::write(int data) { |
Reiko | 0:011622696878 | 16 | char foo[2]; |
Reiko | 0:011622696878 | 17 | foo[0]=data; |
Reiko | 0:011622696878 | 18 | foo[1]=data>>8; |
Reiko | 0:011622696878 | 19 | _i2c.write(_address, foo, 2); |
Reiko | 0:011622696878 | 20 | } |