diff options
| author | Gabriel Hart | 2021-09-19 14:22:43 -0500 |
|---|---|---|
| committer | Gabriel Hart | 2021-09-19 14:22:43 -0500 |
| commit | c32ae490226e7713492c78bea9168b250513a3a0 (patch) | |
| tree | 1271a15f6a5a29e9b41a62700adacd84f1bfa05a /hwdef-Sofirn_SP10-Pro.h | |
| parent | Merge TK changes thru rev 623 (2021-09-17) (diff) | |
| download | anduril-c32ae490226e7713492c78bea9168b250513a3a0.tar.gz anduril-c32ae490226e7713492c78bea9168b250513a3a0.tar.bz2 anduril-c32ae490226e7713492c78bea9168b250513a3a0.zip | |
SP10 Pro: use dynamic PWM, add hidden firefly, adjust candle amplitude, and tweak party strobe & LVP level
Diffstat (limited to 'hwdef-Sofirn_SP10-Pro.h')
| -rw-r--r-- | hwdef-Sofirn_SP10-Pro.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/hwdef-Sofirn_SP10-Pro.h b/hwdef-Sofirn_SP10-Pro.h index e35728c..4691d04 100644 --- a/hwdef-Sofirn_SP10-Pro.h +++ b/hwdef-Sofirn_SP10-Pro.h @@ -30,6 +30,9 @@ PA1 : Boost Enable #endif #define PWM_CHANNELS 2 +#define PWM_BITS 16 // data type needs 16 bits, not 8 +#define PWM_TOP 255 // highest value used in top half of ramp +#define USE_DYN_PWM // dynamic frequency and speed // Small channel #ifndef PWM1_PIN @@ -43,12 +46,15 @@ PA1 : Boost Enable #define PWM2_LVL TCA0.SINGLE.CMP0 // PB0 is TCA Compare 0 #endif +// PWM parameters of both channels are tied together because they share a counter +#define PWM1_TOP TCA0.SINGLE.PER // holds the TOP value for for variable-resolution PWM + #define LED_ENABLE_PIN PIN1_bp #define LED_ENABLE_PORT PORTA_OUT #define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened #define DUAL_VOLTAGE_FLOOR 20 // for AA/14500 boost drivers, don't indicate low voltage if below this level -#define DUAL_VOLTAGE_LOW_LOW 9 // the lower voltage range's danger zone 0.9 volts (NiMH) +#define DUAL_VOLTAGE_LOW_LOW 8 // the lower voltage range's danger zone 0.8 volts (NiMH) #define ADMUX_VOLTAGE_DIVIDER ADC_MUXPOS_AIN9_gc // which ADC channel to read // Raw ADC readings at 4.4V and 2.2V @@ -108,7 +114,7 @@ inline void hwdef_setup() { // See the manual for other pins, clocks, configs, portmux, etc PORTMUX.CTRLC = PORTMUX_TCA02_ALTERNATE_gc; // Use alternate pin for TCA0:WO2 TCA0.SINGLE.CTRLB = TCA_SINGLE_CMP0EN_bm | TCA_SINGLE_CMP2EN_bm | TCA_SINGLE_WGMODE_DSBOTTOM_gc; - TCA0.SINGLE.PER = 255; + PWM1_TOP = PWM_TOP; TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV1_gc | TCA_SINGLE_ENABLE_bm; } |
