60 #ifndef MAG3110_ENABLE_LEN_FILTER 61 #define MAG3110_ENABLE_LEN_FILTER 0 66 #define MAG3110_MAG_REG_STATUS 0x00 67 #define MAG3110_MAG_REG_HXL 0x01 68 #define MAG3110_MAG_REG_HXH 0x02 69 #define MAG3110_MAG_REG_HYL 0x03 70 #define MAG3110_MAG_REG_HYH 0x04 71 #define MAG3110_MAG_REG_HZL 0x05 72 #define MAG3110_MAG_REG_HZH 0x06 73 #define MAG3110_MAG_REG_WHO_AM_I 0x07 74 #define MAG3110_MAG_REG_SYSMODE 0x08 75 #define MAG3110_MAG_REG_CTRL_REG1 0x10 76 #define MAG3110_MAG_REG_CTRL_REG2 0x11 78 #define BIT_STATUS_REG_DATA_READY (1 << 3) 85 , _dev(
std::move(dev))
97 if (!sensor || !sensor->
init(rotation)) {
153 if (!ack || sig != 0xC4)
goto exit;
194 _mag_x = (int16_t)(buf[0] << 8 | buf[1]);
195 _mag_y = (int16_t)(buf[2] << 8 | buf[3]);
196 _mag_z = (int16_t)(buf[4] << 8 | buf[5]);
202 #define MAG_SCALE (1.0f/10000 / 0.0001f * 1000) // 1 Tesla full scale of +-10000, 1 Gauss = 0,0001 Tesla, library needs milliGauss int printf(const char *fmt,...)
Vector3< float > Vector3f
void set_external(uint8_t instance, bool external)
virtual PeriodicHandle register_periodic_callback(uint32_t period_usec, PeriodicCb)=0
uint32_t get_bus_id(void) const
AP_HAL::OwnPtr< AP_HAL::Device > _dev
virtual AP_HAL::Semaphore * get_semaphore()=0
void rotate_field(Vector3f &mag, uint8_t instance)
virtual void set_retries(uint8_t retries)
#define MAG3110_MAG_REG_HXL
void publish_filtered_field(const Vector3f &mag, uint8_t instance)
void correct_field(Vector3f &mag, uint8_t i)
bool field_ok(const Vector3f &field)
#define HAL_SEMAPHORE_BLOCK_FOREVER
virtual bool take(uint32_t timeout_ms) WARN_IF_UNUSED=0
bool init(enum Rotation rotation)
void set_dev_id(uint8_t instance, uint32_t dev_id)
virtual void delay(uint16_t ms)=0
void set_device_type(uint8_t devtype)
virtual bool take_nonblocking() WARN_IF_UNUSED=0
static AP_HAL::OwnPtr< AP_HAL::Device > dev
uint8_t register_compass(void) const
virtual bool set_speed(Speed speed)=0
#define MAG3110_MAG_REG_WHO_AM_I
AP_Compass_MAG3110(Compass &compass, AP_HAL::OwnPtr< AP_HAL::Device > dev)
#define MAG3110_MAG_REG_CTRL_REG2
#define MAG3110_MAG_REG_STATUS
static AP_Compass_Backend * probe(Compass &compass, AP_HAL::OwnPtr< AP_HAL::Device > dev, enum Rotation=ROTATION_NONE)
uint8_t _compass_instance
void set_rotation(uint8_t instance, enum Rotation rotation)
#define MAG3110_MAG_REG_CTRL_REG1
bool read_registers(uint8_t first_reg, uint8_t *recv, uint32_t recv_len)
#define FUNCTOR_BIND_MEMBER(func, rettype,...)
void publish_raw_field(const Vector3f &mag, uint8_t instance)
void panic(const char *errormsg,...) FMT_PRINTF(1
bool write_register(uint8_t reg, uint8_t val, bool checked=false)
#define BIT_STATUS_REG_DATA_READY
AP_HAL::Scheduler * scheduler