/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. See the file COPYING * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Copyright (C) 2010 Frank van Maarseveen */ #ifndef _HARDWARE_H_ #define _HARDWARE_H #include #include "bits.h" /* * attiny85 lfuse: 0x62 -> 0x42 make lfuse * 7 CKDIV8: 0 0 init CLKPR[CLKPS] to 0011 (divide clock by 8) * 6 CKOUT 1 1 * 5 SUT1: 1 -> 0 SUT=00: startup/reset asap (6+14CK) * 4 SUT0: 0 0 * 3 CKSEL3 0 0 * 2 CKSEL2 0 0 * 1 CKSEL1 1 1 * 0 CKSEL0 0 0 * * attiny85 hfuse 0xdf -> 0xde make hfuse * 7 RSTDISBL 1 1 note: programming this 0 affects SUT * 6 DWEN 1 1 * 5 SPIEN 0 0 * 4 WDTON 1 1 * 3 EESAVE 1 1 * 2 BODLEVEL2 1 1 * 1 BODLEVEL1 1 1 * 0 BODLEVEL0 1 -> 0 BOD at 1.8V * * attiny85 efuse 0xff -> 0xfe make efuse * 0 SELFPRGGEN 1 -> 0 Enable self-programming * */ #define MHZ 4 /* CLKPR[CLKPS] will be set to 0001, dividing by 2 */ /* * The LED for program transmission is at pin 5, PB0. */ #define LED (B, 0) __attribute__((always_inline)) static inline void hw_init(void) { CLKPR = _BV(CLKPCE); CLKPR = BIN8(0001); /* CLKPS = 0001, divide final system clock by 2 */ } #endif