mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 12:03:34 +08:00
I2C changes for upstream NuttX per trasaction freq control
This commit is contained in:
committed by
Lorenz Meier
parent
0177e250f4
commit
dcc2d1c3d1
@@ -50,7 +50,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <nuttx/i2c.h>
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
|
||||
#include <board_config.h>
|
||||
|
||||
@@ -68,7 +68,7 @@ __EXPORT int i2c_main(int argc, char *argv[]);
|
||||
|
||||
static int transfer(uint8_t address, uint8_t *send, unsigned send_len, uint8_t *recv, unsigned recv_len);
|
||||
|
||||
static struct i2c_dev_s *i2c;
|
||||
static struct i2c_master_s *i2c;
|
||||
|
||||
int i2c_main(int argc, char *argv[])
|
||||
{
|
||||
@@ -110,6 +110,7 @@ transfer(uint8_t address, uint8_t *send, unsigned send_len, uint8_t *recv, unsig
|
||||
msgs = 0;
|
||||
|
||||
if (send_len > 0) {
|
||||
msgv[msgs].frequency = 400000;
|
||||
msgv[msgs].addr = address;
|
||||
msgv[msgs].flags = 0;
|
||||
msgv[msgs].buffer = send;
|
||||
@@ -118,6 +119,7 @@ transfer(uint8_t address, uint8_t *send, unsigned send_len, uint8_t *recv, unsig
|
||||
}
|
||||
|
||||
if (recv_len > 0) {
|
||||
msgv[msgs].frequency = 400000;
|
||||
msgv[msgs].addr = address;
|
||||
msgv[msgs].flags = I2C_M_READ;
|
||||
msgv[msgs].buffer = recv;
|
||||
@@ -129,12 +131,6 @@ transfer(uint8_t address, uint8_t *send, unsigned send_len, uint8_t *recv, unsig
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* I2C architecture means there is an unavoidable race here
|
||||
* if there are any devices on the bus with a different frequency
|
||||
* preference. Really, this is pointless.
|
||||
*/
|
||||
I2C_SETFREQUENCY(i2c, 400000);
|
||||
ret = I2C_TRANSFER(i2c, &msgv[0], msgs);
|
||||
|
||||
// reset the I2C bus to unwedge on error
|
||||
|
||||
Reference in New Issue
Block a user