~toykeeper/flashlight-firmware/trunk

« back to all changes in this revision

Viewing changes to Flintrock/bistro-hd/fr-tk-attiny.h

  • Committer: Selene Scriven
  • Date: 2018-07-05 10:22:48 UTC
  • mto: This revision was merged to the branch mainline in revision 209.
  • Revision ID: bzr@toykeeper.net-20180705102248-4157s7ly7ascx0w3
Forked Bistro as a base for Dragon.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef FR_ATTINY_H
2
 
#define FR_ATTINY_H
3
 
/*
4
 
 *  Driver layout header. 
5
 
 *
6
 
 * New layout definition structure 2017, (C) Flintrock (FR).
7
 
 * 
8
 
 * To work with tk-bistro and other compatible software.
9
 
 *
10
 
 * Tried to keep it compatible with
11
 
 * previous version, but likely some failure there.
12
 
 *
13
 
 * Inspired by and mostly compatible with Original version by Selene Scriven (C) 2015  
14
 
 *
15
 
 * This program is free software: you can redistribute it and/or modify
16
 
 * it under the terms of the GNU General Public License as published by
17
 
 * the Free Software Foundation, either version 3 of the License, or
18
 
 * (at your option) any later version.
19
 
 *
20
 
 * This program is distributed in the hope that it will be useful,
21
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 
 * GNU General Public License for more details.
24
 
 *
25
 
 * You should have received a copy of the GNU General Public License
26
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27
 
 *
28
 
 */
29
 
 
30
 
//#define ATTINY 13
31
 
//#define ATTINY 25
32
 
 
33
 
/******************** hardware-specific values **************************/
34
 
#if (ATTINY == 13)
35
 
    #define F_CPU 4800000UL
36
 
        #define _TIMSK_ TIMSK0
37
 
        #define _TIMER0_OVF_vect_ TIM0_OVF_vect
38
 
    #define EEPSIZE 64
39
 
    #define V_REF REFS0
40
 
    #define BOGOMIPS 950
41
 
// adc_prscl belongs here.  It has nothing to do with layout but does relate some to selected F_CPU above.
42
 
   #define ADC_PRSCL   0x06   //  02 is 4, 03, is 8, 04 is 16, 05 is 32, 06 is 64 // adc rate is F_CPU/13/prescale
43
 
 
44
 
#elif (ATTINY == 25) || (ATTINY == 45) || (ATTINY ==85)
45
 
    // TODO: Use 6.4 MHz instead of 8 MHz?
46
 
// FR adds some addresses for use in asm I/O address space
47
 
        #define _TIMSK_ TIMSK
48
 
        #define _TIMER0_OVF_vect_ TIMER0_OVF_vect
49
 
    #define F_CPU 8000000UL
50
 
    #define EEPSIZE 128  // not actually correct for 45 and 85 (256) but doesn't matter.
51
 
    #define V_REF REFS1    // just defines which bit controls the voltage reference.
52
 
                              // since we don't touch REFS0 2.56V is not available (not very useful anyway).
53
 
        #define VCC_REF_PIN 0x00 // ADC ref when using Vcc as a reference really just a 1 bit value. 
54
 
        #define _1V_ADC_INPUT 0x0C // ID For one volt reference when used as input (not reference) to ADC 
55
 
        // Bogomips appears to be used in tk-delay.h
56
 
        // as the number ticks needed for a 1 ms delay where a tick is 4 clock cycles
57
 
        // as defined by _delay_loop2:  
58
 
        // http://www.atmel.com/webdoc/AVRLibcReferenceManual/group__util__delay__basic_1ga74a94fec42bac9f1ff31fd443d419a6a.html
59
 
        // The example there says 65536 corresponds to 261ms for 1Mhz so  250 ticks per ms ie FCPU/4000. 
60
 
        // anyway, the POWERSAVE delay re-implements this with a timer clock instead.
61
 
        #define BOGOMIPS (F_CPU/4000)
62
 
        #define TEMP_CHANNEL 0b00001111
63
 
// Mooved adc_prscl here.  It has nothing to do with layout but does relate to selecte F_CPU above.
64
 
    #define ADC_PRSCL   0x06   //  02 is 4, 03, is 8, 04 is 16, 05 is 32, 06 is 64 // adc rate is F_CPU/13/prescale
65
 
#else
66
 
    Hey, you need to define ATTINY.
67
 
#endif
68
 
 
69
 
// FR's new simplified "auto"-defines, 
70
 
// 2017 by Flintrock (C)
71
 
// Just define which PWM channels you want, then the extras.
72
 
// Also just define everything by PORTB (PB) number.  Lookups work out the other details automatically.
73
 
 
74
 
#ifdef CUSTOM_LAYOUT
75
 
// A layout for you to customize
76
 
 
77
 
/*
78
 
 *             ----
79
 
 *        PB5               Reset -|1  8|- VCC
80
 
 *        PB3    PWM4/OTC/ESWITCH -|2  7|- Voltage/OTSM/ESWITCH    PB2    
81
 
 *        PB4                PWM3 -|3  6|- PWM1                    PB1    
82
 
 *                            GND -|4  5|- PWM2                    PB0    
83
 
 *             ----
84
 
 */
85
 
 
86
 
// ALL numbers use PB numbers
87
 
// First choose which PWM pins to use.  
88
 
//#define ENABLE_PWM1           // PWM on pb1  (pin 5)  Single 7135 usually
89
 
//#define ENABLE_PWM2           // PWM on pb0  (pin 6)  FET in FET+1 or 7135s in triple
90
 
//#define ENABLE_PWM3           // PWM on pb4  (pin 3)  FET in triple channel
91
 
//#define ENABLE_PWM4         // PWM on pb3  (pin 2)  Can be used for RGBW setup.  
92
 
 
93
 
// ASSIGN PINS FOR EXTRA FEATURES, You can change the pin numbers within reason. They can overlap in some cases.
94
 
//#define CAP_PIN        PB3       // OTC CAP or secondary OTSM CAP
95
 
//#define VOLTAGE_PIN    PB2       // set to pb number or VCC Only PB2,PB3, PB4 and VCC are really valid
96
 
//#define OTSM_PIN       PB2       // PIN to check for voltage shutoff.  Requires #define OTSM in bistro.c to activate.
97
 
//#define ESWITCH_PIN    PB3       // Usually instead of CAP_PIN. Requires #define USE_ESWITCH in bistro.c to activate.
98
 
                                 // Can double/triple up on the OTSM/Voltage PIN (e: 4 channel driver) by shorting R2 with the e_switch.
99
 
                                                                 // Could even pull it to 0.5V and distinguish the two switches with ADC. (not implemented)
100
 
 
101
 
//#define STAR2_PIN      PB0 // These have no purpose in the bistro software.
102
 
//#define STAR3_PIN      PB4
103
 
//#define STAR4_PIN      PB3
104
 
 
105
 
/* Note: you can define/uncomment multiple functions for a pin even if some are not used for a particular compilation.
106
 
*  Which functions are used are defined in bistro.
107
 
*  Ex, if you define ESWITCH and Voltage on the same pin (a legitimate combination anyway), but you define  READ_VOLTAGE_FROM_VCC in bistro,
108
 
* bistro will enable a pull-up resistor on the pin to define the open-switch state, in theory at least.  In contrast if READ_VOLTAGE_FROM divider
109
 
* is defined, it will disable the pull-up on the voltage pin. Pull-up on OTSM_PIN is also disabled if USE_OTSM is defined in bistro.
110
 
*/
111
 
 
112
 
 
113
 
 
114
 
#endif // CUSTOM_LAYOUT
115
 
 
116
 
//FR's new simplified "auto"-defines
117
 
// you can't really pick and choose where to put pwms 
118
 
// without changing the initialization code.. so define 4 and just choose which ones you want:
119
 
// Also just define everything by PB number, use lookups to work it out below the config settings.
120
 
 
121
 
#ifdef TRIPLEDOWN_LAYOUT
122
 
/*
123
 
 *             ----
124
 
 *        PB5        Reset -|1  8|- VCC
125
 
 *        PB3  ESWITCH/OTC -|2  7|- Voltage ADC/OTSM/INDICATOR   PB2    
126
 
 *        PB4   PWM3 (FET) -|3  6|- PWM1 (6x7135)                PB1    
127
 
 *                     GND -|4  5|- PWM2 (1x7135)                PB0    
128
 
 *             ----
129
 
 */
130
 
 
131
 
// ALL numbers use PB numbers
132
 
// First choose which PWM pins to use.  
133
 
#define ENABLE_PWM1           // PWM on pb1  (pin 5)  Single 7135 usually
134
 
#define ENABLE_PWM2           // PWM on pb0  (pin 6)  FET in FET+1 or 7135s in triple
135
 
#define ENABLE_PWM3           // PWM on pb4  (pin 3)  FET in triple channel
136
 
//#define ENABLE_PWM4         // PWM on pb3  (pin 2)  Can be used for RGBW setup
137
 
 
138
 
// SELECT PINS FOR EXTRA FEATURES, these may overlap in some cases.
139
 
#define CAP_PIN        PB3       // OTC CAP or secondary OTSM CAP
140
 
#define VOLTAGE_PIN    PB2       //  PB2,PB3, PB4 are only really valid.  If using VCC it's ignored.
141
 
#define INDICATOR_PIN  PB2       // This only gets used if enabled with #define USE_INDICATOR in main config
142
 
#define OTSM_PIN       PB2       // PIN to check for voltage shutoff (clicky).  Requires #define OTSM in bistro.c to activate.
143
 
                                 // This can be the same as the voltage pin, if the voltage is kept > 1.8V while on.
144
 
                                                                 // That generally requires using an LDO as a VCC voltage reference.
145
 
#define ESWITCH_PIN    PB3       // Usually instead of CAP_PIN. Requires #define USE_ESWITCH in bistro.c to activate.
146
 
                                 // Can double/triple up on the OTSM/Voltage PIN (e: 4 channel driver) by shorting R2 with the e_switch.
147
 
                                                                 // Could even pull it to 0.5V and distinguish the two switches with ADC. (not implemented)
148
 
 
149
 
//#define STAR2_PIN      PB0 // These have no purpose in the bistro software.
150
 
//#define STAR3_PIN      PB4
151
 
//#define STAR4_PIN      PB3
152
 
 
153
 
/* Note: you can define/uncomment multiple functions for a pin even if some are not used for a particular compilation.
154
 
*  Which functions are used are defined in bistro.
155
 
*  Ex, if you define ESWITCH and Voltage on the same pin (a legitimate combination anyway), but you define  READ_VOLTAGE_FROM_VCC in bistro,
156
 
* bistro will enable a pull-up resistor on the pin to define the open-switch state, in theory at least.  In contrast if READ_VOLTAGE_FROM divider
157
 
* is defined, it will disable the pull-up on the voltage pin. Pull-up on OTSM_PIN is also disabled if USE_OTSM is defined in bistro.
158
 
*/
159
 
 
160
 
 
161
 
 
162
 
#endif // TRIPLE_DOWN_LAYOUT
163
 
 
164
 
/*********************************************************************/
165
 
 
166
 
#ifdef QUADRUPLEDOWN_LAYOUT
167
 
// An example of a Quad layout, although the real point here is that these can easily be configured "on the fly" as needed.
168
 
 
169
 
/*
170
 
 *             ----
171
 
 *        PB5        Reset -|1  8|- VCC
172
 
 *        PB3    PWM4 Blue -|2  7|- Voltage ADC  PB2    
173
 
 *        PB4     PWM3 Red -|3  6|- PWM1 White   PB1    
174
 
 *                     GND -|4  5|- PWM2 Green   PB0    
175
 
 *             ----
176
 
 */
177
 
 
178
 
// ALL numbers use PB numbers
179
 
// First choose which PWM pins to use.  
180
 
#define ENABLE_PWM1           // PWM on pb1  (pin 5)  Single 7135 usually
181
 
#define ENABLE_PWM2           // PWM on pb0  (pin 6)  FET in FET+1 or 7135s in triple
182
 
#define ENABLE_PWM3           // PWM on pb4  (pin 3)  FET in triple channel
183
 
#define ENABLE_PWM4         // PWM on pb3  (pin 2)  Can be used for RGBW setup
184
 
 
185
 
// SELECT PINS FOR EXTRA FEATURES, these may overlap in some cases.
186
 
//#define CAP_PIN        PB3     // OTC CAP or secondary OTSM CAP
187
 
#define VOLTAGE_PIN    PB2       // set to pb number or VCC Only PB2,PB3, PB4 and VCC are really valid
188
 
#define OTSM_PIN       PB2       // PIN to check for voltage shutoff.  Requires #define OTSM in bistro.c to activate.
189
 
#define ESWITCH_PIN    PB2       // Usually instead of CAP_PIN. Requires #define USE_ESWITCH in bistro.c to activate.
190
 
                                 // Can double/triple up on the OTSM/Voltage PIN (e: 4 channel driver) by shorting R2 with the e_switch.
191
 
                                                                 // Could even pull it to 0.5V and distinguish the two switches with ADC. (not implemented)
192
 
 
193
 
//#define STAR2_PIN      PB0     // These have no purpose in the bistro software.
194
 
//#define STAR3_PIN      PB4
195
 
//#define STAR4_PIN      PB3
196
 
 
197
 
 
198
 
 
199
 
#endif // QUADRUPLE_DOWN_LAYOUT
200
 
 
201
 
/*********************************************************************/
202
 
 
203
 
/*********************************************************************/
204
 
 
205
 
//* Q8  Diagram
206
 
/*
207
 
 *             ----
208
 
 *        PB5        Reset -|1  8|- VCC
209
 
 *        PB3     e-switch -|2  7|- Voltage         PB2 (stock: unused)    
210
 
 *        PB4  IndicatorLED-|3  6|- PWM (FET)       PB1    
211
 
 *                     GND -|4  5|- PWM2 (1x7135)   PB0    
212
 
 *             ----
213
 
 */
214
 
 
215
 
#ifdef Q8_LAYOUT
216
 
// First choose which PWM pins to use.
217
 
#define ENABLE_PWM1           // PWM on pb1  (pin 5)  Single 7135 usually
218
 
#define ENABLE_PWM2           // PWM on pb0  (pin 6)  FET in FET+1 or 7135s in triple
219
 
//#define ENABLE_PWM3           // PWM on pb4  (pin 3)  FET in triple channel
220
 
//#define ENABLE_PWM4         // PWM on pb3  (pin 2)  Can be used for RGBW setup
221
 
 
222
 
// SELECT PINS FOR EXTRA FEATURES, these may overlap in some cases.
223
 
//#define CAP_PIN        PB3       // OTC CAP or secondary OTSM CAP
224
 
#define VOLTAGE_PIN    PB2       // set to pb number or VCC Only PB2,PB3, PB4 and VCC are really valid
225
 
//#define OTSM_PIN       PB2       // PIN to check for voltage shutoff
226
 
#define ESWITCH_PIN    PB3       // usually instead of CAP_PIN but could double up on OTSM PIN
227
 
#define INDICATOR_PIN  PB4         // indicator LED.
228
 
//#define STAR3_PIN        PB4
229
 
 
230
 
// adc rate is F_CPU/13/prescale
231
 
 
232
 
#endif  // BLFA6_LAYOUT
233
 
 
234
 
 
235
 
#ifdef FET_7135_LAYOUT
236
 
 
237
 
/*
238
 
 *             ----
239
 
 *        PB5        Reset -|1  8|- VCC
240
 
 *        PB3          OTC -|2  7|- PWM4 Blue    PB2    
241
 
 *        PB4     PWM3 Red -|3  6|- PWM1 White   PB1    
242
 
 *                     GND -|4  5|- PWM2 Green   PB0    
243
 
 *             ----
244
 
 */
245
 
 
246
 
// ALL numbers use PB numbers
247
 
// First choose which PWM pins to use.
248
 
#define ENABLE_PWM1           // PWM on pb1  (pin 5)  Single 7135 usually
249
 
#define ENABLE_PWM2           // PWM on pb0  (pin 6)  FET in FET+1 or 7135s in triple
250
 
//#define ENABLE_PWM3           // PWM on pb4  (pin 3)  FET in triple channel
251
 
//#define ENABLE_PWM4         // PWM on pb3  (pin 2)  Can be used for RGBW setup
252
 
 
253
 
// SELECT PINS FOR EXTRA FEATURES, these may overlap in some cases.
254
 
#define CAP_PIN        PB3       // OTC CAP or secondary OTSM CAP
255
 
#define VOLTAGE_PIN    PB2       // set to pb number or VCC Only PB2,PB3, PB4 and VCC are really valid
256
 
//#define OTSM_PIN       PB2       // PIN to check for voltage shutoff
257
 
//#define ESWITCH_PIN    PB3       // usually instead of CAP_PIN but could double up on OTSM PIN
258
 
#define STAR2_PIN PB0             // These have no purpose in the bistro software.
259
 
#define STAR3_PIN PB4
260
 
 
261
 
 
262
 
#endif //FET_7135_LAYOUT
263
 
 
264
 
/*********************************************************************/
265
 
 
266
 
#ifdef FERRERO_ROCHER_LAYOUT
267
 
/*
268
 
 *            ----
269
 
 *    Reset -|1  8|- VCC
270
 
 * E-switch -|2  7|- Voltage ADC
271
 
 *  Red LED -|3  6|- PWM
272
 
 *      GND -|4  5|- Green LED
273
 
 *            ----
274
 
 */
275
 
// ALL numbers use PB numbers
276
 
// First choose which PWM pins to use.
277
 
#define ENABLE_PWM1           // PWM on pb1  (pin 5)  Single 7135 usually               (PWM)
278
 
#define ENABLE_PWM2           // PWM on pb0  (pin 6)  FET in FET+1 or 7135s in triple  (GREEN)
279
 
#define ENABLE_PWM3           // PWM on pb4  (pin 3)  FET in triple channel            (RED)
280
 
//#define ENABLE_PWM4         // PWM on pb3  (pin 2)  Can be used for RGBW setup
281
 
 
282
 
// SELECT PINS FOR EXTRA FEATURES, these may overlap in some cases.
283
 
//#define CAP_PIN        PB3       // OTC CAP or secondary OTSM CAP
284
 
#define VOLTAGE_PIN    PB2       // set to pb number or VCC Only PB2,PB3, PB4 and VCC are really valid
285
 
//#define OTSM_PIN       PB2       // PIN to check for voltage shutoff
286
 
#define ESWITCH_PIN    PB3       // usually instead of CAP_PIN but could double up on OTSM PIN
287
 
//#define STAR2_PIN        PB0    // These have no purpose in the bistro software.
288
 
//#define STAR3_PIN        PB4
289
 
//#define STAR4_PIN        PB3
290
 
 
291
 
// adc rate is F_CPU/13/prescale
292
 
 
293
 
#endif  // FERRERO_ROCHER_LAYOUT
294
 
 
295
 
 
296
 
/*********************************************************************/
297
 
 
298
 
//* NANJG 105C Diagram
299
 
/*
300
 
 *             ----
301
 
 *        PB5        Reset -|1  8|- VCC
302
 
 *        PB3          OTC -|2  7|- Voltage ADC     PB2    
303
 
 *        PB4        Star 3-|3  6|- PWM (FET)       PB1    
304
 
 *                     GND -|4  5|- PWM2 (1x7135)   PB0    
305
 
 *             ----
306
 
 */
307
 
 
308
 
#ifdef BLFA6_LAYOUT
309
 
// First choose which PWM pins to use.
310
 
#define ENABLE_PWM1           // PWM on pb1  (pin 5)  Single 7135 usually
311
 
#define ENABLE_PWM2           // PWM on pb0  (pin 6)  FET in FET+1 or 7135s in triple
312
 
//#define ENABLE_PWM3           // PWM on pb4  (pin 3)  FET in triple channel
313
 
//#define ENABLE_PWM4         // PWM on pb3  (pin 2)  Can be used for RGBW setup
314
 
 
315
 
// SELECT PINS FOR EXTRA FEATURES, these may overlap in some cases.
316
 
#define CAP_PIN        PB3       // OTC CAP or secondary OTSM CAP
317
 
#define VOLTAGE_PIN    PB2       // set to pb number or VCC Only PB2,PB3, PB4 and VCC are really valid
318
 
//#define OTSM_PIN       PB2       // PIN to check for voltage shutoff
319
 
//#define ESWITCH_PIN    PB3       // usually instead of CAP_PIN but could double up on OTSM PIN
320
 
#define STAR3_PIN        PB4
321
 
 
322
 
// adc rate is F_CPU/13/prescale
323
 
 
324
 
#endif  // BLFA6_LAYOUT
325
 
 
326
 
 
327
 
//* NANJG 105D Convoy/biscotti
328
 
/*
329
 
 *             ----
330
 
 *        PB5        Reset -|1  8|- VCC
331
 
 *        PB3              -|2  7|- Voltage ADC     PB2    
332
 
 *        PB4              -|3  6|-                 PB1    
333
 
 *                     GND -|4  5|- PWM2 (FET)      PB0    
334
 
 *             ----
335
 
 */
336
 
 
337
 
#ifdef NANJG105D_LAYOUT
338
 
// First choose which PWM pins to use.
339
 
//#define ENABLE_PWM1           // PWM on pb1  (pin 5)  Single 7135 usually
340
 
#define ENABLE_PWM2           // PWM on pb0  (pin 6)  FET in FET+1 or 7135s in triple
341
 
//#define ENABLE_PWM3           // PWM on pb4  (pin 3)  FET in triple channel
342
 
//#define ENABLE_PWM4         // PWM on pb3  (pin 2)  Can be used for RGBW setup
343
 
 
344
 
// SELECT PINS FOR EXTRA FEATURES, these may overlap in some cases.
345
 
//#define CAP_PIN        PB3       // OTC CAP or secondary OTSM CAP
346
 
#define VOLTAGE_PIN    PB2       // set to pb number or VCC Only PB2,PB3, PB4 and VCC are really valid
347
 
//#define OTSM_PIN       PB2       // PIN to check for voltage shutoff
348
 
//#define ESWITCH_PIN    PB3       // usually instead of CAP_PIN but could double up on OTSM PIN
349
 
//#define STAR3_PIN        PB4
350
 
 
351
 
// adc rate is F_CPU/13/prescale
352
 
 
353
 
#endif  // BLFA6_LAYOUT
354
 
 
355
 
 
356
 
#ifdef NANJG_LAYOUT // is this even right for anything?
357
 
// First choose which PWM pins to use.
358
 
#define ENABLE_PWM1           // PWM on pb1  (pin 5)  Single 7135 usually
359
 
//#define ENABLE_PWM2           // PWM on pb0  (pin 6)  FET in FET+1 or 7135s in triple
360
 
//#define ENABLE_PWM3           // PWM on pb4  (pin 3)  FET in triple channel
361
 
//#define ENABLE_PWM4         // PWM on pb3  (pin 2)  Can be used for RGBW setup
362
 
 
363
 
// SELECT PINS FOR EXTRA FEATURES, these may overlap in some cases.
364
 
//#define CAP_PIN        PB3       // OTC CAP or secondary OTSM CAP
365
 
#define VOLTAGE_PIN    PB2       // set to pb number or VCC Only PB2,PB3, PB4 and VCC are really valid
366
 
//#define OTSM_PIN       PB2       // PIN to check for voltage shutoff
367
 
//#define ESWITCH_PIN    PB3       // usually instead of CAP_PIN but could double up on OTSM PIN
368
 
#define STAR2_PIN        PB0        // These have no purpose in the bistro software.
369
 
#define STAR3_PIN        PB4
370
 
#define STAR4_PIN        PB3
371
 
 
372
 
// adc rate is F_CPU/13/prescale
373
 
 
374
 
#endif  // NANJG_LAYOUT
375
 
 
376
 
 
377
 
/*************************************************END OF LAYOUT DEFINITIONS*********************************************/
378
 
/*******************You should not need to edit below here**************************************************************/
379
 
// Below are universal associations, mostly to define the PWM OCR associations and adc_mux 
380
 
// corresponding to selected pins.
381
 
// the idea is these would eventually go after all defines.
382
 
// 
383
 
 
384
 
#ifdef ENABLE_PWM1
385
 
  #define PWM_PIN     PB1     // pin 6, FET PWM
386
 
  #define PWM1_LVL     OCR0B   // OCR0B is the output compare register for PB1
387
 
#endif
388
 
 
389
 
#ifdef ENABLE_PWM2
390
 
  #define PWM2_PIN    PB0     // pin 5
391
 
  #define PWM2_LVL    OCR0A   // output compare register for PB4
392
 
  // for backwards compatibility, not used in bistro-HD
393
 
  #define ALT_PWM_PIN PWM2_PIN
394
 
  #define ALT_PWM1_LVL PWM2_LVL
395
 
#endif
396
 
 
397
 
#ifdef ENABLE_PWM3
398
 
  #define PWM3_PIN    PB4     // pin 3
399
 
  #define PWM3_LVL    OCR1B   // output compare register for PB4
400
 
  // for backwards compatibility, not used in bistro-HD
401
 
  #define FET_PWM_PIN      
402
 
  #define FET_PWM1_LVL PWM3_LVL   
403
 
#endif
404
 
 
405
 
#ifdef ENABLE_PWM4
406
 
#define PWM4_PIN    PB3     // pin 3
407
 
#define PWM4_LVL    OCR1A   // output compare register to be used with PB3
408
 
                            // This one does NOT attach to PB3, An interrupt will be used instead.
409
 
#endif
410
 
 
411
 
 
412
 
#if defined(VOLTAGE_PIN) 
413
 
//&& VOLTAGE_PIN != VCC_REF_PIN
414
 
// Should use_vcc just be determined by this config?
415
 
  #define ADC_PIN VOLTAGE_PIN        // SYNONYMS
416
 
  #define ADC_DIDR VOLTAGE_PIN       // Digital input disable bit corresponding with PB2, redundant
417
 
#endif
418
 
 
419
 
#if defined(ADC_PIN) && !defined(VOLTAGE_PIN)
420
 
  #define VOLTAGE_PIN ADC_PIN // for backwards compatibility
421
 
#endif
422
 
 
423
 
 
424
 
#if defined(VOLTAGE_PIN)
425
 
// Lookup the adc channel
426
 
  #if VOLTAGE_PIN == PB2   // is there a more elegant way?
427
 
      #define ADC_CHANNEL 1
428
 
  #elif VOLTAGE_PIN == PB4
429
 
          #define ADC_CHANNEL 2
430
 
  #elif VOLTAGE_PIN == PB3
431
 
      #define ADC_CHANNEL 3
432
 
  #elif VOLTAGE_PIN == PB5  // reset pin, probably going to be... interesting to try.
433
 
      #define ADC_CHANNEL 0  
434
 
  #else
435
 
     No ADC channel exists on the selected VOLTAGE_PIN.  Try PB2, PB3, PB4, or PB5 (PB3 on most drivers).
436
 
  #endif
437
 
#endif
438
 
 
439
 
 
440
 
//#ifndef PWM1_LVL
441
 
 
442
 
//#endif
443
 
 
444
 
 
445
 
 
446
 
 
447
 
#endif  // FR_ATTINY_H