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:
- 18:c631bf8fc741
- Parent:
- 15:23cf4a802b5b
- Child:
- 21:e861258373e2
--- a/YKNCT_I2C.cpp Mon Apr 29 16:26:19 2019 +0000 +++ b/YKNCT_I2C.cpp Wed May 08 16:41:07 2019 +0000 @@ -12,19 +12,22 @@ void Y_I2C::Out(OUT_I2C_Data_TypeDef *OUT_I2C_Data, uint8_t MAX) { - int cnt=0; - int i=0; + int cnt=0; //何個出力したかを保存する + int ad_cnt=0; //同じアドレスの数を保存する while(cnt<MAX) { char data=0; - int tmp=(OUT_I2C_Data+cnt)->DevAddress; - for(i=0;; i++) { - if(tmp!=(OUT_I2C_Data+cnt+i)->DevAddress) + int tmp_address=(OUT_I2C_Data+cnt)->DevAddress; + + //同じアドレスの数を数える + for(ad_cnt=0;; ad_cnt++) { + if(tmp_address!=(OUT_I2C_Data+cnt+ad_cnt)->DevAddress) break; } - for(int j=0; j<=i; j++) data|=(OUT_I2C_Data+cnt+j)->out_data<<j; + //一枚の基板に出力するデータを格納する + for(int j=0; j<ad_cnt; j++) data|=(OUT_I2C_Data+cnt+j)->out_data<<j; i2c.write((OUT_I2C_Data+cnt)->DevAddress<<1, &data, 1); - cnt+=i; + cnt+=ad_cnt; } }