cores: Added selfprog bootloader support to x4 series
authorMichel Pollet <buserror@gmail.com>
Sat, 26 Dec 2009 13:32:41 +0000 (13:32 +0000)
committerMichel Pollet <buserror@gmail.com>
Sat, 26 Dec 2009 13:32:41 +0000 (13:32 +0000)
Untested, but behaves the same as x8 so it should work..

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

index d0dcb80..c216a26 100644 (file)
@@ -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);
index 1b25257..9b1cb1f 100644 (file)
@@ -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),
index b0036fc..5a41071 100644 (file)
@@ -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),
index 30201dc..dffaeaf 100644 (file)
@@ -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),\