How to add custom betaflight code to obtain data from I2C device and pass to OSD?

June

New Member
I successfully obtained data from my I2C device in Arduino:


#include <Wire.h>
...
Wire.begin();
... // read function:
Wire.beginTransmission(address);
Wire.write(startAddress >> 8);
Wire.write(startAddress & 0xFF);
uint16_t numberOfBytesToRead = bytesRemaining;

Wire.requestFrom((uint8_t)address, numberOfBytesToRead);
if (Wire.available()) {
for (uint16_t x = 0 ; x < numberOfBytesToRead / 2; x++) {
data[dataSpot] = Wire.read() << 8; //MSB // uint16_t *data
data[dataSpot] |= Wire.read(); //LSB
dataSpot++;
}
}


Now I need to do the same in STM32F411 Flight Controller:
1) obtain this data in Betaflight loop, along with other sensors data
2) send it to OSD, along with other sensors data

Please help me with specific code examples or suggest which files and functions should I edit? I'm still very new to Betaflight project structure
 
Back
Top