~toykeeper/flashlight-firmware/lume1

« back to all changes in this revision

Viewing changes to ToyKeeper/hwdef-fw3x-lume1.h

  • Committer: Selene Scriven
  • Date: 2020-09-07 06:30:12 UTC
  • Revision ID: bzr@toykeeper.net-20200907063012-mfu8ove5jiybs3v7
adjusted Lume1 (FW3X) cfg and hwdef according to what seems right for it
(but it's not tested since I have no relevant hardware...  need to get
 it tested by someone who has the hardware)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
3
3
 
4
4
/* lume1 Driver Rev B for FW3x driver layout (attiny1634)
5
5
 * www.loneoceans.com/labs/ for more information
9
9
 *   2    PA5   R red aux LED (PWM0B)
10
10
 *   3    PA4   G green aux LED
11
11
 *   4    PA3   B blue aux LED
12
 
 *   5    PA2   e-switch (PCINT2) 
 
12
 *   5    PA2   e-switch (PCINT2)
13
13
 *   6    PA1   Jumper 1
14
 
 *   7    PA0   Jumper 2 
 
14
 *   7    PA0   Jumper 2
15
15
 *   8    GND   GND
16
16
 *   9    VCC   VCC
17
17
 *  10    PC5   Jumper 3
25
25
 *  18    PB1   MOSI
26
26
 *  19    PB0   ADC5 Voltage Battery Sense (2:1 divider)
27
27
 *  20    PA7   BB_Enable
28
 
 *                              ADC12   internal thermal sensor (not used for lume1)
 
28
 *        ADC12 internal thermal sensor (not used for lume1)
29
29
 *
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
32
 
 * for FET control. 
 
32
 * for FET control.
33
33
 */
34
34
 
35
35
#ifdef ATTINY
66
66
#define JUMPER4_PIN PC4
67
67
*/
68
68
 
69
 
/*
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)
74
 
#endif
75
 
*/
76
 
 
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)
115
111
 
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
123
119
 
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);
131
125
  // FET PWM 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)
139
133
       ;
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);
150
144
  */
151
145
 
152
146
  // configure PWM for 10 bit at 3.9kHz
172
166
 
173
167
#define LAYOUT_DEFINED
174
168
 
175
 
#endif
 
 
b'\\ No newline at end of file'
 
169
#endif