Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

I2C - Code example
[I2C - System Management Bus]

 #include <otSerial.h>
 #include <otTimer.h>
 #include <otPrintfLite.h>
 #include <otI2cBus.h>

 void setup()
 {
   UartEnableSignals(UART0);
   UartSetBaud(UART0, 115200);
   setStdout(UART0);   // printf output is now directed on UART0
   I2cBusReset();
   I2cBusFrequency(100, 30);
 }


 void loop()
 {
   printf("MPU9250 id = %x\n", I2cBusReadByte(0x68, 0x75, 0)); // WHO_AM_I_MPU9250
   // Correct output is 0x71
   DelayMs(1000);
 }
footer
otStudio - Library Reference - (C) 2020-23 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0