From 3d12b7066d27b591e0283e20ed066bc66e29fbe4 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 10 Nov 2023 21:34:40 -0700 Subject: refactor checkpoint: splitting MCU-specific code into arch/$MCU.[ch] Phew, that's a lot of changes! And there's still a lot more to do... --- hw/hank/emisar-2ch/fet/hwdef.h | 6 ++---- hw/hank/emisar-2ch/hwdef.h | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'hw/hank/emisar-2ch') diff --git a/hw/hank/emisar-2ch/fet/hwdef.h b/hw/hank/emisar-2ch/fet/hwdef.h index 0778e10..06dfeb8 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 - -#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,7 +104,7 @@ 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 diff --git a/hw/hank/emisar-2ch/hwdef.h b/hw/hank/emisar-2ch/hwdef.h index e3707c7..7fbac8e 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 - -#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,7 +101,7 @@ 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 -- cgit v1.2.3 From 1b6f40863b4f08365e39236496d687ab7806ed11 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Mon, 27 Nov 2023 07:31:56 -0700 Subject: fixed ADC on attiny1634 and related builds --- hw/hank/emisar-2ch/fet/hwdef.h | 30 +----------------------------- hw/hank/emisar-2ch/hwdef.h | 30 +----------------------------- 2 files changed, 2 insertions(+), 58 deletions(-) (limited to 'hw/hank/emisar-2ch') 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 -- cgit v1.2.3