Skip to content

Commit fdf8eca

Browse files
committed
Add spm for tinyx4 tiny2313 tiny2313a and tiny4313
1 parent 65e7e1e commit fdf8eca

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

simavr/cores/sim_tiny2313.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "avr_eeprom.h"
2323
#include "avr_watchdog.h"
2424
#include "avr_extint.h"
25+
#include "avr_flash.h"
2526
#include "avr_ioport.h"
2627
#include "avr_uart.h"
2728
#include "avr_timer.h"
@@ -44,6 +45,7 @@ static const struct mcu_t {
4445
avr_t core;
4546
avr_eeprom_t eeprom;
4647
avr_watchdog_t watchdog;
48+
avr_flash_t selfprog;
4749
avr_extint_t extint;
4850
avr_ioport_t porta, portb, portd;
4951
avr_uart_t uart;
@@ -60,6 +62,15 @@ static const struct mcu_t {
6062
},
6163
AVR_EEPROM_DECLARE_8BIT(EEPROM_READY_vect),
6264
AVR_WATCHDOG_DECLARE(WDTCSR, WDT_OVERFLOW_vect),
65+
.selfprog = {
66+
.flags = 0,
67+
.r_spm = SPMCSR,
68+
.spm_pagesize = SPM_PAGESIZE,
69+
.selfprgen = AVR_IO_REGBIT(SPMCSR, SPMEN),
70+
.pgers = AVR_IO_REGBIT(SPMCSR, PGERS),
71+
.pgwrt = AVR_IO_REGBIT(SPMCSR, PGWRT),
72+
.blbset = AVR_IO_REGBIT(SPMCSR, RFLB),
73+
},
6374
.extint = {
6475
AVR_EXTINT_TINY_DECLARE(0, 'D', 2, EIFR),
6576
AVR_EXTINT_TINY_DECLARE(1, 'D', 3, EIFR),
@@ -251,6 +262,7 @@ static void init(struct avr_t * avr)
251262

252263
avr_eeprom_init(avr, &mcu->eeprom);
253264
avr_watchdog_init(avr, &mcu->watchdog);
265+
avr_flash_init(avr, &mcu->selfprog);
254266
avr_extint_init(avr, &mcu->extint);
255267
avr_ioport_init(avr, &mcu->porta);
256268
avr_ioport_init(avr, &mcu->portb);

simavr/cores/sim_tiny2313a.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "avr_eeprom.h"
2323
#include "avr_watchdog.h"
2424
#include "avr_extint.h"
25+
#include "avr_flash.h"
2526
#include "avr_ioport.h"
2627
#include "avr_uart.h"
2728
#include "avr_timer.h"
@@ -44,6 +45,7 @@ static const struct mcu_t {
4445
avr_t core;
4546
avr_eeprom_t eeprom;
4647
avr_watchdog_t watchdog;
48+
avr_flash_t selfprog;
4749
avr_extint_t extint;
4850
avr_ioport_t porta, portb, portd;
4951
avr_uart_t uart;
@@ -60,6 +62,15 @@ static const struct mcu_t {
6062
},
6163
AVR_EEPROM_DECLARE_8BIT(EEPROM_Ready_vect),
6264
AVR_WATCHDOG_DECLARE(WDTCR, WDT_OVERFLOW_vect),
65+
.selfprog = {
66+
.flags = 0,
67+
.r_spm = SPMCSR,
68+
.spm_pagesize = SPM_PAGESIZE,
69+
.selfprgen = AVR_IO_REGBIT(SPMCSR, SPMEN),
70+
.pgers = AVR_IO_REGBIT(SPMCSR, PGERS),
71+
.pgwrt = AVR_IO_REGBIT(SPMCSR, PGWRT),
72+
.blbset = AVR_IO_REGBIT(SPMCSR, RFLB),
73+
},
6374
.extint = {
6475
AVR_EXTINT_TINY_DECLARE(0, 'D', 2, GIFR),
6576
AVR_EXTINT_TINY_DECLARE(1, 'D', 3, GIFR),
@@ -237,6 +248,7 @@ static void init(struct avr_t * avr)
237248

238249
avr_eeprom_init(avr, &mcu->eeprom);
239250
avr_watchdog_init(avr, &mcu->watchdog);
251+
avr_flash_init(avr, &mcu->selfprog);
240252
avr_extint_init(avr, &mcu->extint);
241253
avr_ioport_init(avr, &mcu->porta);
242254
avr_ioport_init(avr, &mcu->portb);

simavr/cores/sim_tiny4313.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "avr_eeprom.h"
2323
#include "avr_watchdog.h"
2424
#include "avr_extint.h"
25+
#include "avr_flash.h"
2526
#include "avr_ioport.h"
2627
#include "avr_uart.h"
2728
#include "avr_timer.h"
@@ -44,6 +45,7 @@ static const struct mcu_t {
4445
avr_t core;
4546
avr_eeprom_t eeprom;
4647
avr_watchdog_t watchdog;
48+
avr_flash_t selfprog;
4749
avr_extint_t extint;
4850
avr_ioport_t porta, portb, portd;
4951
avr_uart_t uart;
@@ -60,6 +62,15 @@ static const struct mcu_t {
6062
},
6163
AVR_EEPROM_DECLARE_8BIT(EEPROM_Ready_vect),
6264
AVR_WATCHDOG_DECLARE(WDTCR, WDT_OVERFLOW_vect),
65+
.selfprog = {
66+
.flags = 0,
67+
.r_spm = SPMCSR,
68+
.spm_pagesize = SPM_PAGESIZE,
69+
.selfprgen = AVR_IO_REGBIT(SPMCSR, SPMEN),
70+
.pgers = AVR_IO_REGBIT(SPMCSR, PGERS),
71+
.pgwrt = AVR_IO_REGBIT(SPMCSR, PGWRT),
72+
.blbset = AVR_IO_REGBIT(SPMCSR, RFLB),
73+
},
6374
.extint = {
6475
AVR_EXTINT_TINY_DECLARE(0, 'D', 2, GIFR),
6576
AVR_EXTINT_TINY_DECLARE(1, 'D', 3, GIFR),
@@ -237,6 +248,7 @@ static void init(struct avr_t * avr)
237248

238249
avr_eeprom_init(avr, &mcu->eeprom);
239250
avr_watchdog_init(avr, &mcu->watchdog);
251+
avr_flash_init(avr, &mcu->selfprog);
240252
avr_extint_init(avr, &mcu->extint);
241253
avr_ioport_init(avr, &mcu->porta);
242254
avr_ioport_init(avr, &mcu->portb);

simavr/cores/sim_tinyx4.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void tx4_init(struct avr_t * avr)
2929
struct mcu_t * mcu = (struct mcu_t*)avr;
3030

3131
avr_eeprom_init(avr, &mcu->eeprom);
32+
avr_flash_init(avr, &mcu->selfprog);
3233
avr_watchdog_init(avr, &mcu->watchdog);
3334
avr_extint_init(avr, &mcu->extint);
3435
avr_ioport_init(avr, &mcu->porta);

simavr/cores/sim_tinyx4.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "avr_eeprom.h"
2929
#include "avr_watchdog.h"
3030
#include "avr_extint.h"
31+
#include "avr_flash.h"
3132
#include "avr_ioport.h"
3233
#include "avr_adc.h"
3334
#include "avr_timer.h"
@@ -44,6 +45,7 @@ struct mcu_t {
4445
avr_t core;
4546
avr_eeprom_t eeprom;
4647
avr_watchdog_t watchdog;
48+
avr_flash_t selfprog;
4749
avr_extint_t extint;
4850
avr_ioport_t porta, portb;
4951
avr_acomp_t acomp;
@@ -70,6 +72,15 @@ const struct mcu_t SIM_CORENAME = {
7072
.reset = tx4_reset,
7173
},
7274
AVR_EEPROM_DECLARE(EE_RDY_vect),
75+
.selfprog = {
76+
.flags = 0,
77+
.r_spm = SPMCSR,
78+
.spm_pagesize = SPM_PAGESIZE,
79+
.selfprgen = AVR_IO_REGBIT(SPMCSR, SPMEN),
80+
.pgers = AVR_IO_REGBIT(SPMCSR, PGERS),
81+
.pgwrt = AVR_IO_REGBIT(SPMCSR, PGWRT),
82+
.blbset = AVR_IO_REGBIT(SPMCSR, RFLB),
83+
},
7384
AVR_WATCHDOG_DECLARE(WDTCSR, WDT_vect),
7485
.extint = {
7586
AVR_EXTINT_TINY_DECLARE(0, 'B', PB2, GIFR),

0 commit comments

Comments
 (0)