aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-11-27 07:31:56 -0700
committerSelene ToyKeeper2023-11-27 07:31:56 -0700
commit1b6f40863b4f08365e39236496d687ab7806ed11 (patch)
treeaf573a54cfdf01d3398ce78799ba0b019f1cb21d /hw
parentmore ADC / DAC / MCU progress... (diff)
downloadanduril-1b6f40863b4f08365e39236496d687ab7806ed11.tar.gz
anduril-1b6f40863b4f08365e39236496d687ab7806ed11.tar.bz2
anduril-1b6f40863b4f08365e39236496d687ab7806ed11.zip
fixed ADC on attiny1634 and related builds
Diffstat (limited to 'hw')
-rw-r--r--hw/hank/emisar-2ch/fet/hwdef.h30
-rw-r--r--hw/hank/emisar-2ch/hwdef.h30
-rw-r--r--hw/hank/emisar-d4k-3ch/hwdef.h30
-rw-r--r--hw/hank/noctigon-dm11/boost/hwdef.h30
-rw-r--r--hw/hank/noctigon-dm11/hwdef.h30
-rw-r--r--hw/hank/noctigon-k1/boost/hwdef.h30
-rw-r--r--hw/hank/noctigon-k1/hwdef.h30
-rw-r--r--hw/hank/noctigon-k1/sbt90/hwdef.h31
-rw-r--r--hw/hank/noctigon-kr4/hwdef.h30
-rw-r--r--hw/hank/noctigon-m44/hwdef.h30
-rw-r--r--hw/hank/vdivider-1634.h39
11 files changed, 49 insertions, 291 deletions
diff --git a/hw/hank/emisar-2ch/fet/hwdef.h b/hw/hank/emisar-2ch/fet/hwdef.h
index 06dfeb8..33eef7e 100644
--- a/hw/hank/emisar-2ch/fet/hwdef.h
+++ b/hw/hank/emisar-2ch/fet/hwdef.h
@@ -107,35 +107,7 @@ enum channel_modes_e {
#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
#endif
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
-#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
-// pin to ADC mappings are in DS table 19-4
-#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
-// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
-#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
-// DS tables 19-3, 19-4
-// Bit 7 6 5 4 3 2 1 0
-// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
-// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
-// divided by ...
-// REFS[1:0] = 1, 0 for internal 1.1V reference
-// other bits reserved
-#define ADMUX_VOLTAGE_DIVIDER 0b10000110
-#define ADC_PRSCL 0x07 // clk/128
-
-// Raw ADC readings at 4.4V and 2.2V
-// calibrate the voltage readout here
-// estimated / calculated values are:
-// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
-// D1, R1, R2 = 0, 330, 100
-#ifndef ADC_44
-//#define ADC_44 981 // raw value at 4.40V
-#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2
-#endif
-#ifndef ADC_22
-//#define ADC_22 489 // raw value at 2.20V
-#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2
-#endif
+#include "hank/vdivider-1634.h"
// this light has aux LEDs under the optic
#define AUXLED_R_PIN PA5 // pin 2
diff --git a/hw/hank/emisar-2ch/hwdef.h b/hw/hank/emisar-2ch/hwdef.h
index 7fbac8e..28d1b45 100644
--- a/hw/hank/emisar-2ch/hwdef.h
+++ b/hw/hank/emisar-2ch/hwdef.h
@@ -104,35 +104,7 @@ enum channel_modes_e {
#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
#endif
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
-#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
-// pin to ADC mappings are in DS table 19-4
-#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
-// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
-#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
-// DS tables 19-3, 19-4
-// Bit 7 6 5 4 3 2 1 0
-// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
-// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
-// divided by ...
-// REFS[1:0] = 1, 0 for internal 1.1V reference
-// other bits reserved
-#define ADMUX_VOLTAGE_DIVIDER 0b10000110
-#define ADC_PRSCL 0x07 // clk/128
-
-// Raw ADC readings at 4.4V and 2.2V
-// calibrate the voltage readout here
-// estimated / calculated values are:
-// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
-// D1, R1, R2 = 0, 330, 100
-#ifndef ADC_44
-//#define ADC_44 981 // raw value at 4.40V
-#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2
-#endif
-#ifndef ADC_22
-//#define ADC_22 489 // raw value at 2.20V
-#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2
-#endif
+#include "hank/vdivider-1634.h"
// this light has aux LEDs under the optic
#define AUXLED_R_PIN PA5 // pin 2
diff --git a/hw/hank/emisar-d4k-3ch/hwdef.h b/hw/hank/emisar-d4k-3ch/hwdef.h
index 002804c..81206c2 100644
--- a/hw/hank/emisar-d4k-3ch/hwdef.h
+++ b/hw/hank/emisar-d4k-3ch/hwdef.h
@@ -133,35 +133,7 @@ uint8_t led4_pwm, led4_dsm;
#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
#endif
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
-#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
-// pin to ADC mappings are in DS table 19-4
-#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
-// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
-#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
-// DS tables 19-3, 19-4
-// Bit 7 6 5 4 3 2 1 0
-// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
-// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
-// divided by ...
-// REFS[1:0] = 1, 0 for internal 1.1V reference
-// other bits reserved
-#define ADMUX_VOLTAGE_DIVIDER 0b10000110
-#define ADC_PRSCL 0x07 // clk/128
-
-// Raw ADC readings at 4.4V and 2.2V
-// calibrate the voltage readout here
-// estimated / calculated values are:
-// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
-// D1, R1, R2 = 0, 330, 100
-#ifndef ADC_44
-//#define ADC_44 981 // raw value at 4.40V
-#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2
-#endif
-#ifndef ADC_22
-//#define ADC_22 489 // raw value at 2.20V
-#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2
-#endif
+#include "hank/vdivider-1634.h"
// this light has aux LEDs under the optic
#define AUXLED_R_PIN PA5 // pin 2
diff --git a/hw/hank/noctigon-dm11/boost/hwdef.h b/hw/hank/noctigon-dm11/boost/hwdef.h
index bef409f..789eac9 100644
--- a/hw/hank/noctigon-dm11/boost/hwdef.h
+++ b/hw/hank/noctigon-dm11/boost/hwdef.h
@@ -101,35 +101,7 @@ uint8_t ch1_pwm, ch1_dsm;
#define SWITCH_PUE PUEA // pullup group A
#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
-#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
-// pin to ADC mappings are in DS table 19-4
-#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
-// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
-#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
-// DS tables 19-3, 19-4
-// Bit 7 6 5 4 3 2 1 0
-// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
-// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
-// divided by ...
-// REFS[1:0] = 1, 0 for internal 1.1V reference
-// other bits reserved
-#define ADMUX_VOLTAGE_DIVIDER 0b10000110
-#define ADC_PRSCL 0x07 // clk/128
-
-// Raw ADC readings at 4.4V and 2.2V
-// calibrate the voltage readout here
-// estimated / calculated values are:
-// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
-// D1, R1, R2 = 0, 330, 100
-#ifndef ADC_44
-//#define ADC_44 981 // raw value at 4.40V
-#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2
-#endif
-#ifndef ADC_22
-//#define ADC_22 489 // raw value at 2.20V
-#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2
-#endif
+#include "hank/vdivider-1634.h"
// this light has aux LEDs under the optic
#define AUXLED_R_PIN PA5 // pin 2
diff --git a/hw/hank/noctigon-dm11/hwdef.h b/hw/hank/noctigon-dm11/hwdef.h
index 11cf3a0..3e3d426 100644
--- a/hw/hank/noctigon-dm11/hwdef.h
+++ b/hw/hank/noctigon-dm11/hwdef.h
@@ -96,35 +96,7 @@ enum CHANNEL_MODES {
#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
-#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
-// pin to ADC mappings are in DS table 19-4
-#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
-// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
-#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
-// DS tables 19-3, 19-4
-// Bit 7 6 5 4 3 2 1 0
-// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
-// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
-// divided by ...
-// REFS[1:0] = 1, 0 for internal 1.1V reference
-// other bits reserved
-#define ADMUX_VOLTAGE_DIVIDER 0b10000110
-#define ADC_PRSCL 0x07 // clk/128
-
-// Raw ADC readings at 4.4V and 2.2V
-// calibrate the voltage readout here
-// estimated / calculated values are:
-// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
-// D1, R1, R2 = 0, 330, 100
-#ifndef ADC_44
-//#define ADC_44 981 // raw value at 4.40V
-#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2
-#endif
-#ifndef ADC_22
-//#define ADC_22 489 // raw value at 2.20V
-#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2
-#endif
+#include "hank/vdivider-1634.h"
// this light has aux LEDs under the optic
#define AUXLED_R_PIN PA5 // pin 2
diff --git a/hw/hank/noctigon-k1/boost/hwdef.h b/hw/hank/noctigon-k1/boost/hwdef.h
index e0a314c..db1584c 100644
--- a/hw/hank/noctigon-k1/boost/hwdef.h
+++ b/hw/hank/noctigon-k1/boost/hwdef.h
@@ -99,35 +99,7 @@ uint8_t ch1_pwm, ch1_dsm;
#define SWITCH_PUE PUEA // pullup group A
#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
-#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
-// pin to ADC mappings are in DS table 19-4
-#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
-// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
-#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
-// DS tables 19-3, 19-4
-// Bit 7 6 5 4 3 2 1 0
-// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
-// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
-// divided by ...
-// REFS[1:0] = 1, 0 for internal 1.1V reference
-// other bits reserved
-#define ADMUX_VOLTAGE_DIVIDER 0b10000110
-#define ADC_PRSCL 0x07 // clk/128
-
-// Raw ADC readings at 4.4V and 2.2V
-// calibrate the voltage readout here
-// estimated / calculated values are:
-// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
-// D1, R1, R2 = 0, 330, 100
-#ifndef ADC_44
-//#define ADC_44 981 // raw value at 4.40V
-#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2
-#endif
-#ifndef ADC_22
-//#define ADC_22 489 // raw value at 2.20V
-#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2
-#endif
+#include "hank/vdivider-1634.h"
// this light has aux LEDs under the optic
#define AUXLED_R_PIN PA5 // pin 2
diff --git a/hw/hank/noctigon-k1/hwdef.h b/hw/hank/noctigon-k1/hwdef.h
index 822b959..0d20871 100644
--- a/hw/hank/noctigon-k1/hwdef.h
+++ b/hw/hank/noctigon-k1/hwdef.h
@@ -89,35 +89,7 @@ enum CHANNEL_MODES {
#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
-#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
-// pin to ADC mappings are in DS table 19-4
-#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
-// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
-#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
-// DS tables 19-3, 19-4
-// Bit 7 6 5 4 3 2 1 0
-// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
-// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
-// divided by ...
-// REFS[1:0] = 1, 0 for internal 1.1V reference
-// other bits reserved
-#define ADMUX_VOLTAGE_DIVIDER 0b10000110
-#define ADC_PRSCL 0x07 // clk/128
-
-// Raw ADC readings at 4.4V and 2.2V
-// calibrate the voltage readout here
-// estimated / calculated values are:
-// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
-// D1, R1, R2 = 0, 330, 100
-#ifndef ADC_44
-//#define ADC_44 981 // raw value at 4.40V
-#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2
-#endif
-#ifndef ADC_22
-//#define ADC_22 489 // raw value at 2.20V
-#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2
-#endif
+#include "hank/vdivider-1634.h"
// this light has aux LEDs under the optic
#define AUXLED_R_PIN PA5 // pin 2
diff --git a/hw/hank/noctigon-k1/sbt90/hwdef.h b/hw/hank/noctigon-k1/sbt90/hwdef.h
index 4c56bc0..e2d04a9 100644
--- a/hw/hank/noctigon-k1/sbt90/hwdef.h
+++ b/hw/hank/noctigon-k1/sbt90/hwdef.h
@@ -93,36 +93,7 @@ enum CHANNEL_MODES {
#define SWITCH_PUE PUEB // pullup group B
#define SWITCH_VECT PCINT1_vect // ISR for PCINT[11:8]
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
-#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
-// pin to ADC mappings are in DS table 19-4
-#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
-// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
-#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
-// DS tables 19-3, 19-4
-// Bit 7 6 5 4 3 2 1 0
-// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
-// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
-// divided by ...
-// REFS[1:0] = 1, 0 for internal 1.1V reference
-// other bits reserved
-#define ADMUX_VOLTAGE_DIVIDER 0b10000110
-#define ADC_PRSCL 0x07 // clk/128
-
-// TODO: calibrate this
-// Raw ADC readings at 4.4V and 2.2V
-// calibrate the voltage readout here
-// estimated / calculated values are:
-// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
-// D1, R1, R2 = 0, 330, 100
-#ifndef ADC_44
-//#define ADC_44 981 // raw value at 4.40V
-#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2
-#endif
-#ifndef ADC_22
-//#define ADC_22 489 // raw value at 2.20V
-#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2
-#endif
+#include "hank/vdivider-1634.h"
#define TEMP_CHANNEL 0b00001111
diff --git a/hw/hank/noctigon-kr4/hwdef.h b/hw/hank/noctigon-kr4/hwdef.h
index be165bd..49e71fa 100644
--- a/hw/hank/noctigon-kr4/hwdef.h
+++ b/hw/hank/noctigon-kr4/hwdef.h
@@ -97,35 +97,7 @@ enum CHANNEL_MODES {
// so ignore voltage while the button is being held
//#define NO_LVP_WHILE_BUTTON_PRESSED
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
-#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
-// pin to ADC mappings are in DS table 19-4
-#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
-// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
-#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
-// DS tables 19-3, 19-4
-// Bit 7 6 5 4 3 2 1 0
-// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
-// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
-// divided by ...
-// REFS[1:0] = 1, 0 for internal 1.1V reference
-// other bits reserved
-#define ADMUX_VOLTAGE_DIVIDER 0b10000110
-#define ADC_PRSCL 0x07 // clk/128
-
-// Raw ADC readings at 4.4V and 2.2V
-// calibrate the voltage readout here
-// estimated / calculated values are:
-// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
-// D1, R1, R2 = 0, 330, 100
-#ifndef ADC_44
-//#define ADC_44 981 // raw value at 4.40V
-#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2
-#endif
-#ifndef ADC_22
-//#define ADC_22 489 // raw value at 2.20V
-#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2
-#endif
+#include "hank/vdivider-1634.h"
// this light has aux LEDs under the optic
#define AUXLED_R_PIN PA5 // pin 2
diff --git a/hw/hank/noctigon-m44/hwdef.h b/hw/hank/noctigon-m44/hwdef.h
index 6bdcef2..a397212 100644
--- a/hw/hank/noctigon-m44/hwdef.h
+++ b/hw/hank/noctigon-m44/hwdef.h
@@ -110,35 +110,7 @@ uint8_t ch2_pwm, ch2_dsm;
#define SWITCH_PUE PUEA // pullup group A
#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
-#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
-#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
-// pin to ADC mappings are in DS table 19-4
-#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
-// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
-#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
-// DS tables 19-3, 19-4
-// Bit 7 6 5 4 3 2 1 0
-// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
-// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
-// divided by ...
-// REFS[1:0] = 1, 0 for internal 1.1V reference
-// other bits reserved
-#define ADMUX_VOLTAGE_DIVIDER 0b10000110
-#define ADC_PRSCL 0x07 // clk/128
-
-// Raw ADC readings at 4.4V and 2.2V
-// calibrate the voltage readout here
-// estimated / calculated values are:
-// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
-// D1, R1, R2 = 0, 330, 100
-#ifndef ADC_44
-//#define ADC_44 981 // raw value at 4.40V
-#define ADC_44 967 // manually tweaked so 4.16V will blink out 4.2
-#endif
-#ifndef ADC_22
-//#define ADC_22 489 // raw value at 2.20V
-#define ADC_22 482 // manually tweaked so 4.16V will blink out 4.2
-#endif
+#include "hank/vdivider-1634.h"
// this light has aux LEDs under the optic
#define AUXLED_R_PIN PA5 // pin 2
diff --git a/hw/hank/vdivider-1634.h b/hw/hank/vdivider-1634.h
new file mode 100644
index 0000000..171267d
--- /dev/null
+++ b/hw/hank/vdivider-1634.h
@@ -0,0 +1,39 @@
+// attiny1634 voltage divider common defs
+// Copyright (C) 2020-2023 Selene ToyKeeper
+// SPDX-License-Identifier: GPL-3.0-or-later
+#pragma once
+
+#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
+#define VOLTAGE_PIN PB1 // Pin 18 / PB1 / ADC6
+// pin to ADC mappings are in DS table 19-4
+#define VOLTAGE_ADC ADC6D // digital input disable pin for PB1
+// DIDR0/DIDR1 mappings are in DS section 19.13.5, 19.13.6
+#define VOLTAGE_ADC_DIDR DIDR1 // DIDR channel for ADC6D
+// DS tables 19-3, 19-4
+// Bit 7 6 5 4 3 2 1 0
+// REFS1 REFS0 REFEN ADC0EN MUX3 MUX2 MUX1 MUX0
+// MUX[3:0] = 0, 1, 1, 0 for ADC6 / PB1
+// divided by ...
+// REFS[1:0] = 1, 0 for internal 1.1V reference
+// other bits reserved
+#define ADMUX_VOLTAGE_DIVIDER 0b10000110
+#undef voltage_raw2cooked
+#define voltage_raw2cooked mcu_vdivider_raw2cooked
+
+#define ADC_PRSCL 0x07 // clk/128
+
+// Raw ADC readings at 4.4V and 2.2V
+// calibrate the voltage readout here
+// estimated / calculated values are:
+// (voltage - D1) * (R2/(R2+R1) * 1024 / 1.1)
+// D1, R1, R2 = 0, 330, 100
+#ifndef ADC_44
+//#define ADC_44 (4*981) // raw value at 4.40V
+#define ADC_44 (4*967) // manually tweaked so 4.16V will blink out 4.2
+#endif
+#ifndef ADC_22
+//#define ADC_22 (4*489) // raw value at 2.20V
+#define ADC_22 (4*482) // manually tweaked so 4.16V will blink out 4.2
+#endif
+
+