~toykeeper/flashlight-firmware/anduril2

« back to all changes in this revision

Viewing changes to RMM/dragon/tk-attiny.h

  • Committer: Selene Scriven
  • Date: 2018-07-05 10:22:48 UTC
  • mto: (188.1.21 trunk)
  • mto: This revision was merged to the branch mainline in revision 354.
  • 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 TK_ATTINY_H
 
2
#define TK_ATTINY_H
 
3
/*
 
4
 * Attiny portability header.
 
5
 * This helps abstract away the differences between various attiny MCUs.
 
6
 *
 
7
 * Copyright (C) 2015 Selene Scriven
 
8
 *
 
9
 * This program is free software: you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation, either version 3 of the License, or
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
 *
 
22
 */
 
23
 
 
24
// Choose your MCU here, or in the main .c file, or in the build script
 
25
//#define ATTINY 13
 
26
//#define ATTINY 25
 
27
 
 
28
/******************** hardware-specific values **************************/
 
29
#if (ATTINY == 13)
 
30
    #define F_CPU 4800000UL
 
31
    #define EEPSIZE 64
 
32
    #define V_REF REFS0
 
33
    #define BOGOMIPS 950
 
34
#elif (ATTINY == 25)
 
35
    // TODO: Use 6.4 MHz instead of 8 MHz?
 
36
    #define F_CPU 8000000UL
 
37
    #define EEPSIZE 128
 
38
    #define V_REF REFS1
 
39
    #define BOGOMIPS (F_CPU/3200)
 
40
#else
 
41
    Hey, you need to define ATTINY.
 
42
#endif
 
43
 
 
44
 
 
45
/******************** I/O pin and register layout ************************/
 
46
#ifdef FET_7135_LAYOUT
 
47
/*
 
48
 *           ----
 
49
 *   Reset -|1  8|- VCC
 
50
 *     OTC -|2  7|- Voltage ADC
 
51
 *  Star 3 -|3  6|- PWM (FET)
 
52
 *     GND -|4  5|- PWM (1x7135)
 
53
 *           ----
 
54
 */
 
55
 
 
56
#define STAR2_PIN   PB0     // If this pin isn't used for ALT_PWM
 
57
#define STAR3_PIN   PB4     // pin 3
 
58
 
 
59
#define CAP_PIN     PB3     // pin 2, OTC
 
60
#define CAP_CHANNEL 0x03    // MUX 03 corresponds with PB3 (Star 4)
 
61
#define CAP_DIDR    ADC3D   // Digital input disable bit corresponding with PB3
 
62
 
 
63
#define PWM_PIN     PB1     // pin 6, FET PWM
 
64
#define PWM_LVL     OCR0B   // OCR0B is the output compare register for PB1
 
65
#define ALT_PWM_PIN PB0     // pin 5, 1x7135 PWM
 
66
#define ALT_PWM_LVL OCR0A   // OCR0A is the output compare register for PB0
 
67
 
 
68
#define VOLTAGE_PIN PB2     // pin 7, voltage ADC
 
69
#define ADC_CHANNEL 0x01    // MUX 01 corresponds with PB2
 
70
#define ADC_DIDR    ADC1D   // Digital input disable bit corresponding with PB2
 
71
#define ADC_PRSCL   0x06    // clk/64
 
72
 
 
73
//#define TEMP_DIDR   ADC4D
 
74
#define TEMP_CHANNEL 0b00001111
 
75
 
 
76
#endif  // FET_7135_LAYOUT
 
77
 
 
78
#ifdef TRIPLEDOWN_LAYOUT
 
79
/*
 
80
 *             ----
 
81
 *     Reset -|1  8|- VCC
 
82
 *       OTC -|2  7|- Voltage ADC
 
83
 * PWM (FET) -|3  6|- PWM (6x7135)
 
84
 *       GND -|4  5|- PWM (1x7135)
 
85
 *             ----
 
86
 */
 
87
 
 
88
#define STAR2_PIN   PB0     // If this pin isn't used for ALT_PWM
 
89
 
 
90
#define CAP_PIN     PB3     // pin 2, OTC
 
91
#define CAP_CHANNEL 0x03    // MUX 03 corresponds with PB3 (Star 4)
 
92
#define CAP_DIDR    ADC3D   // Digital input disable bit corresponding with PB3
 
93
 
 
94
#define PWM_PIN     PB1     // pin 6, 6x7135 PWM
 
95
#define PWM_LVL     OCR0B   // OCR0B is the output compare register for PB1
 
96
#define ALT_PWM_PIN PB0     // pin 5, 1x7135 PWM
 
97
#define ALT_PWM_LVL OCR0A   // OCR0A is the output compare register for PB0
 
98
#define FET_PWM_PIN PB4     // pin 3
 
99
#define FET_PWM_LVL OCR1B   // output compare register for PB4
 
100
 
 
101
#define VOLTAGE_PIN PB2     // pin 7, voltage ADC
 
102
#define ADC_CHANNEL 0x01    // MUX 01 corresponds with PB2
 
103
#define ADC_DIDR    ADC1D   // Digital input disable bit corresponding with PB2
 
104
#define ADC_PRSCL   0x06    // clk/64
 
105
 
 
106
//#define TEMP_DIDR   ADC4D
 
107
#define TEMP_CHANNEL 0b00001111
 
108
 
 
109
#endif  // FET_7135_LAYOUT
 
110
 
 
111
#ifdef FERRERO_ROCHER_LAYOUT
 
112
/*
 
113
 *            ----
 
114
 *    Reset -|1  8|- VCC
 
115
 * E-switch -|2  7|- Voltage ADC
 
116
 *  Red LED -|3  6|- PWM
 
117
 *      GND -|4  5|- Green LED
 
118
 *            ----
 
119
 */
 
120
// TODO: fill in this section, update Ferrero_Rocher code to use it.
 
121
#endif  // FERRERO_ROCHER_LAYOUT
 
122
 
 
123
#ifdef NANJG_LAYOUT
 
124
#define STAR2_PIN   PB0
 
125
#define STAR3_PIN   PB4
 
126
#define STAR4_PIN   PB3
 
127
#define PWM_PIN     PB1
 
128
#define VOLTAGE_PIN PB2
 
129
#define ADC_CHANNEL 0x01    // MUX 01 corresponds with PB2
 
130
#define ADC_DIDR    ADC1D   // Digital input disable bit corresponding with PB2
 
131
#define ADC_PRSCL   0x06    // clk/64
 
132
 
 
133
#define PWM_LVL     OCR0B   // OCR0B is the output compare register for PB1
 
134
#endif  // NANJG_LAYOUT
 
135
 
 
136
#ifndef PWM_LVL
 
137
    Hey, you need to define an I/O pin layout.
 
138
#endif
 
139
 
 
140
#endif  // TK_ATTINY_H