From b5aa0edd108fe2480ffaf0356565ed4f06270f70 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 5 Jun 2019 22:21:22 +0200 Subject: [PATCH] feather-m0: add documentation on BAT voltage --- boards/feather-m0/doc.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/boards/feather-m0/doc.txt b/boards/feather-m0/doc.txt index b3f0576604..4154089e07 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