misc: Point to correct simavr include dirs
[simavr] / simavr / sim / avr_flash.h
1 /*
2         avr_flash.h
3
4         Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
5
6         This file is part of simavr.
7
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.
12
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.
17
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/>.
20  */
21
22
23 #ifndef __AVR_FLASH_H___
24 #define __AVR_FLASH_H___
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #include "sim_avr.h"
31
32 /*
33  * Handles self-programming subsystem if the core
34  * supports it.
35  */
36 typedef struct avr_flash_t {
37         avr_io_t        io;
38
39         uint16_t        spm_pagesize;
40         uint8_t r_spm;
41         avr_regbit_t selfprgen;
42         avr_regbit_t pgers;             // page erase
43         avr_regbit_t pgwrt;             // page write
44         avr_regbit_t blbset;    // lock bit set
45
46         avr_int_vector_t flash; // Interrupt vector
47 } avr_flash_t;
48
49 void avr_flash_init(avr_t * avr, avr_flash_t * p);
50
51
52 #define AVR_IOCTL_FLASH_SPM             AVR_IOCTL_DEF('f','s','p','m')
53
54 #define AVR_SELFPROG_DECLARE(_spmr, _spen, _vector) \
55         .selfprog = {\
56                 .r_spm = _spmr,\
57                 .spm_pagesize = SPM_PAGESIZE,\
58                 .selfprgen = AVR_IO_REGBIT(_spmr, _spen),\
59                 .pgers = AVR_IO_REGBIT(_spmr, PGERS),\
60                 .pgwrt = AVR_IO_REGBIT(_spmr, PGWRT),\
61                 .blbset = AVR_IO_REGBIT(_spmr, BLBSET),\
62                 .flash = {\
63                         .enable = AVR_IO_REGBIT(_spmr, SPMIE),\
64                         .vector = _vector,\
65                 },\
66         }
67
68 #ifdef __cplusplus
69 };
70 #endif
71
72 #endif /* __AVR_FLASH_H___ */