aboutsummaryrefslogtreecommitdiff
path: root/arch/avr32dd20.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2024-03-27 07:13:26 -0600
committerSelene ToyKeeper2024-03-27 07:13:26 -0600
commit7b49797be1da97f54e9df3a1b0342ab20d7f02d5 (patch)
tree1aab20b6979c781419fc61c8be73facf332ad8e2 /arch/avr32dd20.c
parentfixed inaccurate comment (thanks to xikteny for spotting it) (diff)
downloadanduril-7b49797be1da97f54e9df3a1b0342ab20d7f02d5.tar.gz
anduril-7b49797be1da97f54e9df3a1b0342ab20d7f02d5.tar.bz2
anduril-7b49797be1da97f54e9df3a1b0342ab20d7f02d5.zip
increased voltage precision from 0.025V to 0.02V
(so 0 to 255 now goes from 0.00V to 5.10V)
Diffstat (limited to 'arch/avr32dd20.c')
-rw-r--r--arch/avr32dd20.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/avr32dd20.c b/arch/avr32dd20.c
index 2ac3526..3ada2ee 100644
--- a/arch/avr32dd20.c
+++ b/arch/avr32dd20.c
@@ -141,10 +141,10 @@ inline uint16_t mcu_adc_result() {
inline uint8_t mcu_vdd_raw2cooked(uint16_t measurement) {
// In : 65535 * (Vbat / 10) / 1.024V
- // Out: uint8_t: Vbat * 40
+ // Out: uint8_t: Vbat * 50
// (add 80 to round up near a boundary)
- uint8_t vbat40 = (uint16_t)(measurement + 80) / 160;
- return vbat40;
+ uint8_t vbat50 = (uint16_t)(measurement + 64) / 128;
+ return vbat50;
}
#if 0