41 SPI(
"ADIS16448", nullptr, bus, device,
SPIDEV_MODE3, 1000000),
42 ScheduledWorkItem(MODULE_NAME,
px4::device_bus_to_wq(get_device_id())),
88 PX4_ERR(
"measure failed");
149 const bool self_test_error = (status & (1 << 5));
151 if (self_test_error) {
155 const bool mag_fail = (status & (1 << 0));
159 PX4_WARN(
"Magnetometer functional test fail");
163 const bool baro_fail = (status & (1 << 1));
166 PX4_ERR(
"Barometer functional test test fail");
171 const bool gyro_x_fail = (status & (1 << 10));
172 const bool gyro_y_fail = (status & (1 << 11));
173 const bool gyro_z_fail = (status & (1 << 12));
175 if (gyro_x_fail || gyro_y_fail || gyro_z_fail) {
176 PX4_ERR(
"gyroscope self-test failure");
181 const bool accel_x_fail = (status & (1 << 13));
182 const bool accel_y_fail = (status & (1 << 14));
183 const bool accel_z_fail = (status & (1 << 15));
185 if (accel_x_fail || accel_y_fail || accel_z_fail) {
186 PX4_ERR(
"accelerometer self-test failure");
197 bool reset_success =
reset();
200 for (
size_t i = 0; i < 5; i++) {
208 reset_success =
reset();
211 if (!reset_success) {
212 PX4_ERR(
"unable to successfully reset");
235 uint16_t smpl_prd = 0;
237 if (desired_sample_rate_hz <= 51) {
240 }
else if (desired_sample_rate_hz <= 102) {
243 }
else if (desired_sample_rate_hz <= 204) {
246 }
else if (desired_sample_rate_hz <= 409) {
256 PX4_ERR(
"failed to set IMU sample rate");
275 PX4_ERR(
"failed to set IMU filter");
286 uint16_t gyro_range_selection = 0;
288 if (desired_gyro_dyn_range <= 250) {
291 }
else if (desired_gyro_dyn_range <= 500) {
302 PX4_ERR(
"failed to set gyro range");
340 cmd[0] = ((reg |
DIR_READ) << 8) & 0xff00;
342 transferhword(cmd,
nullptr, 1);
344 transferhword(
nullptr, cmd, 1);
355 cmd[0] = ((reg |
DIR_WRITE) << 8) | (0x00ff & value);
356 cmd[1] = (((reg + 0x1) |
DIR_WRITE) << 8) | ((0xff00 & value) >> 8);
358 transferhword(cmd,
nullptr, 1);
360 transferhword(cmd + 1,
nullptr, 1);
383 uint16_t crc = 0xFFFF;
386 static constexpr
unsigned int POLY = 0x1021;
391 for (
int i = 1; i < 12; i++) {
392 unsigned int upperByte = (burstData[i] >> 8) & 0xFF;
393 unsigned int lowerByte = (burstData[i] & 0xFF);
396 for (
int ii = 0; ii < 8; ii++, data >>= 1) {
397 if ((crc & 0x0001) ^ (data & 0x0001)) {
398 crc = (crc >> 1) ^ POLY;
407 for (
int ii = 0; ii < 8; ii++, data >>= 1) {
408 if ((crc & 0x0001) ^ (data & 0x0001)) {
409 crc = (crc >> 1) ^ POLY;
419 crc = (crc << 8) | (data >> 8 & 0xFF);
430 int16_t outputbuffer = 0;
432 if ((word >> 11) & 0x1) {
433 outputbuffer = (word & 0xfff) | 0xf000;
436 outputbuffer = (word & 0x0fff);
439 return (outputbuffer);
449 #pragma pack(push, 1) // Ensure proper memory alignment. 481 if (
OK != transferhword((uint16_t *)&report, ((uint16_t *)&report),
sizeof(report) /
sizeof(int16_t))) {
493 if (report.CRC16 !=
ComputeCRC16((uint16_t *)&report.DIAG_STAT)) {
507 _px4_accel.
update(timestamp_sample, report.XACCL_OUT, report.YACCL_OUT, report.ZACCL_OUT);
511 _px4_gyro.
update(timestamp_sample, report.XGYRO_OUT, report.YGYRO_OUT, report.ZGYRO_OUT);
514 const bool baro_mag_update = (report.DIAG_STAT & (1 << 7));
516 if (baro_mag_update) {
519 _px4_mag.
update(timestamp_sample, report.XMAGN_OUT, report.YMAGN_OUT, report.ZMAGN_OUT);
#define ADIS16448_MSC_CTRL
#define BITS_SMPL_PRD_8_TAP_CFG
void print_info()
Diagnostics - print some basic information about the driver and sensor.
#define BITS_SMPL_PRD_4_TAP_CFG
void set_temperature(float temperature)
#define BITS_GYRO_DYN_RANGE_500_CFG
#define ADIS16448_PRODUCT_ID
static struct vehicle_status_s status
void set_sample_rate(unsigned rate)
#define ADIS16448_DIAG_STAT
#define ADIS16448_Product
#define ADIS16448_GPIO_CTRL
static constexpr float ADIS16448_MAG_SENSITIVITY
static constexpr float ADIS16448_BARO_SENSITIVITY
void set_device_type(uint8_t devtype)
void set_error_count(uint64_t error_count)
void set_error_count(uint64_t error_count)
PX4Accelerometer _px4_accel
#define ADIS16448_SENS_AVG
void update(hrt_abstime timestamp, float x, float y, float z)
#define ADIS16448_GLOB_CMD
void Run()
Static trampoline from the hrt_call context; because we don't have a generic hrt wrapper yet...
#define DRV_GYR_DEVTYPE_ADIS16448
#define DRV_ACC_DEVTYPE_ADIS16448
uint16_t read_reg16(unsigned reg)
Read a register from the ADIS16448.
perf_counter_t _perf_crc_bad
bool set_dlpf_filter(uint16_t frequency_hz)
Set low pass filter frequency.
Namespace encapsulating all device framework classes, functions and data.
#define BITS_GYRO_DYN_RANGE_250_CFG
void set_device_type(uint8_t devtype)
void set_error_count(uint64_t error_count)
bool set_sample_rate(uint16_t desired_sample_rate_hz)
Set sample rate (approximate) - 1kHz to 5Hz.
void set_external(bool external)
static uint16_t ComputeCRC16(uint16_t burstData[13])
bool set_gyro_dyn_range(uint16_t desired_gyro_dyn_range)
Set the gyroscope dynamic range.
static constexpr float ADIS16448_GYRO_INITIAL_SENSITIVITY
void update(hrt_abstime timestamp, float x, float y, float z)
#define BITS_SMPL_PRD_16_TAP_CFG
void perf_count(perf_counter_t handle)
Count a performance event.
static int16_t convert12BitToINT16(uint16_t word)
convert 12 bit integer format to int16.
void perf_free(perf_counter_t handle)
Free a counter.
void set_temperature(float temperature)
void init()
Activates/configures the hardware registers.
void set_temperature(float temperature)
void set_sample_rate(unsigned rate)
void stop()
Stop automatic measurement.
void update(hrt_abstime timestamp, float pressure)
void update(hrt_abstime timestamp, int16_t x, int16_t y, int16_t z)
Rotation
Enum for board and external compass rotations.
static constexpr float ADIS16448_ACCEL_SENSITIVITY
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
void set_error_count(uint64_t error_count)
bool reset()
Resets the chip and measurements ranges.
void perf_end(perf_counter_t handle)
End a performance event.
#define ADIS16448_SMPL_PRD
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
void write_reg16(unsigned reg, uint16_t value)
Write a register in the ADIS16448.
static constexpr float _sample_rate
void set_scale(float scale)
void set_scale(float scale)
void start()
Start automatic measurement.
ADIS16448(int bus, uint32_t device, enum Rotation rotation)
#define DRV_MAG_DEVTYPE_ADIS16448
void set_temperature(float temperature)
perf_counter_t _perf_read
void perf_print_counter(perf_counter_t handle)
Print one performance counter to stdout.
uint64_t perf_event_count(perf_counter_t handle)
Return current event_count.
#define BITS_GYRO_DYN_RANGE_1000_CFG
perf_counter_t _perf_bad_transfer
perf_counter_t _perf_transfer
void set_scale(float scale)
void set_device_type(uint8_t devtype)
#define ADIS16334_SERIAL_NUMBER
#define BITS_SMPL_PRD_2_TAP_CFG
#define BITS_SMPL_PRD_NO_TAP_CFG
void modify_reg16(unsigned reg, uint16_t clearbits, uint16_t setbits)
Modify a register in the ADIS16448 Bits are cleared before bits are set.
void perf_begin(perf_counter_t handle)
Begin a performance event.
int measure()
Fetch measurements from the sensor and update the report buffers.
#define DEVICE_DEBUG(FMT,...)
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
void set_device_type(uint8_t devtype)