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.
Fork of mbed-RtosI2cDriver by
Diff: I2CDriverTest04.h
- Revision:
- 12:6ddadcbbdca2
- Parent:
- 11:8c1d44595620
- Child:
- 13:530968937ccb
--- a/I2CDriverTest04.h Thu May 09 20:52:07 2013 +0000 +++ b/I2CDriverTest04.h Fri May 10 07:34:24 2013 +0000 @@ -26,16 +26,16 @@ //printf("tst02\n"); config(i2c); + const char reg= 0x3a; + char result[64]; while(true) { //osci.write(0); i2c.frequency(g_freq); Thread::signal_wait(1<<5,osWaitForever); - // read back srf08 echo times (1+16 words) - const char reg= 0x3a; - char result[64]; + // read from MPU600's fifo + uint32_t t1=us_ticker_read(); int stat = i2c.read(i2cAdr, reg, result, g_len); - uint32_t dt=us_ticker_read()-t1; if(stat!=0) { //osci.write(1); @@ -53,7 +53,7 @@ Thread highPrioThread(highPrioThreadFun,0,osPriorityAboveNormal); RtosTimer highPrioTicker(highPrioCallBck, osTimerPeriodic, (void *)0); - Thread::wait(100); + Thread::wait(2000); highPrioTicker.start(1); #if defined(TARGET_LPC1768) @@ -92,10 +92,8 @@ void readModWrite(I2CMasterRtos& i2c, uint8_t reg, uint8_t dta) { - //printf("rmw01\n"); char rd1; int rStat1 = i2c.read(i2cAdr, reg, &rd1, 1); - //printf("rmw02\n"); char data[2]; data[0]=(char)reg; data[1]=(char)dta; @@ -103,7 +101,7 @@ int wStat = i2c.write(i2cAdr, data, 2); osDelay(100); int rStat2 = i2c.read(i2cAdr, reg, &rd2, 1); - printf("%2d%2d%2d %2x <- %2x => %2x -> %2x \n", rStat1, wStat, rStat2, reg, dta, rd1, rd2); + printf("(%3x%3x%3x) %2x <- %2x => %2x -> %2x \n", rStat1, wStat, rStat2, reg, dta, rd1, rd2); } static void config(I2CMasterRtos& i2c)