From 8661b5cf9699e85ea4f5893484f6a143e9badbfd Mon Sep 17 00:00:00 2001 From: Peter Harper <77111776+peterharperuk@users.noreply.github.com> Date: Thu, 8 Jun 2023 16:01:47 +0100 Subject: [PATCH] Fix PICO_VBUS_PIN (#393) Inexplicably using the wrongly named constant. Should be PICO_VBUS_PIN. * In read_vsys ignore initial readings We were doing this for pico_w but it seems it's needed for pico as well. --- adc/read_vsys/power_status.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/adc/read_vsys/power_status.c b/adc/read_vsys/power_status.c index 226835f..4f0fffa 100644 --- a/adc/read_vsys/power_status.c +++ b/adc/read_vsys/power_status.c @@ -23,9 +23,9 @@ int power_source(bool *battery_powered) { #if defined CYW43_WL_GPIO_VBUS_PIN *battery_powered = !cyw43_arch_gpio_get(CYW43_WL_GPIO_VBUS_PIN); return PICO_OK; -#elif defined PICO_VBUS_GPIO_PIN - gpio_set_function(PICO_VBUS_GPIO_PIN, GPIO_FUNC_SIO); - *battery_powered = !gpio_get(PICO_VBUS_GPIO_PIN); +#elif defined PICO_VBUS_PIN + gpio_set_function(PICO_VBUS_PIN, GPIO_FUNC_SIO); + *battery_powered = !gpio_get(PICO_VBUS_PIN); return PICO_OK; #else return PICO_ERROR_NO_DATA; @@ -49,13 +49,11 @@ int power_voltage(float *voltage_result) { adc_fifo_setup(true, false, 0, false, false); adc_run(true); -#if CYW43_USES_VSYS_PIN - // We seem to read low values from cyw43 sometimes - this seems to fix it + // We seem to read low values initially - this seems to fix it int ignore_count = PICO_POWER_SAMPLE_COUNT; while (!adc_fifo_is_empty() || ignore_count-- > 0) { (void)adc_fifo_get_blocking(); } -#endif // read vsys uint32_t vsys = 0;