mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 17:03:33 +08:00
drivers: re-use calibration topic
E.g. instead of defining a gyro_scale struct in drv_gyro.h, use the gyro_calibration message.
This commit is contained in:
@@ -114,13 +114,13 @@ private:
|
||||
ringbuffer::RingBuffer *_accel_reports;
|
||||
ringbuffer::RingBuffer *_mag_reports;
|
||||
|
||||
struct accel_scale _accel_scale;
|
||||
struct accel_calibration_s _accel_scale;
|
||||
unsigned _accel_range_m_s2;
|
||||
float _accel_range_scale;
|
||||
unsigned _accel_samplerate;
|
||||
unsigned _accel_onchip_filter_bandwith;
|
||||
|
||||
struct mag_scale _mag_scale;
|
||||
struct mag_calibration_s _mag_scale;
|
||||
unsigned _mag_range_ga;
|
||||
float _mag_range_scale;
|
||||
unsigned _mag_samplerate;
|
||||
@@ -584,7 +584,7 @@ ACCELSIM::devIOCTL(unsigned long cmd, unsigned long arg)
|
||||
|
||||
case ACCELIOCSSCALE: {
|
||||
/* copy scale, but only if off by a few percent */
|
||||
struct accel_scale *s = (struct accel_scale *) arg;
|
||||
struct accel_calibration_s *s = (struct accel_calibration_s *) arg;
|
||||
float sum = s->x_scale + s->y_scale + s->z_scale;
|
||||
|
||||
if (sum > 2.0f && sum < 4.0f) {
|
||||
@@ -606,7 +606,7 @@ ACCELSIM::devIOCTL(unsigned long cmd, unsigned long arg)
|
||||
|
||||
case ACCELIOCGSCALE:
|
||||
/* copy scale out */
|
||||
memcpy((struct accel_scale *) arg, &(_accel_scale), sizeof(_accel_scale));
|
||||
memcpy((struct accel_calibration_s *) arg, &(_accel_scale), sizeof(_accel_scale));
|
||||
return OK;
|
||||
|
||||
case ACCELIOCSELFTEST:
|
||||
@@ -712,12 +712,12 @@ ACCELSIM::mag_ioctl(unsigned long cmd, unsigned long arg)
|
||||
|
||||
case MAGIOCSSCALE:
|
||||
/* copy scale in */
|
||||
memcpy(&_mag_scale, (struct mag_scale *) arg, sizeof(_mag_scale));
|
||||
memcpy(&_mag_scale, (struct mag_calibration_s *) arg, sizeof(_mag_scale));
|
||||
return OK;
|
||||
|
||||
case MAGIOCGSCALE:
|
||||
/* copy scale out */
|
||||
memcpy((struct mag_scale *) arg, &_mag_scale, sizeof(_mag_scale));
|
||||
memcpy((struct mag_calibration_s *) arg, &_mag_scale, sizeof(_mag_scale));
|
||||
return OK;
|
||||
|
||||
case MAGIOCSRANGE:
|
||||
|
||||
@@ -154,7 +154,7 @@ private:
|
||||
|
||||
ringbuffer::RingBuffer *_accel_reports;
|
||||
|
||||
struct accel_scale _accel_scale;
|
||||
struct accel_calibration_s _accel_scale;
|
||||
float _accel_range_scale;
|
||||
float _accel_range_m_s2;
|
||||
orb_advert_t _accel_topic;
|
||||
@@ -163,7 +163,7 @@ private:
|
||||
|
||||
ringbuffer::RingBuffer *_gyro_reports;
|
||||
|
||||
struct gyro_scale _gyro_scale;
|
||||
struct gyro_calibration_s _gyro_scale;
|
||||
float _gyro_range_scale;
|
||||
float _gyro_range_rad_s;
|
||||
|
||||
@@ -839,7 +839,7 @@ GYROSIM::devIOCTL(unsigned long cmd, unsigned long arg)
|
||||
|
||||
case ACCELIOCSSCALE: {
|
||||
/* copy scale, but only if off by a few percent */
|
||||
struct accel_scale *s = (struct accel_scale *) arg;
|
||||
struct accel_calibration_s *s = (struct accel_calibration_s *) arg;
|
||||
float sum = s->x_scale + s->y_scale + s->z_scale;
|
||||
|
||||
if (sum > 2.0f && sum < 4.0f) {
|
||||
@@ -853,7 +853,7 @@ GYROSIM::devIOCTL(unsigned long cmd, unsigned long arg)
|
||||
|
||||
case ACCELIOCGSCALE:
|
||||
/* copy scale out */
|
||||
memcpy((struct accel_scale *) arg, &_accel_scale, sizeof(_accel_scale));
|
||||
memcpy((struct accel_calibration_s *) arg, &_accel_scale, sizeof(_accel_scale));
|
||||
return OK;
|
||||
|
||||
case ACCELIOCSRANGE:
|
||||
@@ -910,12 +910,12 @@ GYROSIM::gyro_ioctl(unsigned long cmd, unsigned long arg)
|
||||
|
||||
case GYROIOCSSCALE:
|
||||
/* copy scale in */
|
||||
memcpy(&_gyro_scale, (struct gyro_scale *) arg, sizeof(_gyro_scale));
|
||||
memcpy(&_gyro_scale, (struct gyro_calibration_s *) arg, sizeof(_gyro_scale));
|
||||
return OK;
|
||||
|
||||
case GYROIOCGSCALE:
|
||||
/* copy scale out */
|
||||
memcpy((struct gyro_scale *) arg, &_gyro_scale, sizeof(_gyro_scale));
|
||||
memcpy((struct gyro_calibration_s *) arg, &_gyro_scale, sizeof(_gyro_scale));
|
||||
return OK;
|
||||
|
||||
case GYROIOCSRANGE:
|
||||
|
||||
Reference in New Issue
Block a user