Skip to content

Commit 8661b5c

Browse files
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.
1 parent a9b3118 commit 8661b5c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

adc/read_vsys/power_status.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ int power_source(bool *battery_powered) {
2323
#if defined CYW43_WL_GPIO_VBUS_PIN
2424
*battery_powered = !cyw43_arch_gpio_get(CYW43_WL_GPIO_VBUS_PIN);
2525
return PICO_OK;
26-
#elif defined PICO_VBUS_GPIO_PIN
27-
gpio_set_function(PICO_VBUS_GPIO_PIN, GPIO_FUNC_SIO);
28-
*battery_powered = !gpio_get(PICO_VBUS_GPIO_PIN);
26+
#elif defined PICO_VBUS_PIN
27+
gpio_set_function(PICO_VBUS_PIN, GPIO_FUNC_SIO);
28+
*battery_powered = !gpio_get(PICO_VBUS_PIN);
2929
return PICO_OK;
3030
#else
3131
return PICO_ERROR_NO_DATA;
@@ -49,13 +49,11 @@ int power_voltage(float *voltage_result) {
4949
adc_fifo_setup(true, false, 0, false, false);
5050
adc_run(true);
5151

52-
#if CYW43_USES_VSYS_PIN
53-
// We seem to read low values from cyw43 sometimes - this seems to fix it
52+
// We seem to read low values initially - this seems to fix it
5453
int ignore_count = PICO_POWER_SAMPLE_COUNT;
5554
while (!adc_fifo_is_empty() || ignore_count-- > 0) {
5655
(void)adc_fifo_get_blocking();
5756
}
58-
#endif
5957

6058
// read vsys
6159
uint32_t vsys = 0;

0 commit comments

Comments
 (0)