// BNO086 Rotation Vector Configuration Fix
// 1. Try with a slower report interval (50ms = 50,000 microseconds)
void enableRotationVectorSlow() {
uint8_t setFeatureCommand[] = {
0xFD, // Set Feature Report command
0x05, // Report ID for Rotation Vector
0x01, // Feature flags (enable)
0x00, // Change sensitivity (relative)
0x00, // Change sensitivity (relative)
0x50, 0xC3, 0x00, 0x00, // Report interval: 50,000 μs (50ms)
0x00, 0x00, 0x00, 0x00, // Batch interval: 0 (no batching)
0x00, 0x00, 0x00, 0x00, // Sensor-specific config
0x00 // Reserved
};
sendPacket(2, setFeatureCommand, sizeof(setFeatureCommand));
}
// 2. Alternative: try with even slower interval (100ms)
void enableRotationVectorVerySlow() {
uint8_t setFeatureCommand[] = {
0xFD, // Set Feature Report command
0x05, // Report ID for Rotation Vector
0x01, // Feature flags (enable)
0x00, // Change sensitivity (relative)
0x00, // Change sensitivity (relative)
0xA0, 0x86, 0x01, 0x00, // Report interval: 100,000 μs (100ms)
0x00, 0x00, 0x00, 0x00, // Batch interval: 0 (no batching)
0x00, 0x00, 0x00, 0x00, // Sensor-specific config
0x00 // Reserved
};
sendPacket(2, setFeatureCommand, sizeof(setFeatureCommand));
}
// 3. Complete sequence with proper wake-up
void properRotationVectorInit() {
// Step 1: Send wake command first
uint8_t wakeCommand[] = {0x84}; // Wake up command
sendPacket(1, wakeCommand, sizeof(wakeCommand));
sl_udelay_wait(10000); // Wait 10ms
// Step 2: Clear any pending data
while (isDataAvailable()) {
readPacket();
}
// Step 3: Disable rotation vector first (ensure clean state)
uint8_t disableCommand[] = {
0xFD, // Set Feature Report command
0x05, // Report ID for Rotation Vector
0x00, // Feature flags (disable)
0x00, 0x00, // Change sensitivity
0x00, 0x00, 0x00, 0x00, // Report interval: 0
0x00, 0x00, 0x00, 0x00, // Batch interval: 0
0x00, 0x00, 0x00, 0x00, // Sensor-specific config
0x00 // Reserved
};
sendPacket(2, disableCommand, sizeof(disableCommand));
sl_udelay_wait(100000); // Wait 100ms
// Step 4: Enable with proper interval
uint8_t enableCommand[] = {
0xFD, // Set Feature Report command
0x05, // Report ID for Rotation Vector
0x01, // Feature flags (enable)
0x00, 0x00, // Change sensitivity
0x50, 0xC3, 0x00, 0x00, // Report interval: 50,000 μs (50ms)
0x50, 0xC3, 0x00, 0x00, // Batch interval: same as report interval
0x00, 0x00, 0x00, 0x00, // Sensor-specific config
0x00 // Reserved
};
sendPacket(2, enableCommand, sizeof(enableCommand));
sl_udelay_wait(100000); // Wait 100ms
// Step 5: Verify the feature is enabled
uint8_t getFeatureCommand[] = {
0xFE, // Get Feature Report command
0x05 // Report ID for Rotation Vector
};
sendPacket(2, getFeatureCommand, sizeof(getFeatureCommand));
}
// 4. Alternative approach: Use different feature flags
void enableRotationVectorAlternative() {
uint8_t setFeatureCommand[] = {
0xFD, // Set Feature Report command
0x05, // Report ID for Rotation Vector
0x03, // Feature flags (enable + wake up on motion)
0x00, 0x00, // Change sensitivity
0x50, 0xC3, 0x00, 0x00, // Report interval: 50,000 μs (50ms)
0x50, 0xC3, 0x00, 0x00, // Batch interval: same as report interval
0x00, 0x00, 0x00, 0x00, // Sensor-specific config
0x00 // Reserved
};
sendPacket(2, setFeatureCommand, sizeof(setFeatureCommand));
}
// 5. Debug helper: Print received feature response
void debugFeatureResponse(uint8_t* data, int length) {
printf("Feature Response Debug:\n");
printf("Length: %d bytes\n", length);
printf("Raw bytes: ");
for (int i = 0; i < length; i++) {
printf("0x%02X ", data[i]);
}
printf("\n");
if (length >= 8) {
printf("Command: 0x%02X\n", data[4]);
printf("Report ID: 0x%02X\n", data[5]);
printf("Feature Flags: 0x%02X\n", data[6]);
if (length >= 12) {
uint32_t interval = (data[9] << 24) | (data[8] << 16) | (data[7] << 8) | data[6];
printf("Report Interval: %u microseconds\n", interval);
}
}
}
// 6. I2C timing consideration
void improvedSendPacket(uint8_t channel, uint8_t* data, int length) {
// Add proper I2C timing delays
sl_udelay_wait(1000); // 1ms before send
// Your existing sendPacket implementation here
sendPacket(channel, data, length);
sl_udelay_wait(5000); // 5ms after send
}