33 I2C(devname, devpath, map_bus_number(bus), 0, 100000UL)
44 #ifdef PX4_I2C_BUS_ONBOARD 45 return PX4_I2C_BUS_ONBOARD;
52 #ifdef PX4_I2C_BUS_EXPANSION 53 return PX4_I2C_BUS_EXPANSION;
59 #ifdef PX4_I2C_BUS_EXPANSION1 60 return PX4_I2C_BUS_EXPANSION1;
72 bool PX4_I2C::do_transfer(uint8_t address,
const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len,
bool split_transfers)
94 if (split_transfers) {
100 if (send && send_len) {
101 if (transfer(send, send_len,
nullptr, 0) != OK) {
105 if (recv && recv_len) {
106 if (transfer(
nullptr, 0, recv, recv_len) != OK) {
112 if (transfer(send, send_len, recv, recv_len) != OK) {
127 (
unsigned)bus, (
unsigned)address);
133 printf(
"I2C device bus %u address 0x%02x closed\n",
140 uint8_t *recv, uint32_t recv_len)
149 uint32_t recv_len, uint8_t times)
int printf(const char *fmt,...)
bool adjust_timer(AP_HAL::Device::PeriodicHandle h, uint32_t period_usec)
AP_HAL::OwnPtr< AP_HAL::I2CDevice > get_device(uint8_t bus, uint8_t address, uint32_t bus_clock=400000, bool use_smbus=false, uint32_t timeout_ms=4) override
void set_device_bus(uint8_t bus)
static pthread_mutex_t instance_lock
static AP_HAL::OwnPtr< AP_HAL::Device > dev
bool read_registers_multiple(uint8_t first_reg, uint8_t *recv, uint32_t recv_len, uint8_t times) override
AP_HAL::Device::PeriodicHandle register_periodic_callback(uint32_t period_usec, AP_HAL::Device::PeriodicCb, AP_HAL::Device *hal_device)
AP_HAL::Device::PeriodicHandle register_periodic_callback(uint32_t period_usec, AP_HAL::Device::PeriodicCb) override
bool do_transfer(uint8_t address, const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len, bool split_transfers)
static const uint8_t num_buses
bool transfer(const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len) override
void init()
Generic board initialization function.
int snprintf(char *str, size_t size, const char *fmt,...)
int asprintf(char **strp, const char *fmt,...)
bool adjust_periodic_callback(AP_HAL::Device::PeriodicHandle h, uint32_t period_usec) override
void set_device_address(uint8_t address)
uint8_t map_bus_number(uint8_t bus) const
static DeviceBus businfo[num_buses]