aboutsummaryrefslogtreecommitdiff
path: root/hw/hank/noctigon-kr4
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-11-30 09:19:45 -0700
committerSelene ToyKeeper2023-11-30 09:19:45 -0700
commitf745e12c3bc48d8fe544893871191086cf3cccc9 (patch)
tree0e7f6c2c5f362719ac4efad9d5c2365f3ed3c159 /hw/hank/noctigon-kr4
parentadded md5sum to build-all.sh output per target (diff)
parenteliminated direct CCP register access from arch/attiny1616 (diff)
downloadanduril-f745e12c3bc48d8fe544893871191086cf3cccc9.tar.gz
anduril-f745e12c3bc48d8fe544893871191086cf3cccc9.tar.bz2
anduril-f745e12c3bc48d8fe544893871191086cf3cccc9.zip
Merge branch 'avr32dd20-devkit' into trunk
Added support for AVR DD MCUs, particularly avr32dd20. Also did a bunch of refactoring for how MCU support works, cleaned up the ADC code, switched to consistent internal formats for voltage and temperature, fixed the FW3X, and some other little things. * avr32dd20-devkit: (28 commits) eliminated direct CCP register access from arch/attiny1616 made the avr32dd20 flashing script more universal added a build target for FW3X with manually-fixed RGB aux wiring prevent future issues like the FW3X had fixed FW3X thermal regulation fixed incorrect temperature history for a few seconds after waking fsm/adc: removed dead code FW3X: fixed external temperature sensor FW3X: multiple upgrades... fw3x: fixed swapped red+blue, fixed battery measurements, added police color strobe fixed ADC on sp10-pro fixed ADC on attiny85 and related builds fixed ADC on attiny1634 and related builds more ADC / DAC / MCU progress... avr32dd20-devkit: make the defaults a bit more dev friendly (realtime voltage colors, and no simple UI by default) ADC voltage: battcheck 3 digits, fixed t1616, switched back to 8-bit internal volt unit got ADC voltage+temp working on avrdd... but broke all other builds/MCUs 1.55V AA battery should not show as "white" voltage color, only purple started refactoring fsm/adc.*, but need a checkpoint before continuing added dac-scale.py: short script to calculate avrdd DAC+Vref values from level_calc.py ramp data ...
Diffstat (limited to 'hw/hank/noctigon-kr4')
-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
4 files changed, 8 insertions, 40 deletions
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: