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.
YKNCT_I2C.cpp
- Committer:
- Tom0108
- Date:
- 2019-04-02
- Revision:
- 0:c555f844eb8d
- Child:
- 1:67d5ea2ff6c1
File content as of revision 0:c555f844eb8d:
#include "YKNCT_I2C.h" Y_I2C::Y_I2C(PinName sda, PinName scl) : i2c(sda, scl) { i2c.frequency(100000); } int Y_I2C::Adc(int address, int num) { static char data[8]= {0}; static int ad_data[4]= {0}; i2c.read(address<<1, data, 8, false); for(int i=0; i<4; i++) ad_data[i]=(int16_t)data[i*2+1]<<8|data[i*2]; return ad_data[num]; }