]> hydra-www.ietfng.org Git - acmetensortoys-chiptunes/commitdiff
Move target/ to avr-libc WDT management
authorNathaniel Wesley Filardo <nwf@smaug.priv.ietfng.org>
Mon, 1 Mar 2010 00:58:29 +0000 (19:58 -0500)
committerNathaniel Wesley Filardo <nwf@smaug.priv.ietfng.org>
Mon, 1 Mar 2010 00:58:29 +0000 (19:58 -0500)
target/asm.S
target/main.c

index 8289b5f966094ecd6b526f6cf60a568d23c32ccf..2d1aa85a43a1c89d4a892bddf0b7d674d275784c 100644 (file)
@@ -2,25 +2,12 @@
 #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.
index 3b1690f0068e272d2e99e279f9191db1882a1ccc..ec1cc4a8faa6cc674c80cfabf43a6534b844522e 100644 (file)
@@ -1,6 +1,7 @@
 #include <avr/io.h>
 #include <avr/interrupt.h>
 #include <avr/pgmspace.h>
+#include <avr/wdt.h>
 
 #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;