cores: Add watchdog
authorMichel Pollet <buserror@gmail.com>
Wed, 6 Jan 2010 22:37:09 +0000 (22:37 +0000)
committerMichel Pollet <buserror@gmail.com>
Wed, 6 Jan 2010 22:43:10 +0000 (22:43 +0000)
Add watchdog block to the existing cores

Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr/cores/sim_megax4.c
simavr/cores/sim_megax4.h
simavr/cores/sim_megax8.c
simavr/cores/sim_megax8.h
simavr/cores/sim_tiny13.c
simavr/cores/sim_tiny2313.c
simavr/cores/sim_tinyx5.c
simavr/cores/sim_tinyx5.h

index c216a26..efd5ede 100644 (file)
@@ -32,6 +32,7 @@ void mx4_init(struct avr_t * avr)
        avr_eeprom_init(avr, &mcu->eeprom);
        avr_flash_init(avr, &mcu->selfprog);
        avr_extint_init(avr, &mcu->extint);
+       avr_watchdog_init(avr, &mcu->watchdog);
        avr_ioport_init(avr, &mcu->porta);
        avr_ioport_init(avr, &mcu->portb);
        avr_ioport_init(avr, &mcu->portc);
index 9b1cb1f..0193389 100644 (file)
@@ -26,6 +26,7 @@
 #include "sim_core_declare.h"
 #include "avr_eeprom.h"
 #include "avr_flash.h"
+#include "avr_watchdog.h"
 #include "avr_extint.h"
 #include "avr_ioport.h"
 #include "avr_uart.h"
@@ -44,6 +45,7 @@ struct mcu_t {
        avr_t core;
        avr_eeprom_t    eeprom;
        avr_flash_t     selfprog;
+       avr_watchdog_t  watchdog;
        avr_extint_t    extint;
        avr_ioport_t    porta, portb, portc, portd;
        avr_uart_t              uart0,uart1;
@@ -69,6 +71,7 @@ struct mcu_t SIM_CORENAME = {
        },
        AVR_EEPROM_DECLARE(EE_READY_vect),
        AVR_SELFPROG_DECLARE(SPMCSR, SPMEN, SPM_READY_vect),
+       AVR_WATCHDOG_DECLARE(WDTCSR, WDT_vect),
        .extint = {
                AVR_EXTINT_DECLARE(0, 'D', PD2),
                AVR_EXTINT_DECLARE(1, 'D', PD3),
index 970aa50..423622f 100644 (file)
@@ -31,6 +31,7 @@ void mx8_init(struct avr_t * avr)
 
        avr_eeprom_init(avr, &mcu->eeprom);
        avr_flash_init(avr, &mcu->selfprog);
+       avr_watchdog_init(avr, &mcu->watchdog);
        avr_extint_init(avr, &mcu->extint);
        avr_ioport_init(avr, &mcu->portb);
        avr_ioport_init(avr, &mcu->portc);
index 5a41071..936af57 100644 (file)
@@ -26,6 +26,7 @@
 #include "sim_core_declare.h"
 #include "avr_eeprom.h"
 #include "avr_flash.h"
+#include "avr_watchdog.h"
 #include "avr_extint.h"
 #include "avr_ioport.h"
 #include "avr_uart.h"
@@ -43,6 +44,7 @@ void mx8_reset(struct avr_t * avr);
 struct mcu_t {
        avr_t core;
        avr_eeprom_t    eeprom;
+       avr_watchdog_t  watchdog;
        avr_flash_t     selfprog;
        avr_extint_t    extint;
        avr_ioport_t    portb,portc,portd;
@@ -72,6 +74,7 @@ struct mcu_t SIM_CORENAME = {
        },
        AVR_EEPROM_DECLARE(EE_READY_vect),
        AVR_SELFPROG_DECLARE(SPMCSR, SELFPRGEN, SPM_READY_vect),
+       AVR_WATCHDOG_DECLARE(WDTCSR, WDT_vect),
        .extint = {
                AVR_EXTINT_DECLARE(0, 'D', 2),
                AVR_EXTINT_DECLARE(1, 'D', 3),
index d1a936b..b14c300 100644 (file)
@@ -24,6 +24,8 @@
 #include "sim_avr.h"
 #include "sim_core_declare.h"
 #include "avr_eeprom.h"
+#include "avr_watchdog.h"
+#include "avr_extint.h"
 #include "avr_ioport.h"
 #include "avr_timer.h"
 
@@ -38,6 +40,8 @@ static void reset(struct avr_t * avr);
 static struct mcu_t {
        avr_t core;
        avr_eeprom_t    eeprom;
+       avr_watchdog_t  watchdog;
+       avr_extint_t    extint;
        avr_ioport_t    portb;
        avr_timer_t             timer0;
 } mcu = {
@@ -60,6 +64,13 @@ static struct mcu_t {
                .reset = reset,
        },
        AVR_EEPROM_DECLARE_8BIT(EE_RDY_vect),
+       // tiny13 has different names for these...
+       #define WDIF WDTIF
+       #define WDIE WDTIE
+       AVR_WATCHDOG_DECLARE(WDTCR, WDT_vect),
+       .extint = {
+               AVR_EXTINT_TINY_DECLARE(0, 'B', 1, GIFR),
+       },
        .portb = {
                .name = 'B',  .r_port = PORTB, .r_ddr = DDRB, .r_pin = PINB,
                .pcint = {
@@ -120,6 +131,8 @@ static void init(struct avr_t * avr)
        printf("%s init\n", avr->mmcu);
 
        avr_eeprom_init(avr, &mcu->eeprom);
+       avr_watchdog_init(avr, &mcu->watchdog);
+       avr_extint_init(avr, &mcu->extint);
        avr_ioport_init(avr, &mcu->portb);
        avr_timer_init(avr, &mcu->timer0);
 }
index 4bb3288..1a58de4 100644 (file)
@@ -22,6 +22,7 @@
 #include </usr/include/stdio.h>
 #include "sim_core_declare.h"
 #include "avr_eeprom.h"
+#include "avr_watchdog.h"
 #include "avr_extint.h"
 #include "avr_ioport.h"
 #include "avr_uart.h"
@@ -40,6 +41,7 @@ static void reset(struct avr_t * avr);
 static struct mcu_t {
        avr_t core;
        avr_eeprom_t    eeprom;
+       avr_watchdog_t  watchdog;
        avr_extint_t    extint;
        avr_ioport_t    portb, portd;
        avr_uart_t              uart;
@@ -53,6 +55,7 @@ static struct mcu_t {
                .reset = reset,
        },
        AVR_EEPROM_DECLARE_8BIT(EEPROM_READY_vect),
+       AVR_WATCHDOG_DECLARE(WDTCSR, WDT_OVERFLOW_vect),
        .extint = {
                AVR_EXTINT_TINY_DECLARE(0, 'D', 2, EIFR),
                AVR_EXTINT_TINY_DECLARE(1, 'D', 3, EIFR),
@@ -198,6 +201,8 @@ static void init(struct avr_t * avr)
        printf("%s init\n", avr->mmcu);
 
        avr_eeprom_init(avr, &mcu->eeprom);
+       avr_watchdog_init(avr, &mcu->watchdog);
+       avr_extint_init(avr, &mcu->extint);
        avr_ioport_init(avr, &mcu->portb);
        avr_ioport_init(avr, &mcu->portd);
        avr_uart_init(avr, &mcu->uart);
index 8631021..13b7366 100644 (file)
@@ -32,6 +32,7 @@ void tx5_init(struct avr_t * avr)
        printf("%s init\n", avr->mmcu);
 
        avr_eeprom_init(avr, &mcu->eeprom);
+       avr_watchdog_init(avr, &mcu->watchdog);
        avr_extint_init(avr, &mcu->extint);
        avr_ioport_init(avr, &mcu->portb);
        avr_adc_init(avr, &mcu->adc);
index 9dda7ed..27e5688 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "sim_core_declare.h"
 #include "avr_eeprom.h"
+#include "avr_watchdog.h"
 #include "avr_extint.h"
 #include "avr_ioport.h"
 #include "avr_adc.h"
@@ -40,6 +41,7 @@ void tx5_reset(struct avr_t * avr);
 struct mcu_t {
        avr_t core;
        avr_eeprom_t    eeprom;
+       avr_watchdog_t  watchdog;
        avr_extint_t    extint;
        avr_ioport_t    portb;
        avr_adc_t               adc;
@@ -64,6 +66,7 @@ struct mcu_t SIM_CORENAME = {
                .reset = tx5_reset,
        },
        AVR_EEPROM_DECLARE(EE_RDY_vect),
+       AVR_WATCHDOG_DECLARE(WDTCR, WDT_vect),
        .extint = {
                AVR_EXTINT_TINY_DECLARE(0, 'B', PB2, GIFR),
        },