ss
Dependencies: WS2812 PixelArray Adafruit_GFX
PCF8574.h@0:27e31cadeb36, 2019-06-15 (annotated)
- Committer:
- eunsong
- Date:
- Sat Jun 15 13:09:31 2019 +0000
- Revision:
- 0:27e31cadeb36
yes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
eunsong | 0:27e31cadeb36 | 1 | #include "mbed.h" |
eunsong | 0:27e31cadeb36 | 2 | |
eunsong | 0:27e31cadeb36 | 3 | #ifndef MBED_PCF8574_H |
eunsong | 0:27e31cadeb36 | 4 | #define MBED_PCF8574_H |
eunsong | 0:27e31cadeb36 | 5 | |
eunsong | 0:27e31cadeb36 | 6 | /** Interface to the popular PCF8574 I2C 8 Bit IO expander */ |
eunsong | 0:27e31cadeb36 | 7 | class PCF8574 { |
eunsong | 0:27e31cadeb36 | 8 | public: |
eunsong | 0:27e31cadeb36 | 9 | /** Create an instance of the PCF8574 connected to specfied I2C pins, with the specified address. |
eunsong | 0:27e31cadeb36 | 10 | * |
eunsong | 0:27e31cadeb36 | 11 | * @param sda The I2C data pin |
eunsong | 0:27e31cadeb36 | 12 | * @param scl The I2C clock pin |
eunsong | 0:27e31cadeb36 | 13 | * @param address The I2C address for this PCF8574 |
eunsong | 0:27e31cadeb36 | 14 | */ |
eunsong | 0:27e31cadeb36 | 15 | PCF8574(PinName sda, PinName scl, int address); |
eunsong | 0:27e31cadeb36 | 16 | |
eunsong | 0:27e31cadeb36 | 17 | /** Read the IO pin level |
eunsong | 0:27e31cadeb36 | 18 | * |
eunsong | 0:27e31cadeb36 | 19 | * @return The byte read |
eunsong | 0:27e31cadeb36 | 20 | */ |
eunsong | 0:27e31cadeb36 | 21 | int read(); |
eunsong | 0:27e31cadeb36 | 22 | |
eunsong | 0:27e31cadeb36 | 23 | /** Write to the IO pins |
eunsong | 0:27e31cadeb36 | 24 | * |
eunsong | 0:27e31cadeb36 | 25 | * @param data The 8 bits to write to the IO port |
eunsong | 0:27e31cadeb36 | 26 | */ |
eunsong | 0:27e31cadeb36 | 27 | void write(int data); |
eunsong | 0:27e31cadeb36 | 28 | |
eunsong | 0:27e31cadeb36 | 29 | private: |
eunsong | 0:27e31cadeb36 | 30 | I2C _i2c; |
eunsong | 0:27e31cadeb36 | 31 | int _address; |
eunsong | 0:27e31cadeb36 | 32 | }; |
eunsong | 0:27e31cadeb36 | 33 | |
eunsong | 0:27e31cadeb36 | 34 | #endif |