mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 19:40:31 +03:00
removed data copying in i2c write - this wasn't needed, we'll see if rabbit2 "developers" will "fix" this bug too.
git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@349 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
ab75f221bb
commit
c6b43776e4
1 changed files with 2 additions and 11 deletions
|
@ -31,7 +31,6 @@ void I2C2_EV_IRQHandler(void)
|
||||||
i2c_ev_handler();
|
i2c_ev_handler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define I2C_DEFAULT_TIMEOUT 30000
|
#define I2C_DEFAULT_TIMEOUT 30000
|
||||||
static volatile uint16_t i2cErrorCount = 0;
|
static volatile uint16_t i2cErrorCount = 0;
|
||||||
|
|
||||||
|
@ -79,26 +78,18 @@ static void i2c_er_handler(void)
|
||||||
bool i2cWriteBuffer(uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data)
|
bool i2cWriteBuffer(uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint8_t my_data[16];
|
|
||||||
uint32_t timeout = I2C_DEFAULT_TIMEOUT;
|
uint32_t timeout = I2C_DEFAULT_TIMEOUT;
|
||||||
|
|
||||||
addr = addr_ << 1;
|
addr = addr_ << 1;
|
||||||
reg = reg_;
|
reg = reg_;
|
||||||
writing = 1;
|
writing = 1;
|
||||||
reading = 0;
|
reading = 0;
|
||||||
write_p = my_data;
|
write_p = data;
|
||||||
read_p = my_data;
|
read_p = data;
|
||||||
bytes = len_;
|
bytes = len_;
|
||||||
busy = 1;
|
busy = 1;
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
// too long
|
|
||||||
if (len_ > 16)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (i = 0; i < len_; i++)
|
|
||||||
my_data[i] = data[i];
|
|
||||||
|
|
||||||
if (!(I2Cx->CR2 & I2C_IT_EVT)) { //if we are restarting the driver
|
if (!(I2Cx->CR2 & I2C_IT_EVT)) { //if we are restarting the driver
|
||||||
if (!(I2Cx->CR1 & 0x0100)) { // ensure sending a start
|
if (!(I2Cx->CR1 & 0x0100)) { // ensure sending a start
|
||||||
while (I2Cx->CR1 & 0x0200) { ; } //wait for any stop to finish sending
|
while (I2Cx->CR1 & 0x0200) { ; } //wait for any stop to finish sending
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue