Skip to content

Commit a5c354c

Browse files
committed
pbio/drv/block_device/block_device_ev3.c: Read ADC once before booting
Without this, the hub can falsely detect low battery when booting.
1 parent c991ad9 commit a5c354c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/pbio/drv/block_device/block_device_ev3.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,15 @@ pbio_error_t ev3_spi_process_thread(pbio_os_state_t *state, void *context) {
914914
// failure, it can reset the user data to factory defaults, and save it
915915
// properly on shutdown.
916916
pbdrv_block_device_load_err = err;
917+
918+
// Read one set of ADC samples before continuing boot.
919+
// This ensures that e.g. the low-battery warning doesn't falsely trigger.
920+
pbdrv_block_device_ev3_spi_begin_for_adc(
921+
channel_cmd,
922+
channel_data,
923+
PBDRV_CONFIG_ADC_EV3_ADC_NUM_CHANNELS + PBDRV_ADC_EV3_NUM_DELAY_SAMPLES);
924+
PBIO_OS_AWAIT_WHILE(state, (spi_dev.status & SPI_STATUS_WAIT_ANY));
925+
917926
pbio_busy_count_down();
918927

919928
pbio_os_timer_set(&timer, ADC_SAMPLE_PERIOD);

0 commit comments

Comments
 (0)