From: Michel Pollet Date: Sat, 26 Dec 2009 13:32:41 +0000 (+0000) Subject: cores: Added selfprog bootloader support to x4 series X-Git-Tag: v1.0a1~17 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=8df158553ef7f2f9569dc307bc4dee6c66e860f4;p=sx%2Fsimavr.git cores: Added selfprog bootloader support to x4 series Untested, but behaves the same as x8 so it should work.. Signed-off-by: Michel Pollet --- diff --git a/simavr/cores/sim_megax4.c b/simavr/cores/sim_megax4.c index d0dcb80..c216a26 100644 --- a/simavr/cores/sim_megax4.c +++ b/simavr/cores/sim_megax4.c @@ -30,6 +30,7 @@ void mx4_init(struct avr_t * avr) printf("%s init\n", avr->mmcu); avr_eeprom_init(avr, &mcu->eeprom); + avr_flash_init(avr, &mcu->selfprog); avr_extint_init(avr, &mcu->extint); avr_ioport_init(avr, &mcu->porta); avr_ioport_init(avr, &mcu->portb); diff --git a/simavr/cores/sim_megax4.h b/simavr/cores/sim_megax4.h index 1b25257..9b1cb1f 100644 --- a/simavr/cores/sim_megax4.h +++ b/simavr/cores/sim_megax4.h @@ -25,6 +25,7 @@ #include "sim_avr.h" #include "sim_core_declare.h" #include "avr_eeprom.h" +#include "avr_flash.h" #include "avr_extint.h" #include "avr_ioport.h" #include "avr_uart.h" @@ -42,6 +43,7 @@ void mx4_reset(struct avr_t * avr); struct mcu_t { avr_t core; avr_eeprom_t eeprom; + avr_flash_t selfprog; avr_extint_t extint; avr_ioport_t porta, portb, portc, portd; avr_uart_t uart0,uart1; @@ -66,6 +68,7 @@ struct mcu_t SIM_CORENAME = { .reset = mx4_reset, }, AVR_EEPROM_DECLARE(EE_READY_vect), + AVR_SELFPROG_DECLARE(SPMCSR, SPMEN, SPM_READY_vect), .extint = { AVR_EXTINT_DECLARE(0, 'D', PD2), AVR_EXTINT_DECLARE(1, 'D', PD3), diff --git a/simavr/cores/sim_megax8.h b/simavr/cores/sim_megax8.h index b0036fc..5a41071 100644 --- a/simavr/cores/sim_megax8.h +++ b/simavr/cores/sim_megax8.h @@ -71,7 +71,7 @@ struct mcu_t SIM_CORENAME = { .reset = mx8_reset, }, AVR_EEPROM_DECLARE(EE_READY_vect), - AVR_SELFPROG_DECLARE(SPMCSR, SPM_READY_vect), + AVR_SELFPROG_DECLARE(SPMCSR, SELFPRGEN, SPM_READY_vect), .extint = { AVR_EXTINT_DECLARE(0, 'D', 2), AVR_EXTINT_DECLARE(1, 'D', 3), diff --git a/simavr/sim/avr_flash.h b/simavr/sim/avr_flash.h index 30201dc..dffaeaf 100644 --- a/simavr/sim/avr_flash.h +++ b/simavr/sim/avr_flash.h @@ -47,11 +47,11 @@ void avr_flash_init(avr_t * avr, avr_flash_t * p); #define AVR_IOCTL_FLASH_SPM AVR_IOCTL_DEF('f','s','p','m') -#define AVR_SELFPROG_DECLARE(_spmr, _vector) \ +#define AVR_SELFPROG_DECLARE(_spmr, _spen, _vector) \ .selfprog = {\ .r_spm = _spmr,\ .spm_pagesize = SPM_PAGESIZE,\ - .selfprgen = AVR_IO_REGBIT(_spmr, SELFPRGEN),\ + .selfprgen = AVR_IO_REGBIT(_spmr, _spen),\ .pgers = AVR_IO_REGBIT(_spmr, PGERS),\ .pgwrt = AVR_IO_REGBIT(_spmr, PGWRT),\ .blbset = AVR_IO_REGBIT(_spmr, BLBSET),\