Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: YKNCT_I2C.cpp
- Revision:
- 1:67d5ea2ff6c1
- Parent:
- 0:c555f844eb8d
- Child:
- 2:f5faf991cd86
--- a/YKNCT_I2C.cpp Tue Apr 02 07:18:26 2019 +0000 +++ b/YKNCT_I2C.cpp Tue Apr 02 09:50:29 2019 +0000 @@ -5,6 +5,20 @@ i2c.frequency(100000); } +void Y_I2C::Out(int address, char data) +{ + i2c.write(address<<1, &data, 1, false); +} + +int Y_I2C::In(int address, int num) +{ + static char data=0; + + i2c.read(address<<1, &data, 1, false); + + return data>>num&1; +} + int Y_I2C::Adc(int address, int num) { static char data[8]= {0}; @@ -21,3 +35,6 @@ + + +