mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Add MPU6500 SPI driver. Move sensor initialisation defines into target
specific headers.
This commit is contained in:
parent
79c2e5648f
commit
da51b5c479
19 changed files with 451 additions and 190 deletions
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <platform.h>
|
||||
|
||||
|
@ -56,7 +57,7 @@ static const i2cDevice_t i2cHardwareMap[] = {
|
|||
};
|
||||
|
||||
// Copy of peripheral address for IRQ routines
|
||||
static I2C_TypeDef *I2Cx;
|
||||
static I2C_TypeDef *I2Cx = NULL;
|
||||
// Copy of device index for reinit, etc purposes
|
||||
static I2CDevice I2Cx_index;
|
||||
|
||||
|
@ -116,6 +117,9 @@ bool i2cWriteBuffer(uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data)
|
|||
busy = 1;
|
||||
error = false;
|
||||
|
||||
if (!I2Cx)
|
||||
return false;
|
||||
|
||||
if (!(I2Cx->CR2 & I2C_IT_EVT)) { // if we are restarting the driver
|
||||
if (!(I2Cx->CR1 & 0x0100)) { // ensure sending a start
|
||||
while (I2Cx->CR1 & 0x0200 && --timeout > 0) { ; } // wait for any stop to finish sending
|
||||
|
@ -155,6 +159,9 @@ bool i2cRead(uint8_t addr_, uint8_t reg_, uint8_t len, uint8_t* buf)
|
|||
busy = 1;
|
||||
error = false;
|
||||
|
||||
if (!I2Cx)
|
||||
return false;
|
||||
|
||||
if (!(I2Cx->CR2 & I2C_IT_EVT)) { // if we are restarting the driver
|
||||
if (!(I2Cx->CR1 & 0x0100)) { // ensure sending a start
|
||||
while (I2Cx->CR1 & 0x0200 && --timeout > 0) { ; } // wait for any stop to finish sending
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue