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:
- 10:49ffdd5cf82e
- Parent:
- 9:f892d57a6714
- Child:
- 11:c7c764e21224
--- a/YKNCT_I2C.cpp Tue Apr 16 14:45:21 2019 +0000 +++ b/YKNCT_I2C.cpp Wed Apr 17 10:32:03 2019 +0000 @@ -22,22 +22,22 @@ void Y_I2C::In(IN_I2C_Data_TypeDef *IN_I2C_Data, uint8_t num) { static char data; + uint8_t array=(IN_I2C_Data+num)->Number; i2c.read((IN_I2C_Data+num) -> DevAddress<<1, &data, 1); - for(int i=0; i<4; i++) - (IN_I2C_Data+num)->in_data[i]=data&1<<i; + (IN_I2C_Data+num)->in_data=data&1<<array; wait_us(1000); } void Y_I2C::Adc(ADC_I2C_Data_TypeDef *ADC_I2C_Data, uint8_t num) { static char data[8]= {0}; + uint8_t array=(ADC_I2C_Data+num)->Number; i2c.read((ADC_I2C_Data+num) -> DevAddress<<1, data, 8); - for(int i=0; i<4; i++) - (ADC_I2C_Data+num)->adc_data[i]=data[i*2+1]<<8|data[i*2]; + (ADC_I2C_Data+num)->adc_data=data[array*2+1]<<8|data[array*2]; wait_us(1000); }