// lume1 Driver Rev B for FW3x driver layout (attiny1634) // Copyright (C) 2020-2023 LoneOceans, Selene ToyKeeper // SPDX-License-Identifier: GPL-3.0-or-later #pragma once /* lume1 Driver Rev B for FW3x driver layout (attiny1634) * www.loneoceans.com/labs/ for more information * * Pin / Name / Function in Lume1 Rev B * 1 PA6 Regulated PWM (PWM1B) * 2 PA5 B: blue aux LED (PWM0B) (or red) * 3 PA4 G: green aux LED * 4 PA3 R: red aux LED (or blue) * 5 PA2 e-switch (PCINT2) * 6 PA1 Jumper 1 * 7 PA0 Jumper 2 * 8 GND GND * 9 VCC VCC * 10 PC5 Jumper 3 * 11 PC4 Jumper 4 * 12 PC3 RESET * 13 PC2 External Thermal Sensor (ADC11) * 14 PC1 SCK * 15 PC0 N/C * 16 PB3 FET PWM (PWM1A) * 17 PB2 MISO * 18 PB1 MOSI * 19 PB0 ADC5 Voltage Battery Sense (2:1 divider) * 20 PA7 BB_Enable * ADC12 internal thermal sensor (not used for lume1) * * Main LED power uses one pin as a global Buck Boost Enable, and * one pin to control the power level via PWM. * Another pin is used for DD FET control. */ #define HWDEF_C lumintop/fw3x-lume1/hwdef.c // allow using aux LEDs as extra channel modes #include "fsm/chan-rgbaux.h" // channel modes: // * 0. main LEDs // * 1+. aux RGB #define NUM_CHANNEL_MODES (1 + NUM_RGB_AUX_CHANNEL_MODES) enum CHANNEL_MODES { CM_MAIN = 0, RGB_AUX_ENUMS }; #define DEFAULT_CHANNEL_MODE CM_MAIN // right-most bit first, modes are in fedcba9876543210 order #define CHANNEL_MODES_ENABLED 0b0000000000000001 #define PWM_BITS 16 // 0 to 32640 (0 to 255 PWM + 0 to 127 DSM) at constant kHz #define PWM_DATATYPE uint16_t #define PWM_DATATYPE2 uint32_t // only needs 32-bit if ramp values go over 255 #define PWM1_DATATYPE uint16_t // regulated ramp #define PWM1_GET(x) PWM_GET16(pwm1_levels, x) #define PWM2_DATATYPE uint8_t // DD FET ramp #define PWM2_GET(x) PWM_GET8(pwm2_levels, x) // PWM parameters of both channels are tied together because they share a counter #define PWM_TOP ICR1 // holds the TOP value for variable-resolution PWM #define PWM_TOP_INIT 255 #define PWM_CNT TCNT1 // for checking / resetting phase // (max is (255 << 7), because it's 8-bit PWM plus 7 bits of DSM) #define DSM_TOP (255<<7) // 15-bit resolution leaves 1 bit for carry // timer interrupt for DSM #define DSM_vect TIMER1_OVF_vect #define DSM_INTCTRL TIMSK #define DSM_OVF_bm (1<