From bd30ae8119d72bf624b771d4a99006c5581302b5 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Wed, 6 Jan 2010 22:37:09 +0000 Subject: [PATCH] cores: Add watchdog Add watchdog block to the existing cores Signed-off-by: Michel Pollet --- simavr/cores/sim_megax4.c | 1 + simavr/cores/sim_megax4.h | 3 +++ simavr/cores/sim_megax8.c | 1 + simavr/cores/sim_megax8.h | 3 +++ simavr/cores/sim_tiny13.c | 13 +++++++++++++ simavr/cores/sim_tiny2313.c | 5 +++++ simavr/cores/sim_tinyx5.c | 1 + simavr/cores/sim_tinyx5.h | 3 +++ 8 files changed, 30 insertions(+) diff --git a/simavr/cores/sim_megax4.c b/simavr/cores/sim_megax4.c index c216a26..efd5ede 100644 --- a/simavr/cores/sim_megax4.c +++ b/simavr/cores/sim_megax4.c @@ -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); diff --git a/simavr/cores/sim_megax4.h b/simavr/cores/sim_megax4.h index 9b1cb1f..0193389 100644 --- a/simavr/cores/sim_megax4.h +++ b/simavr/cores/sim_megax4.h @@ -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), diff --git a/simavr/cores/sim_megax8.c b/simavr/cores/sim_megax8.c index 970aa50..423622f 100644 --- a/simavr/cores/sim_megax8.c +++ b/simavr/cores/sim_megax8.c @@ -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); diff --git a/simavr/cores/sim_megax8.h b/simavr/cores/sim_megax8.h index 5a41071..936af57 100644 --- a/simavr/cores/sim_megax8.h +++ b/simavr/cores/sim_megax8.h @@ -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), diff --git a/simavr/cores/sim_tiny13.c b/simavr/cores/sim_tiny13.c index d1a936b..b14c300 100644 --- a/simavr/cores/sim_tiny13.c +++ b/simavr/cores/sim_tiny13.c @@ -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); } diff --git a/simavr/cores/sim_tiny2313.c b/simavr/cores/sim_tiny2313.c index 4bb3288..1a58de4 100644 --- a/simavr/cores/sim_tiny2313.c +++ b/simavr/cores/sim_tiny2313.c @@ -22,6 +22,7 @@ #include #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); diff --git a/simavr/cores/sim_tinyx5.c b/simavr/cores/sim_tinyx5.c index 8631021..13b7366 100644 --- a/simavr/cores/sim_tinyx5.c +++ b/simavr/cores/sim_tinyx5.c @@ -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); diff --git a/simavr/cores/sim_tinyx5.h b/simavr/cores/sim_tinyx5.h index 9dda7ed..27e5688 100644 --- a/simavr/cores/sim_tinyx5.h +++ b/simavr/cores/sim_tinyx5.h @@ -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), }, -- 2.39.5