aboutsummaryrefslogtreecommitdiff
path: root/hw/hank
diff options
context:
space:
mode:
Diffstat (limited to 'hw/hank')
-rw-r--r--hw/hank/emisar-2ch/fet/hwdef.h36
-rw-r--r--hw/hank/emisar-2ch/hwdef.h36
-rw-r--r--hw/hank/emisar-d18/hwdef.h4
-rw-r--r--hw/hank/emisar-d4/hwdef.h4
-rw-r--r--hw/hank/emisar-d4k-3ch/hwdef.h36
-rw-r--r--hw/hank/emisar-d4sv2/hwdef.h6
-rw-r--r--hw/hank/emisar-d4v2/hwdef.h8
-rw-r--r--hw/hank/emisar-d4v2/nofet/anduril.h2
-rw-r--r--hw/hank/noctigon-dm11/boost/hwdef.h38
-rw-r--r--hw/hank/noctigon-dm11/hwdef.h42
-rw-r--r--hw/hank/noctigon-dm11/nofet/anduril.h2
-rw-r--r--hw/hank/noctigon-k1/boost/hwdef.h38
-rw-r--r--hw/hank/noctigon-k1/hwdef.h42
-rw-r--r--hw/hank/noctigon-k1/sbt90/hwdef.h39
-rw-r--r--hw/hank/noctigon-kr4/2ch/hwdef.h4
-rw-r--r--hw/hank/noctigon-kr4/boost/hwdef.h4
-rw-r--r--hw/hank/noctigon-kr4/hwdef.h38
-rw-r--r--hw/hank/noctigon-kr4/nofet/anduril.h2
-rw-r--r--hw/hank/noctigon-m44/hwdef.h38
-rw-r--r--hw/hank/vdivider-1634.h39
20 files changed, 93 insertions, 365 deletions
diff --git a/hw/hank/emisar-2ch/fet/hwdef.h b/hw/hank/emisar-2ch/fet/hwdef.h
index 0778e10..33eef7e 100644
--- a/hw/hank/emisar-2ch/fet/hwdef.h
+++ b/hw/hank/emisar-2ch/fet/hwdef.h
@@ -32,9 +32,7 @@
* The first channel also has a direct-drive FET for turbo.
*/
-#include <avr/io.h>
-
-#define HWDEF_C_FILE hank/emisar-2ch/fet/hwdef.c
+#define HWDEF_C hank/emisar-2ch/fet/hwdef.c
// allow using aux LEDs as extra channel modes
#include "fsm/chan-rgbaux.h"
@@ -106,38 +104,10 @@ enum channel_modes_e {
#define SWITCH_PCMSK PCMSK0 // PCMSK1 is for PCINT[7:0]
#define SWITCH_PORT PINA // PINA or PINB or PINC
#define SWITCH_PUE PUEA // pullup group A
-#define PCINT_vect PCINT0_vect // ISR for PCINT[7:0]
+#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 e3707c7..28d1b45 100644
--- a/hw/hank/emisar-2ch/hwdef.h
+++ b/hw/hank/emisar-2ch/hwdef.h
@@ -31,9 +31,7 @@
* and one pin to control the Opamp power level.
*/
-#include <avr/io.h>
-
-#define HWDEF_C_FILE hank/emisar-2ch/hwdef.c
+#define HWDEF_C hank/emisar-2ch/hwdef.c
// allow using aux LEDs as extra channel modes
#include "fsm/chan-rgbaux.h"
@@ -103,38 +101,10 @@ enum channel_modes_e {
#define SWITCH_PCMSK PCMSK0 // PCMSK1 is for PCINT[7:0]
#define SWITCH_PORT PINA // PINA or PINB or PINC
#define SWITCH_PUE PUEA // pullup group A
-#define PCINT_vect PCINT0_vect // ISR for PCINT[7:0]
+#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-d18/hwdef.h b/hw/hank/emisar-d18/hwdef.h
index 86c97c2..a0d3cd0 100644
--- a/hw/hank/emisar-d18/hwdef.h
+++ b/hw/hank/emisar-d18/hwdef.h
@@ -12,9 +12,7 @@
* ----
*/
-#include <avr/io.h>
-
-#define HWDEF_C_FILE lumintop/fw3a/hwdef.c
+#define HWDEF_C lumintop/fw3a/hwdef.c
// channel modes
// * 0. FET+N+1 stacked
diff --git a/hw/hank/emisar-d4/hwdef.h b/hw/hank/emisar-d4/hwdef.h
index 55ef72e..6257ddb 100644
--- a/hw/hank/emisar-d4/hwdef.h
+++ b/hw/hank/emisar-d4/hwdef.h
@@ -12,9 +12,7 @@
* ----
*/
-#include <avr/io.h>
-
-#define HWDEF_C_FILE hank/emisar-d4/hwdef.c
+#define HWDEF_C hank/emisar-d4/hwdef.c
// allow using aux LEDs as extra channel modes (when they exist)
//#ifdef AUXLED_PIN
diff --git a/hw/hank/emisar-d4k-3ch/hwdef.h b/hw/hank/emisar-d4k-3ch/hwdef.h
index 7cfe699..81206c2 100644
--- a/hw/hank/emisar-d4k-3ch/hwdef.h
+++ b/hw/hank/emisar-d4k-3ch/hwdef.h
@@ -35,9 +35,7 @@
* So this code should support both wire layouts.
*/
-#include <avr/io.h>
-
-#define HWDEF_C_FILE hank/emisar-d4k-3ch/hwdef.c
+#define HWDEF_C hank/emisar-d4k-3ch/hwdef.c
// allow using aux LEDs as extra channel modes
#include "fsm/chan-rgbaux.h"
@@ -132,38 +130,10 @@ uint8_t led4_pwm, led4_dsm;
#define SWITCH_PCMSK PCMSK0 // PCMSK1 is for PCINT[7:0]
#define SWITCH_PORT PINA // PINA or PINB or PINC
#define SWITCH_PUE PUEA // pullup group A
-#define PCINT_vect PCINT0_vect // ISR for PCINT[7:0]
+#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-d4sv2/hwdef.h b/hw/hank/emisar-d4sv2/hwdef.h
index d1e0452..121593a 100644
--- a/hw/hank/emisar-d4sv2/hwdef.h
+++ b/hw/hank/emisar-d4sv2/hwdef.h
@@ -30,9 +30,7 @@
* ADC12 thermal sensor
*/
-#include <avr/io.h>
-
-#define HWDEF_C_FILE hank/emisar-d4sv2/hwdef.c
+#define HWDEF_C hank/emisar-d4sv2/hwdef.c
// allow using aux LEDs as extra channel modes
#include "fsm/chan-rgbaux.h"
@@ -89,7 +87,7 @@ enum CHANNEL_MODES {
#define SWITCH_PCMSK PCMSK0 // PCMSK0 is for PCINT[7:0]
#define SWITCH_PORT PINA // PINA or PINB or PINC
#define SWITCH_PUE PUEA // pullup group A
-#define PCINT_vect PCINT0_vect // ISR for PCINT[7:0]
+#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
#define ADC_PRSCL 0x07 // clk/128
diff --git a/hw/hank/emisar-d4v2/hwdef.h b/hw/hank/emisar-d4v2/hwdef.h
index 9e3f755..1c10004 100644
--- a/hw/hank/emisar-d4v2/hwdef.h
+++ b/hw/hank/emisar-d4v2/hwdef.h
@@ -28,10 +28,8 @@
* ADC12 thermal sensor
*/
-#include <avr/io.h>
-
-#ifndef HWDEF_C_FILE
-#define HWDEF_C_FILE hank/emisar-d4v2/hwdef.c
+#ifndef HWDEF_C
+#define HWDEF_C hank/emisar-d4v2/hwdef.c
#endif
// allow using aux LEDs as extra channel modes
@@ -84,7 +82,7 @@ enum CHANNEL_MODES {
#define SWITCH_PCMSK PCMSK0 // PCMSK0 is for PCINT[7:0]
#define SWITCH_PORT PINA // PINA or PINB or PINC
#define SWITCH_PUE PUEA // pullup group A
-#define PCINT_vect PCINT0_vect // ISR for PCINT[7:0]
+#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
#define ADC_PRSCL 0x07 // clk/128
diff --git a/hw/hank/emisar-d4v2/nofet/anduril.h b/hw/hank/emisar-d4v2/nofet/anduril.h
index b5f9304..e05fb2e 100644
--- a/hw/hank/emisar-d4v2/nofet/anduril.h
+++ b/hw/hank/emisar-d4v2/nofet/anduril.h
@@ -4,7 +4,7 @@
#pragma once
// switch to 1-channel support functions
-#define HWDEF_C_FILE hank/emisar-d4v2/nofet/hwdef.c
+#define HWDEF_C hank/emisar-d4v2/nofet/hwdef.c
#include "hank/emisar-d4v2/anduril.h"
diff --git a/hw/hank/noctigon-dm11/boost/hwdef.h b/hw/hank/noctigon-dm11/boost/hwdef.h
index 5ac2daf..789eac9 100644
--- a/hw/hank/noctigon-dm11/boost/hwdef.h
+++ b/hw/hank/noctigon-dm11/boost/hwdef.h
@@ -36,9 +36,7 @@
* not to change brightness.
*/
-#include <avr/io.h>
-
-#define HWDEF_C_FILE hank/noctigon-dm11/boost/hwdef.c
+#define HWDEF_C hank/noctigon-dm11/boost/hwdef.c
// allow using aux LEDs as extra channel modes
#include "fsm/chan-rgbaux.h"
@@ -101,37 +99,9 @@ uint8_t ch1_pwm, ch1_dsm;
#define SWITCH_PCMSK PCMSK0 // PCMSK0 is for PCINT[7:0]
#define SWITCH_PORT PINA // PINA or PINB or PINC
#define SWITCH_PUE PUEA // pullup group A
-#define PCINT_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
+#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
+
+#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 cd21eae..3e3d426 100644
--- a/hw/hank/noctigon-dm11/hwdef.h
+++ b/hw/hank/noctigon-dm11/hwdef.h
@@ -37,10 +37,8 @@
* Some models also have a direct-drive FET for turbo.
*/
-#include <avr/io.h>
-
-#ifndef HWDEF_C_FILE
-#define HWDEF_C_FILE hank/noctigon-kr4/hwdef.c
+#ifndef HWDEF_C
+#define HWDEF_C hank/noctigon-kr4/hwdef.c
#endif
// allow using aux LEDs as extra channel modes
@@ -95,38 +93,10 @@ enum CHANNEL_MODES {
#define SWITCH_PCMSK PCMSK0 // PCMSK0 is for PCINT[7:0]
#define SWITCH_PORT PINA // PINA or PINB or PINC
#define SWITCH_PUE PUEA // pullup group A
-#define PCINT_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
+#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
+
+
+#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/nofet/anduril.h b/hw/hank/noctigon-dm11/nofet/anduril.h
index 12336f1..c13f4ab 100644
--- a/hw/hank/noctigon-dm11/nofet/anduril.h
+++ b/hw/hank/noctigon-dm11/nofet/anduril.h
@@ -4,7 +4,7 @@
#pragma once
// same support functions as a KR4
-#define HWDEF_C_FILE hank/noctigon-kr4/nofet/hwdef.c
+#define HWDEF_C hank/noctigon-kr4/nofet/hwdef.c
#include "hank/noctigon-dm11/anduril.h"
// turn off the DD FET
diff --git a/hw/hank/noctigon-k1/boost/hwdef.h b/hw/hank/noctigon-k1/boost/hwdef.h
index 951932a..db1584c 100644
--- a/hw/hank/noctigon-k1/boost/hwdef.h
+++ b/hw/hank/noctigon-k1/boost/hwdef.h
@@ -34,9 +34,7 @@
* not to change brightness.
*/
-#include <avr/io.h>
-
-#define HWDEF_C_FILE hank/noctigon-dm11/boost/hwdef.c
+#define HWDEF_C hank/noctigon-dm11/boost/hwdef.c
// allow using aux LEDs as extra channel modes
#include "fsm/chan-rgbaux.h"
@@ -99,37 +97,9 @@ uint8_t ch1_pwm, ch1_dsm;
#define SWITCH_PCMSK PCMSK0 // PCMSK0 is for PCINT[7:0]
#define SWITCH_PORT PINA // PINA or PINB or PINC
#define SWITCH_PUE PUEA // pullup group A
-#define PCINT_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
+#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
+
+#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 9a68401..0d20871 100644
--- a/hw/hank/noctigon-k1/hwdef.h
+++ b/hw/hank/noctigon-k1/hwdef.h
@@ -36,10 +36,8 @@
* not to change brightness.
*/
-#include <avr/io.h>
-
-#ifndef HWDEF_C_FILE
-#define HWDEF_C_FILE hank/noctigon-k1/hwdef.c
+#ifndef HWDEF_C
+#define HWDEF_C hank/noctigon-k1/hwdef.c
#endif
// allow using aux LEDs as extra channel modes
@@ -88,38 +86,10 @@ enum CHANNEL_MODES {
#define SWITCH_PCMSK PCMSK0 // PCMSK0 is for PCINT[7:0]
#define SWITCH_PORT PINA // PINA or PINB or PINC
#define SWITCH_PUE PUEA // pullup group A
-#define PCINT_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
+#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
+
+
+#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 8186b49..e2d04a9 100644
--- a/hw/hank/noctigon-k1/sbt90/hwdef.h
+++ b/hw/hank/noctigon-k1/sbt90/hwdef.h
@@ -37,9 +37,7 @@
* Also has a direct-drive FET for turbo.
*/
-#include <avr/io.h>
-
-#define HWDEF_C_FILE hank/noctigon-kr4/hwdef.c
+#define HWDEF_C hank/noctigon-kr4/hwdef.c
// allow using aux LEDs as extra channel modes
#include "fsm/chan-rgbaux.h"
@@ -93,38 +91,9 @@ enum CHANNEL_MODES {
#define SWITCH_PCMSK PCMSK1 // PCMSK1 is for PCINT[11:8]
#define SWITCH_PORT PINB // PINA or PINB or PINC
#define SWITCH_PUE PUEB // pullup group B
-#define PCINT_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
+#define SWITCH_VECT PCINT1_vect // ISR for PCINT[11:8]
+
+#include "hank/vdivider-1634.h"
#define TEMP_CHANNEL 0b00001111
diff --git a/hw/hank/noctigon-kr4/2ch/hwdef.h b/hw/hank/noctigon-kr4/2ch/hwdef.h
index b23c7cc..28a686d 100644
--- a/hw/hank/noctigon-kr4/2ch/hwdef.h
+++ b/hw/hank/noctigon-kr4/2ch/hwdef.h
@@ -30,8 +30,6 @@
* ADC12 thermal sensor
*/
-#include <avr/io.h>
-
// move the switch to a different pin
#define SWITCH_PIN PB2 // pin 17
#define SWITCH_PCINT PCINT10 // pin 17 pin change interrupt
@@ -39,7 +37,7 @@
#define SWITCH_PCMSK PCMSK1 // PCMSK1 is for PCINT[11:8]
#define SWITCH_PORT PINB // PINA or PINB or PINC
#define SWITCH_PUE PUEB // pullup group B
-#define PCINT_vect PCINT1_vect // ISR for PCINT[11:8]
+#define SWITCH_VECT PCINT1_vect // ISR for PCINT[11:8]
// the rest of the config is the same as the generic Emisar 2ch build
#include "hank/emisar-2ch/hwdef.h"
diff --git a/hw/hank/noctigon-kr4/boost/hwdef.h b/hw/hank/noctigon-kr4/boost/hwdef.h
index f17d263..b923b30 100644
--- a/hw/hank/noctigon-kr4/boost/hwdef.h
+++ b/hw/hank/noctigon-kr4/boost/hwdef.h
@@ -46,12 +46,12 @@
#undef SWITCH_PCMSK
#undef SWITCH_PORT
#undef SWITCH_PUE
-#undef PCINT_vect
+#undef SWITCH_VECT
#define SWITCH_PIN PB2 // pin 17
#define SWITCH_PCINT PCINT10 // pin 17 pin change interrupt
#define SWITCH_PCIE PCIE1 // PCIE1 is for PCINT[11:8]
#define SWITCH_PCMSK PCMSK1 // PCMSK1 is for PCINT[11:8]
#define SWITCH_PORT PINB // PINA or PINB or PINC
#define SWITCH_PUE PUEB // pullup group B
-#define PCINT_vect PCINT1_vect // ISR for PCINT[11:8]
+#define SWITCH_VECT PCINT1_vect // ISR for PCINT[11:8]
diff --git a/hw/hank/noctigon-kr4/hwdef.h b/hw/hank/noctigon-kr4/hwdef.h
index 586f848..49e71fa 100644
--- a/hw/hank/noctigon-kr4/hwdef.h
+++ b/hw/hank/noctigon-kr4/hwdef.h
@@ -35,10 +35,8 @@
* Some models also have a direct-drive FET for turbo.
*/
-#include <avr/io.h>
-
-#ifndef HWDEF_C_FILE
-#define HWDEF_C_FILE hank/noctigon-kr4/hwdef.c
+#ifndef HWDEF_C
+#define HWDEF_C hank/noctigon-kr4/hwdef.c
#endif
// allow using aux LEDs as extra channel modes
@@ -93,41 +91,13 @@ enum CHANNEL_MODES {
#define SWITCH_PCMSK PCMSK1 // PCMSK1 is for PCINT[11:8]
#define SWITCH_PORT PINB // PINA or PINB or PINC
#define SWITCH_PUE PUEB // pullup group B
-#define PCINT_vect PCINT1_vect // ISR for PCINT[11:8]
+#define SWITCH_VECT PCINT1_vect // ISR for PCINT[11:8]
// the button tends to short out the voltage divider,
// 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-kr4/nofet/anduril.h b/hw/hank/noctigon-kr4/nofet/anduril.h
index 4522cde..ad3f012 100644
--- a/hw/hank/noctigon-kr4/nofet/anduril.h
+++ b/hw/hank/noctigon-kr4/nofet/anduril.h
@@ -5,7 +5,7 @@
// (and Noctigon KR1)
// (and Emisar D4v2 E21A, a.k.a. "D4v2.5")
-#define HWDEF_C_FILE hank/noctigon-kr4/nofet/hwdef.c
+#define HWDEF_C hank/noctigon-kr4/nofet/hwdef.c
#include "hank/noctigon-kr4/anduril.h"
// brightness w/ SST-20 4000K LEDs:
diff --git a/hw/hank/noctigon-m44/hwdef.h b/hw/hank/noctigon-m44/hwdef.h
index af942d9..a397212 100644
--- a/hw/hank/noctigon-m44/hwdef.h
+++ b/hw/hank/noctigon-m44/hwdef.h
@@ -28,9 +28,7 @@
* ADC12 thermal sensor
*/
-#include <avr/io.h>
-
-#define HWDEF_C_FILE hank/noctigon-m44/hwdef.c
+#define HWDEF_C hank/noctigon-m44/hwdef.c
// allow using aux LEDs as extra channel modes
#include "fsm/chan-rgbaux.h"
@@ -110,37 +108,9 @@ uint8_t ch2_pwm, ch2_dsm;
#define SWITCH_PCMSK PCMSK0 // PCMSK0 is for PCINT[7:0]
#define SWITCH_PORT PINA // PINA or PINB or PINC
#define SWITCH_PUE PUEA // pullup group A
-#define PCINT_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
+#define SWITCH_VECT PCINT0_vect // ISR for PCINT[7:0]
+
+#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
+
+
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.