#include <target/config.h>
#include <avr/io.h>
- .global watchdogoff
.global __vector_14
.extern lastsample
.extern noiseseed
.extern osc
-watchdogoff:
- wdr
- in r24, 0x34 ; mcusr
- andi r24, 0xf7
- out 0x34, r24
- lds r24, 0x60 ; wdtcsr
- ori r24, 0x18
- sts 0x60, r24
- ldi r24, 0x00
- sts 0x60, r24
- ret
-
__vector_14:
; Entire interrupt routine, worst case:
; 308 + TARGET_AUDIO_PORT_SHIFT clocks.
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
+#include <avr/wdt.h>
#define TRACKLEN 32
struct unpacker songup;
-void watchdogoff();
extern u8 songdata[] __ATTR_PROGMEM__;
#define readsongbyte(x) pgm_read_byte_near(&songdata[x]);
+/* This is the AVR-LIBC standard dance for disabling the WDT */
+ static uint8_t mcusr_mirror __attribute__ ((section (".noinit")));
+
+ void get_mcusr(void) \
+ __attribute__((naked)) \
+ __attribute__((section(".init3")));
+ void get_mcusr(void)
+ {
+ mcusr_mirror = MCUSR;
+ MCUSR = 0;
+ wdt_disable();
+ }
+
static void initup(struct unpacker *up, u16 offset) {
up->nextbyte = offset;
up->bits = 0;
int main() {
asm("cli");
- watchdogoff();
CLKPR = 0x80;
CLKPR = 0x80;