36 #include <px4_platform_common/px4_config.h> 37 #include <px4_platform_common/defines.h> 38 #include <px4_platform_common/time.h> 42 #include <sys/types.h> 46 #include <semaphore.h> 55 #include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp> 68 #include <px4_platform_common/getopt.h> 78 #define HMC5883_CONVERSION_INTERVAL (1000000 / 150) 80 #define ADDR_CONF_A 0x00 81 #define ADDR_CONF_B 0x01 82 #define ADDR_MODE 0x02 83 #define ADDR_DATA_OUT_X_MSB 0x03 84 #define ADDR_DATA_OUT_X_LSB 0x04 85 #define ADDR_DATA_OUT_Z_MSB 0x05 86 #define ADDR_DATA_OUT_Z_LSB 0x06 87 #define ADDR_DATA_OUT_Y_MSB 0x07 88 #define ADDR_DATA_OUT_Y_LSB 0x08 89 #define ADDR_STATUS 0x09 92 #define ADDR_TEMP_OUT_MSB 0x31 93 #define ADDR_TEMP_OUT_LSB 0x32 96 #define HMC5883L_MODE_NORMAL (0 << 0) 97 #define HMC5883L_MODE_POSITIVE_BIAS (1 << 0) 98 #define HMC5883L_MODE_NEGATIVE_BIAS (1 << 1) 100 #define HMC5883L_AVERAGING_1 (0 << 5) 101 #define HMC5883L_AVERAGING_2 (1 << 5) 102 #define HMC5883L_AVERAGING_4 (2 << 5) 103 #define HMC5883L_AVERAGING_8 (3 << 5) 105 #define MODE_REG_CONTINOUS_MODE (0 << 0) 106 #define MODE_REG_SINGLE_MODE (1 << 0) 108 #define STATUS_REG_DATA_OUT_LOCK (1 << 1) 109 #define STATUS_REG_DATA_READY (1 << 0) 111 #define HMC5983_TEMP_SENSOR_ENABLE (1 << 7) 264 int read_reg(uint8_t reg, uint8_t &val);
void print_info()
Diagnostics - print some basic information about the driver.
int measure()
Issue a measurement command.
unsigned _measure_interval
API for the uORB lightweight object broker.
void Run() override
Perform a poll cycle; collect from the previous measurement and start a new one.
int write_reg(uint8_t reg, uint8_t val)
Write a register.
perf_counter_t _conf_errors
mag scaling factors; Vout = (Vin * Vscale) + Voffset
Device(const Device &)=delete
int set_range(unsigned range)
Set the sensor range.
perf_counter_t _comms_errors
uint8_t _temperature_error_count
High-resolution timer with callouts and timekeeping.
bool _sensor_ok
sensor was found and reports ok
perf_counter_t _sample_perf
Abstract class for any character device.
ringbuffer::RingBuffer * _reports
Generic device / sensor interface.
HMC5883(device::Device *interface, const char *path, enum Rotation rotation)
int set_temperature_compensation(unsigned enable)
enable hmc5983 temperature compensation
struct mag_calibration_s _scale
int read_reg(uint8_t reg, uint8_t &val)
Read a register.
Rotation
Enum for board and external compass rotations.
int check_scale()
Check the current scale calibration.
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
uint8_t _temperature_counter
virtual ssize_t read(cdev::file_t *filp, char *buffer, size_t buflen)
Perform a read from the device.
int collect()
Collect the result of the most recent measurement.
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
void check_conf(void)
check the sensor configuration.
Shared defines for the hmc5883 driver.
int reset()
Reset the device.
int check_offset()
Check the current offset calibration.
virtual int ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
Perform an ioctl operation on the device.
Fundamental base class for all physical drivers (I2C, SPI).
void check_range(void)
check the sensor range.
void start()
Initialise the automatic measurement state machine and start it.
perf_counter_t _range_errors
void stop()
Stop the automatic measurement state machine.
int calibrate(cdev::file_t *filp, unsigned enable)
Perform the on-sensor scale calibration routine.
Performance measuring tools.
Base class for devices connected via I2C.
int set_excitement(unsigned enable)
Perform the on-sensor scale calibration routine.
float meas_to_float(uint8_t in[2])
Convert a big-endian signed 16-bit value to a float.