186.1.1
by Selene Scriven
Imported Emisar D4 RampingIOS code from Tom E. |
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 2000
|
|
40 |
#elif (ATTINY == 85)
|
|
41 |
// TODO: Use 6.4 MHz instead of 8 MHz?
|
|
42 |
#define F_CPU 8000000UL
|
|
43 |
#define EEPSIZE 512
|
|
44 |
#define V_REF REFS1
|
|
45 |
#define BOGOMIPS 2000
|
|
46 |
#else
|
|
47 |
Hey, you need to define ATTINY. |
|
48 |
#endif
|
|
49 |
||
50 |
||
51 |
/******************** I/O pin and register layout ************************/
|
|
52 |
/*
|
|
53 |
* ----
|
|
54 |
* Reset -|1 8|- VCC
|
|
55 |
* OTC -|2 7|- Voltage ADC
|
|
56 |
* Star 3 -|3 6|- PWM (FET)
|
|
57 |
* GND -|4 5|- PWM (1x7135)
|
|
58 |
* ----
|
|
59 |
*/
|
|
60 |
||
61 |
#define STAR2_PIN PB0 // If this pin isn't used for ALT_PWM |
|
62 |
#define STAR3_PIN PB4 // pin 3 |
|
63 |
||
64 |
#define CAP_PIN PB3 // pin 2, OTC |
|
65 |
#define CAP_CHANNEL 0x03 // MUX 03 corresponds with PB3 (Star 4) |
|
66 |
#define CAP_DIDR ADC3D // Digital input disable bit corresponding with PB3 |
|
67 |
||
68 |
#define PWM_PIN PB1 // pin 6, FET PWM |
|
69 |
#define PWM_LVL OCR0B // OCR0B is the output compare register for PB1 |
|
70 |
#define ALT_PWM_PIN PB0 // pin 5, 1x7135 PWM |
|
71 |
#define ALT_PWM_LVL OCR0A // OCR0A is the output compare register for PB0 |
|
72 |
||
73 |
#define VOLTAGE_PIN PB2 // pin 7, voltage ADC |
|
74 |
#define ADC_CHANNEL 0x01 // MUX 01 corresponds with PB2 |
|
75 |
#define ADC_DIDR ADC1D // Digital input disable bit corresponding with PB2 |
|
76 |
#define ADC_PRSCL 0x06 // clk/64 |
|
77 |
||
78 |
//#define TEMP_DIDR ADC4D
|
|
79 |
#define TEMP_CHANNEL 0b00001111
|
|
80 |
||
81 |
#endif // TK_ATTINY_H |