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.
This commit is contained in:
@@ -23,9 +23,9 @@ int power_source(bool *battery_powered) {
|
|||||||
#if defined CYW43_WL_GPIO_VBUS_PIN
|
#if defined CYW43_WL_GPIO_VBUS_PIN
|
||||||
*battery_powered = !cyw43_arch_gpio_get(CYW43_WL_GPIO_VBUS_PIN);
|
*battery_powered = !cyw43_arch_gpio_get(CYW43_WL_GPIO_VBUS_PIN);
|
||||||
return PICO_OK;
|
return PICO_OK;
|
||||||
#elif defined PICO_VBUS_GPIO_PIN
|
#elif defined PICO_VBUS_PIN
|
||||||
gpio_set_function(PICO_VBUS_GPIO_PIN, GPIO_FUNC_SIO);
|
gpio_set_function(PICO_VBUS_PIN, GPIO_FUNC_SIO);
|
||||||
*battery_powered = !gpio_get(PICO_VBUS_GPIO_PIN);
|
*battery_powered = !gpio_get(PICO_VBUS_PIN);
|
||||||
return PICO_OK;
|
return PICO_OK;
|
||||||
#else
|
#else
|
||||||
return PICO_ERROR_NO_DATA;
|
return PICO_ERROR_NO_DATA;
|
||||||
@@ -49,13 +49,11 @@ int power_voltage(float *voltage_result) {
|
|||||||
adc_fifo_setup(true, false, 0, false, false);
|
adc_fifo_setup(true, false, 0, false, false);
|
||||||
adc_run(true);
|
adc_run(true);
|
||||||
|
|
||||||
#if CYW43_USES_VSYS_PIN
|
// We seem to read low values initially - this seems to fix it
|
||||||
// We seem to read low values from cyw43 sometimes - this seems to fix it
|
|
||||||
int ignore_count = PICO_POWER_SAMPLE_COUNT;
|
int ignore_count = PICO_POWER_SAMPLE_COUNT;
|
||||||
while (!adc_fifo_is_empty() || ignore_count-- > 0) {
|
while (!adc_fifo_is_empty() || ignore_count-- > 0) {
|
||||||
(void)adc_fifo_get_blocking();
|
(void)adc_fifo_get_blocking();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// read vsys
|
// read vsys
|
||||||
uint32_t vsys = 0;
|
uint32_t vsys = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user