1
#ifndef HWDEF_LUME1_FW3X_REVB_H
2
#define HWDEF_LUME1_FW3X_REVB_H
1
#ifndef HWDEF_FW3X_LUME1_H
2
#define HWDEF_FW3X_LUME1_H
4
4
/* lume1 Driver Rev B for FW3x driver layout (attiny1634)
5
5
* www.loneoceans.com/labs/ for more information
26
26
* 19 PB0 ADC5 Voltage Battery Sense (2:1 divider)
28
* ADC12 internal thermal sensor (not used for lume1)
28
* ADC12 internal thermal sensor (not used for lume1)
30
* Main LED power uses one pin as a global Buck Boost Enable, and
30
* Main LED power uses one pin as a global Buck Boost Enable, and
31
31
* one pin to control the power level via PWM. Another pin is used
66
66
#define JUMPER4_PIN PC4
70
// average drop across diode on this hardware
71
// not applicable for LUME1 driver
72
#ifndef VOLTAGE_FUDGE_FACTOR
73
#define VOLTAGE_FUDGE_FACTOR 4 // add 0.20V (measured 0.22V)
77
69
#define USE_VOLTAGE_DIVIDER // use a dedicated pin, not VCC, because VCC input is flattened
78
70
#define VOLTAGE_PIN PB0 // Pin 19 PB0 ADC5
79
71
// pin to ADC mappings are in DS table 19-4
111
103
// See line 34 and line 209
112
104
#define USE_EXTERNAL_TEMP_SENSOR
113
105
#define ADMUX_THERM_EXTERNAL_SENSOR 0b00001011 // VCC reference (2.5V), Channel PC2
114
#define TEMP_CHANNEL 0b00001111
106
// Used for Lume1 Driver: MCP9700 - T_Celsius = 100*(VOUT - 0.5V)
107
// ADC is 2.5V reference, 0 to 1023
108
// FIXME: due to floating point, this calculation takes 916 extra bytes
109
// (should use an integer equivalent instead)
110
#define EXTERN_TEMP_FORMULA(m) (((m)-205)/4.09)
116
112
// this driver allows for aux LEDs under the optic
117
#define AUXLED_R_PIN PA5 // pin 2
118
#define AUXLED_G_PIN PA4 // pin 3
119
#define AUXLED_B_PIN PA3 // pin 4
120
#define AUXLED_RGB_PORT PORTA // PORTA or PORTB or PORTC
121
#define AUXLED_RGB_DDR DDRA // DDRA or DDRB or DDRC
122
#define AUXLED_RGB_PUE PUEA // PUEA or PUEB or PUEC
113
#define AUXLED_R_PIN PA5 // pin 2
114
#define AUXLED_G_PIN PA4 // pin 3
115
#define AUXLED_B_PIN PA3 // pin 4
116
#define AUXLED_RGB_PORT PORTA // PORTA or PORTB or PORTC
117
#define AUXLED_RGB_DDR DDRA // DDRA or DDRB or DDRC
118
#define AUXLED_RGB_PUE PUEA // PUEA or PUEB or PUEC
124
120
// with so many pins, doing this all with #ifdefs gets awkward...
125
121
// ... so just hardcode it in each hwdef file instead
126
122
// For lume1 driver, no SW support for Auxillary Jumpers X1 to X4 yet!
127
123
inline void hwdef_setup() {
128
124
// enable output ports in Data Direction Registers
129
// Buck Boost Enable Pin
130
// DDRA = (1 << LED_ENABLE_PIN);
132
126
DDRB = (1 << PWM2_PIN);
133
// Main PWM, aux R/G/B
127
// Main PWM, Buck Boost Enable Pin, aux R/G/B
134
128
DDRA = (1 << PWM1_PIN)
129
| (1 << LED_ENABLE_PIN)
135
130
| (1 << AUXLED_R_PIN)
136
131
| (1 << AUXLED_G_PIN)
137
132
| (1 << AUXLED_B_PIN)
138
| (1 << LED_ENABLE_PIN)
140
134
//DDRB&=~(1<<VOLTAGE_PIN); // All pins are input by default
141
135
/* // For Jumpers X1 to X4, no SW support yet
143
137
DDRA &= (1<<JUMPER2_PIN);
144
138
DDRC &= (1<<JUMPER3_PIN);
145
139
DDRC &= (1<<JUMPER4_PIN);
146
PUEA = (1 << JUMPER1_PIN);
147
PUEA = (1 << JUMPER2_PIN);
148
PUEC = (1 << JUMPER3_PIN);
149
PUEC = (1 << JUMPER4_PIN);
140
PUEA = (1 << JUMPER1_PIN);
141
PUEA = (1 << JUMPER2_PIN);
142
PUEC = (1 << JUMPER3_PIN);
143
PUEC = (1 << JUMPER4_PIN);
152
146
// configure PWM for 10 bit at 3.9kHz