From 641040fb7ed761d4326fcdd9a06fde3acdc4daf9 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sun, 28 Feb 2010 19:58:29 -0500 Subject: [PATCH] Move target/ to avr-libc WDT management --- target/asm.S | 13 ------------- target/main.c | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/target/asm.S b/target/asm.S index 8289b5f..2d1aa85 100644 --- a/target/asm.S +++ b/target/asm.S @@ -2,25 +2,12 @@ #include #include - .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. diff --git a/target/main.c b/target/main.c index 3b1690f..ec1cc4a 100644 --- a/target/main.c +++ b/target/main.c @@ -1,6 +1,7 @@ #include #include #include +#include #define TRACKLEN 32 @@ -76,10 +77,22 @@ u16 resources[16 + MAXTRACK]; 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; @@ -331,7 +344,6 @@ void initresources() { int main() { asm("cli"); - watchdogoff(); CLKPR = 0x80; CLKPR = 0x80; -- 2.50.1