diff --git a/boards/feather-m0/doc.txt b/boards/feather-m0/doc.txt index b3f0576604c6..4154089e0700 100644 --- a/boards/feather-m0/doc.txt +++ b/boards/feather-m0/doc.txt @@ -24,7 +24,20 @@ SAMD21 mcu. ### Pinout Adafruit Feather M0 proto pinout + alt="Adafruit Feather M0 proto pinout" style="width:800px;"/>
+ +`AIN7` can be used to [measure the voltage of a connected Lipoly battery][battery]. +It is mapped to ADC_LINE(6) in RIOT. + +~~~~~~~~~~~~~~~~ {.c} +int vbat = adc_sample(ADC_LINE(6), ADC_RES_10BIT); +vbat *= 2; /* voltage was divided by 2, so multiply it back */ +vbat *= 33; /* reference voltage 3.3V * 10 */ +vbat /= 10240; /* resolution * 10 (because we multiplied 3.3V by 10) */ +printf("Bat: %dV\n", vbat); +~~~~~~~~~~~~~~~~ + +[battery]: https://learn.adafruit.com/adafruit-feather-m0-basic-proto/power-management#measuring-battery-4-9 ### Flash the board diff --git a/boards/feather-m0/include/periph_conf.h b/boards/feather-m0/include/periph_conf.h index 61bdb06118ee..625e94872843 100644 --- a/boards/feather-m0/include/periph_conf.h +++ b/boards/feather-m0/include/periph_conf.h @@ -177,9 +177,10 @@ static const adc_conf_chan_t adc_channels[] = { { GPIO_PIN(PA, 4), ADC_INPUTCTRL_MUXPOS_PIN4 }, /* A3 */ { GPIO_PIN(PA, 5), ADC_INPUTCTRL_MUXPOS_PIN5 }, /* A4 */ { GPIO_PIN(PB, 2), ADC_INPUTCTRL_MUXPOS_PIN10 }, /* A5 */ + { GPIO_PIN(PA, 7), ADC_INPUTCTRL_MUXPOS_PIN7 }, /* A7 */ }; -#define ADC_0_CHANNELS (6U) +#define ADC_0_CHANNELS (7U) #define ADC_NUMOF ADC_0_CHANNELS /** @} */