4 Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
6 This file is part of simavr.
8 simavr is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 simavr is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with simavr. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef __AVR_FLASH_H___
24 #define __AVR_FLASH_H___
29 * Handles self-programming subsystem if the core
32 typedef struct avr_flash_t {
35 uint16_t spm_pagesize;
37 avr_regbit_t selfprgen;
38 avr_regbit_t pgers; // page erase
39 avr_regbit_t pgwrt; // page write
40 avr_regbit_t blbset; // lock bit set
42 avr_int_vector_t flash; // Interrupt vector
45 void avr_flash_init(avr_t * avr, avr_flash_t * p);
48 #define AVR_IOCTL_FLASH_SPM AVR_IOCTL_DEF('f','s','p','m')
50 #define AVR_SELFPROG_DECLARE(_spmr, _spen, _vector) \
53 .spm_pagesize = SPM_PAGESIZE,\
54 .selfprgen = AVR_IO_REGBIT(_spmr, _spen),\
55 .pgers = AVR_IO_REGBIT(_spmr, PGERS),\
56 .pgwrt = AVR_IO_REGBIT(_spmr, PGWRT),\
57 .blbset = AVR_IO_REGBIT(_spmr, BLBSET),\
59 .enable = AVR_IO_REGBIT(_spmr, SPMIE),\
64 #endif /* __AVR_FLASH_H___ */