aboutsummaryrefslogtreecommitdiff
path: root/tk-attiny.h
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-08-11 15:16:23 -0600
committerSelene ToyKeeper2019-08-11 15:16:23 -0600
commit89a86871aa6330218043586f0347c0c1e7c79dab (patch)
treee3a4cc2a4517e5563e91cdaaf86718170d4f0a37 /tk-attiny.h
parentAdded setup info for Fedora. (diff)
parentadded scripts to flash attiny1634, which were missing before (diff)
downloadanduril-89a86871aa6330218043586f0347c0c1e7c79dab.tar.gz
anduril-89a86871aa6330218043586f0347c0c1e7c79dab.tar.bz2
anduril-89a86871aa6330218043586f0347c0c1e7c79dab.zip
merged fsm to trunk... lots of updates:
+ attiny1634 support + Emisar D4v2 support + Mateminco MF01S / MT18 support + Fireflies E01 and E07v2 support + RGB aux LED support + added factory reset function + added manual / automatic memory toggle + added 2-level brightness during lockout + added Fireflies UI + made momentary mode also support strobe-group modes * thermal regulation rewritten, behaves mostly better now * strobe modes auto-reverse their ramp now * muggle mode fixes * UI diagram and manual updated * button timing adjusted, and compile-time options added for it * general refactoring
Diffstat (limited to 'tk-attiny.h')
-rw-r--r--tk-attiny.h55
1 files changed, 52 insertions, 3 deletions
diff --git a/tk-attiny.h b/tk-attiny.h
index 3c985f2..947a87c 100644
--- a/tk-attiny.h
+++ b/tk-attiny.h
@@ -28,24 +28,26 @@
/******************** hardware-specific values **************************/
#if (ATTINY == 13)
#define F_CPU 4800000UL
- #define EEPSIZE 64
+ //#define EEPSIZE 64
#define V_REF REFS0
#define BOGOMIPS 950
#define ADMUX_VCC 0b00001100
#define DELAY_ZERO_TIME 252
+ #define SWITCH_PORT PINB // PINA or PINB or PINC
#elif (ATTINY == 25)
// TODO: Use 6.4 MHz instead of 8 MHz?
#define F_CPU 8000000UL
- #define EEPSIZE 128
+ //#define EEPSIZE 128
#define V_REF REFS1
#define BOGOMIPS (F_CPU/4000)
#define ADMUX_VCC 0b00001100
#define ADMUX_THERM 0b10001111
#define DELAY_ZERO_TIME 1020
+ #define SWITCH_PORT PINB // PINA or PINB or PINC
#elif (ATTINY == 85)
// TODO: Use 6.4 MHz instead of 8 MHz?
#define F_CPU 8000000UL
- #define EEPSIZE 512
+ //#define EEPSIZE 512
#define V_REF REFS1
#define BOGOMIPS (F_CPU/4000)
// (1 << V_REF) | (0 << ADLAR) | (VCC_CHANNEL)
@@ -53,10 +55,30 @@
// (1 << V_REF) | (0 << ADLAR) | (THERM_CHANNEL)
#define ADMUX_THERM 0b10001111
#define DELAY_ZERO_TIME 1020
+ #define SWITCH_PORT PINB // PINA or PINB or PINC
+#elif (ATTINY == 1634)
+ #define F_CPU 8000000UL
+ #define V_REF REFS1
+ #define BOGOMIPS (F_CPU/4000)
+ // (1 << V_REF) | (0 << ADLAR) | (VCC_CHANNEL)
+ #define ADMUX_VCC 0b00001101
+ // (1 << V_REF) | (0 << ADLAR) | (THERM_CHANNEL)
+ #define ADMUX_THERM 0b10001110
+ #define DELAY_ZERO_TIME 1020
+ //#define SWITCH_PORT PINA // set this in hwdef
#else
#error Hey, you need to define ATTINY.
#endif
+// auto-detect eeprom size from avr-libc headers
+#ifndef EEPSIZE
+#ifdef E2SIZE
+#define EEPSIZE E2SIZE
+#else
+#define EEPSIZE (E2END+1)
+#endif
+#endif
+
#include <avr/interrupt.h>
@@ -86,4 +108,31 @@
#error Hey, you need to define an I/O pin layout.
#endif
+#if (ATTINY==25) || (ATTINY==45) || (ATTINY==85)
+ // use clock_prescale_set(n) instead; it's safer
+ //#define CLOCK_DIVIDER_SET(n) {CLKPR = 1<<CLKPCE; CLKPR = n;}
+#elif (ATTINY==1634)
+ // make it a NOP for now
+ // FIXME
+ //#define clock_prescale_set(x) ((void)0)
+ //#define clock_prescale_set(n) {cli(); CCP = 0xD8; CLKPR = n; sei();}
+ //#define clock_prescale_set(n) {cli(); CCP = 0xD8; CLKPR = n; sei();}
+ inline void clock_prescale_set(uint8_t n) {cli(); CCP = 0xD8; CLKPR = n; sei();}
+ typedef enum
+ {
+ clock_div_1 = 0,
+ clock_div_2 = 1,
+ clock_div_4 = 2,
+ clock_div_8 = 3,
+ clock_div_16 = 4,
+ clock_div_32 = 5,
+ clock_div_64 = 6,
+ clock_div_128 = 7,
+ clock_div_256 = 8
+ } clock_div_t;
+
+#else
+#error Unable to define MCU macros.
+#endif
+
#endif // TK_ATTINY_H