From df14f64185df1e03db3b2a0bfda9955e8a22799d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 20 Feb 2020 21:58:58 -0800 Subject: [PATCH] altos: More bmx160 debugging Signed-off-by: Keith Packard --- ao-tools/ao-eeprom/ao-eeprom.c | 11 +++++++++++ ao-tools/lib/ao-eeprom-read.h | 1 + src/drivers/ao_bmx160.c | 10 ++++++++++ src/drivers/ao_bmx160.h | 2 -- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ao-tools/ao-eeprom/ao-eeprom.c b/ao-tools/ao-eeprom/ao-eeprom.c index 91a6ccb3..2f076242 100644 --- a/ao-tools/ao-eeprom/ao-eeprom.c +++ b/ao-tools/ao-eeprom/ao-eeprom.c @@ -351,6 +351,16 @@ main (int argc, char **argv) case AO_LOG_FORMAT_MICROPEAK2: len = 2; break; + case AO_LOG_FORMAT_TELEMEGA_4: + len = 32; + break; + max_adc= 4095; + adc_ref = 3.3; + batt_r1 = 5600; + batt_r2 = 10000; + sense_r1 = 100e3; + sense_r2 = 27e3; + break; } if (arg_len) len = arg_len; @@ -398,6 +408,7 @@ main (int argc, char **argv) case AO_LOG_FORMAT_TELEMEGA: case AO_LOG_FORMAT_TELEMEGA_3: case AO_LOG_FORMAT_EASYMEGA_2: + case AO_LOG_FORMAT_TELEMEGA_4: log_mega = (struct ao_log_mega *) &eeprom->data[pos]; switch (log_mega->type) { case AO_LOG_FLIGHT: diff --git a/ao-tools/lib/ao-eeprom-read.h b/ao-tools/lib/ao-eeprom-read.h index 82893f24..e4a9b0cc 100644 --- a/ao-tools/lib/ao-eeprom-read.h +++ b/ao-tools/lib/ao-eeprom-read.h @@ -44,6 +44,7 @@ #define AO_LOG_FORMAT_EASYMEGA_2 16 /* 32 byte typed telemega records with 32 bit gyro cal, mpu9250 rotated 90° and adxl375 */ #define AO_LOG_FORMAT_TELESTATIC 17 /* 32 byte typed telestatic records */ #define AO_LOG_FORMAT_MICROPEAK2 18 /* 2-byte baro values with header */ +#define AO_LOG_FORMAT_TELEMEGA_4 19 /* 32 byte typed telemega records with 32 bit gyro cal and Bmx160 */ #define AO_LOG_FORMAT_NONE 127 /* No log at all */ enum ao_pyro_flag { diff --git a/src/drivers/ao_bmx160.c b/src/drivers/ao_bmx160.c index 0cb66384..0c503d28 100644 --- a/src/drivers/ao_bmx160.c +++ b/src/drivers/ao_bmx160.c @@ -183,6 +183,8 @@ _ao_bmx160_wait_alive(void) static void _ao_bmx160_setup(void) { + int r; + if (ao_bmx160_configured) return; @@ -216,6 +218,9 @@ _ao_bmx160_setup(void) (BMX160_ACC_CONF_ACC_ODR_200 << BMX160_ACC_CONF_ACC_ODR)); _ao_bmx160_reg_write(BMX160_ACC_RANGE, BMX160_ACC_RANGE_16G); + for (r = 0x4; r <= 0x17; r++) + (void) _ao_bmx160_reg_read(r); + /* Configure gyro: * @@ -319,11 +324,16 @@ ao_bmx160_show(void) uint8_t gyr_conf = _ao_bmx160_reg_read(BMX160_GYR_CONF); uint8_t gyr_range = _ao_bmx160_reg_read(BMX160_GYR_RANGE); uint8_t mag_conf = _ao_bmx160_reg_read(BMX160_MAG_CONF); + uint8_t status = _ao_bmx160_reg_read(BMX160_MAG_CONF); + uint8_t acc_x_lo = _ao_bmx160_reg_read(BMX160_ACCEL_X_0_7); + uint8_t acc_x_hi = _ao_bmx160_reg_read(BMX160_ACCEL_X_8_15); ao_bmx160_spi_put(); printf("ACC_CONF %02x ACC_RANGE %02x GYR_CONF %02x GYR_RANGE %02x MAG_CONF %02x\n", acc_conf, acc_range, gyr_conf, gyr_range, mag_conf); + printf("STATUS %02x ACCEL_X_0_7 %02x ACCEL_X_8_15 %02x\n", status, acc_x_lo, acc_x_hi); + printf ("Accel: %7d %7d %7d Gyro: %7d %7d %7d Mag: %7d %7d %7d\n", ao_bmx160_current.acc_x, ao_bmx160_current.acc_y, diff --git a/src/drivers/ao_bmx160.h b/src/drivers/ao_bmx160.h index 2b7e7bd7..e62f172d 100644 --- a/src/drivers/ao_bmx160.h +++ b/src/drivers/ao_bmx160.h @@ -130,8 +130,6 @@ ao_bmx160_init(void); #define BMX160_ACC_RANGE_4G 0x5 #define BMX160_ACC_RANGE_8G 0x8 #define BMX160_ACC_RANGE_16G 0xc -#define BMX160_ACC_RANGE_ -#define BMX160_ACC_RANGE_ #define BMX160_GYR_CONF 0x42 #define BMX160_GYR_CONF_GYR_ODR 0 #define BMX160_GYR_CONF_GYR_ODR_25 0x6 -- 2.30.2