Commit 8df158553ef7f2f9569dc307bc4dee6c66e860f4
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>
4 files changed:
simavr/cores/sim_megax4.c
simavr/cores/sim_megax4.h
simavr/cores/sim_megax8.h
simavr/sim/avr_flash.h

index d0dcb80c9af1bf3c15ba83de9a4ec7e738482114..c216a267e9b4056a7f5048c0b226890681c6c601 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 1b252577a318875e3d79f2f0e67e453f170b2510..9b1cb1fb81b62e29488e7eb8846d56d6e0a059b0 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 b0036fc8eeb3b644e5fc9ab7444ff737a7bf3d72..5a410717906dcacf78a92f88c890a285bd8b0d67 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 30201dcbd0badac28d6b832069c119a1725b724d..dffaeaf796139c9bace24b24b7f71298dd94e0e9 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),\