39 #include <sys/types.h> 44 #include <semaphore.h> 56 #include <nuttx/wqueue.h> 59 #include <nuttx/arch.h> 60 #include <nuttx/clock.h> 62 #include <board_config.h> 67 #include <drivers/device/i2c.h> 68 #include <drivers/drv_mag.h> 71 #define AK09916_SAMPLE_RATE 100 72 #define AK09916_DEVICE_PATH_MAG "/dev/ak09916_i2c_int" 74 #define AK09916_DEVICE_PATH_MAG_EXT "/dev/ak09916_i2c_ext" 78 #define AK09916_MAG_RANGE_GA 1.5e-3f; 81 #define AK09916_I2C_ADDR 0x0C 83 #define AK09916_DEVICE_ID_A 0x48 84 #define AK09916_DEVICE_ID_B 0x09 // additional ID byte ("INFO" on AK9063 without content specification.) 86 #define AK09916REG_WIA 0x00 88 #define AK09916REG_HXL 0x11 89 #define AK09916REG_HXH 0x12 90 #define AK09916REG_HYL 0x13 91 #define AK09916REG_HYH 0x14 92 #define AK09916REG_HZL 0x15 93 #define AK09916REG_HZH 0x16 94 #define AK09916REG_ST1 0x10 95 #define AK09916REG_ST2 0x18 96 #define AK09916REG_CNTL2 0x31 97 #define AK09916REG_CNTL3 0x32 100 #define AK09916_CNTL2_POWERDOWN_MODE 0x00 101 #define AK09916_RESET 0x01 102 #define AK09916_CNTL2_SINGLE_MODE 0x01 103 #define AK09916_CNTL2_CONTINOUS_MODE_10HZ 0x02 104 #define AK09916_CNTL2_CONTINOUS_MODE_20HZ 0x04 105 #define AK09916_CNTL2_CONTINOUS_MODE_50HZ 0x06 106 #define AK09916_CNTL2_CONTINOUS_MODE_100HZ 0x08 107 #define AK09916_CNTL2_SELFTEST_MODE 0x10 108 #define AK09916_CNTL3_SRST 0x01 109 #define AK09916_ST1_DRDY 0x01 110 #define AK09916_ST1_DOR 0x02 113 #pragma pack(push, 1) 135 virtual int ioctl(
struct file *filp,
int cmd,
unsigned long arg);
137 virtual ssize_t read(
struct file *filp,
char *
buffer,
size_t buflen);
139 void read_block(uint8_t reg, uint8_t *val, uint8_t count);
144 void print_info(
void);
145 int setup_master_i2c(
void);
146 bool check_id(uint8_t &
id);
149 static void cycle_trampoline(
void *arg);
164 uint8_t read_reg(uint8_t reg);
165 void write_reg(uint8_t reg, uint8_t value);
169 unsigned _measure_ticks;
173 int _mag_orb_class_instance;
174 int _mag_class_instance;
175 bool _mag_reading_data;
176 ringbuffer::RingBuffer *_mag_reports;
177 mag_report _last_report {};
179 float _mag_range_scale;
189 bool check_duplicate(uint8_t *mag_data);
192 uint8_t _last_mag_data[6];
A flexible ringbuffer class.
Configuration flags used in code.
mag scaling factors; Vout = (Vin * Vscale) + Voffset
Definition: drv_mag.h:56
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
Definition: uORB.h:134
High-resolution timer with callouts and timekeeping.
Helper class implementing the magnetometer driver node.
Definition: ak09916.hpp:129
Definition of commonly used conversions.
Definition: icm20948.h:377
void reset(enum BMP280_BUS busid)
Reset the driver.
Definition: bmp280.cpp:743
Rotation
Enum for board and external compass rotations.
Definition: rotation.h:51
Platform dependant logging/debug implementation.
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
Definition: video_device.h:50
Performance measuring tools.