diff --git a/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.c b/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.c index 6c5a5a0..07e8590 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.c +++ b/project/ble_peripheral/ble_app_bladder_patch/command/handlers/cmd_sensor.c @@ -122,11 +122,6 @@ void all_sensors(void) buf[18] = (uint8_t)(info_temp >> 8); buf[19] = (uint8_t)(info_temp & 0xFF); - DBG_PRINTF("[RBB] IMU temp_x100=%u (%u.%02u C)\r\n", - info_temp, - info_temp / 100, - info_temp % 100); - dr_binary_tx_safe(buf, 10); /* 20 bytes = 10 words */ } @@ -174,11 +169,6 @@ void all_sensors_batt_temp(void) buf[6] = (uint8_t)(info_temp >> 8); buf[7] = (uint8_t)(info_temp & 0xFF); - DBG_PRINTF("[RBB] IMU temp_x100=%u (%u.%02u C)\r\n", - info_temp, - info_temp / 100, - info_temp % 100); - dr_binary_tx_safe(buf, 4); /* 8 bytes = 4 words, CRC appended by TX layer */ } diff --git a/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c b/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c index 304348b..6fd49dc 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c +++ b/project/ble_peripheral/ble_app_bladder_patch/measurement/adc121s051/dr_adc121s051.c @@ -1224,10 +1224,6 @@ static bool maa_async_send_header(void) buf[5] = (uint8_t)(ch_info & 0xFF); buf[6] = (uint8_t)(ch->num_samples >> 8); buf[7] = (uint8_t)(ch->num_samples & 0xFF); - ADC_LOG("reb ch_info: session=%u, ch=%u, value=0x%04X", - g_maa_ctx.ch_session, - g_maa_ctx.current_ch, - ch_info); uint16_t dst_idx = MAA_REB_HEADER_LEN; uint16_t first_chunk = (total_data_bytes > MAA_REB_DATA_LEN) ? MAA_REB_DATA_LEN : total_data_bytes; diff --git a/project/ble_peripheral/ble_app_bladder_patch/measurement/battery/battery_saadc.c b/project/ble_peripheral/ble_app_bladder_patch/measurement/battery/battery_saadc.c index 96cd834..0672efb 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/measurement/battery/battery_saadc.c +++ b/project/ble_peripheral/ble_app_bladder_patch/measurement/battery/battery_saadc.c @@ -192,14 +192,6 @@ void battery_event_handler(nrf_drv_saadc_evt_t const * p_event) { DBG_PRINTF("[SAFETY] IMU temp read failed\r\n"); } - else - { - int temp_x100 = (int)(imu_temp_c * 100.0f); - DBG_PRINTF("[SAFETY] 60s IMU temp_x100=%d (%d.%02d C)\r\n", - temp_x100, - temp_x100 / 100, - temp_x100 % 100); - } safety_check_complete(imu_temp_c); } diff --git a/project/ble_peripheral/ble_app_bladder_patch/measurement/imu/app_raw/app_raw.c b/project/ble_peripheral/ble_app_bladder_patch/measurement/imu/app_raw/app_raw.c index 9dd6b9d..6382e79 100644 --- a/project/ble_peripheral/ble_app_bladder_patch/measurement/imu/app_raw/app_raw.c +++ b/project/ble_peripheral/ble_app_bladder_patch/measurement/imu/app_raw/app_raw.c @@ -491,10 +491,13 @@ static uint16_t imu_temp_raw_to_x100(int16_t temp_raw) int imu_read_direct(void) { uint8_t raw[14]; /* temp 2 bytes + accel 6 bytes + gyro 6 bytes */ + uint8_t temp_raw_bytes[2]; int32_t accel[3], gyro[3]; int16_t temp_raw; + int32_t temp_sum; uint8_t reg; uint32_t ret; + uint8_t i; imu_direct_twi_init_once(); @@ -543,6 +546,7 @@ int imu_read_direct(void) * raw[8..13] = gyro X,Y,Z (2 bytes each, MSB first) */ temp_raw = (int16_t)((raw[0] << 8) | raw[1]); + temp_sum = temp_raw; accel[0] = (int16_t)((raw[2] << 8) | raw[3]); accel[1] = (int16_t)((raw[4] << 8) | raw[5]); accel[2] = (int16_t)((raw[6] << 8) | raw[7]); @@ -564,6 +568,30 @@ int imu_read_direct(void) if (info4 == true) { + reg = REG_TEMP_DATA1; + for (i = 1; i < IMU_TEMP_AVG_SAMPLES; i++) + { + ret = icm42670_twi_tx(IMU_I2C_ADDR, ®, 1, true); + if (ret) + { + DBG_PRINTF("[IMU] temp avg tx FAIL %u\r\n", ret); + break; + } + + ret = icm42670_twi_rx(IMU_I2C_ADDR, temp_raw_bytes, sizeof(temp_raw_bytes)); + if (ret) + { + DBG_PRINTF("[IMU] temp avg rx FAIL %u\r\n", ret); + break; + } + + temp_sum += (int16_t)((temp_raw_bytes[0] << 8) | temp_raw_bytes[1]); + } + if (i == IMU_TEMP_AVG_SAMPLES) + { + temp_raw = (int16_t)(temp_sum / (int32_t)IMU_TEMP_AVG_SAMPLES); + } + uint16_t temp_x100 = imu_temp_raw_to_x100(temp_raw); /* info4 mode: store in global array (sent as rbb: packet by mbb?) */