Reproduce https://mbed.org/forum/bugs-suggestions/topic/4128/ bug in med-NXP
Revision 0:308c98db9173, committed 2013-05-19
- Comitter:
- humlet
- Date:
- Sun May 19 07:15:51 2013 +0000
- Commit message:
- reproduce ; https://mbed.org/forum/bugs-suggestions/topic/4128/
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun May 19 07:15:51 2013 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +#include "I2C.h" + +int main() +{ + const int len = 128; + char strs[2][len]; + + I2C i2c(p28, p27); + const uint32_t adr = 0x70<<1; + char rData[5]; + char wData[5]; + + for(int i=0; i<2; i++) { + // read SW rev from register 0x00 from a srf08 ultra sonic ranger at i2c address 0x70/0xe0 + wData[0] = 0x00; // register address + int wStat = i2c.write(adr,wData,1,1); // write register address and keep bus open, i.e. don't finish write sequence with an instnt stop condition + if(i)wait_us(23); // grant some time to the i2c HW to start the unintentional additional write + rData[0]=0xff; + int rStat = i2c.read(adr,rData,1); // read srf08's SW rev from register 0x00. If in time, the start condition at the beginning of the sequence would abort the unitended write + snprintf(strs[i],len,"wStat=0x%02X rStat=0x%02X rData=0x%02X %s\n",wStat,rStat,rData[0], ((wStat|rStat)?"OUCH!":"OK!")); + } + printf(strs[0]); + printf(strs[1]); + return 0; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-NXP.lib Sun May 19 07:15:51 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/emilmont/code/mbed-NXP/#7e0c8e02c919
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-src.lib Sun May 19 07:15:51 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/emilmont/code/mbed-src/#c24f5ba8a7f9