2017-05-05 07:09:29 -03:00
|
|
|
#pragma once
|
|
|
|
|
2016-07-14 07:07:24 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
|
|
|
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
|
|
|
|
|
|
|
#include <arch/board/board.h>
|
|
|
|
#include "board_config.h"
|
|
|
|
#include <drivers/device/i2c.h>
|
|
|
|
#include "AP_HAL_PX4.h"
|
|
|
|
|
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
/*
|
|
|
|
wrapper class for I2C to expose protected functions from PX4Firmware
|
|
|
|
*/
|
|
|
|
class PX4::PX4_I2C : public device::I2C {
|
|
|
|
public:
|
2016-10-31 04:57:44 -03:00
|
|
|
PX4_I2C(uint8_t bus);
|
2017-04-17 23:28:47 -03:00
|
|
|
bool do_transfer(uint8_t address, const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len, bool split_transfers);
|
2016-07-14 07:07:24 -03:00
|
|
|
|
2016-10-31 04:57:44 -03:00
|
|
|
void set_retries(uint8_t retries) {
|
|
|
|
_retries = retries;
|
|
|
|
}
|
2016-11-04 06:23:20 -03:00
|
|
|
|
|
|
|
uint8_t map_bus_number(uint8_t bus) const;
|
2017-10-26 01:08:29 -03:00
|
|
|
|
|
|
|
// setup instance_lock
|
|
|
|
static void init_lock(void) {
|
|
|
|
pthread_mutex_init(&instance_lock, nullptr);
|
|
|
|
}
|
2016-10-31 04:57:44 -03:00
|
|
|
|
2016-07-14 07:07:24 -03:00
|
|
|
private:
|
|
|
|
static uint8_t instance;
|
2017-10-26 01:08:29 -03:00
|
|
|
static pthread_mutex_t instance_lock;
|
2016-07-14 07:07:24 -03:00
|
|
|
bool init_done;
|
|
|
|
bool init_ok;
|
2018-03-16 17:46:30 -03:00
|
|
|
char devname[11];
|
|
|
|
char devpath[15];
|
2016-07-14 07:07:24 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CONFIG_HAL_BOARD
|