SimAVR
AVR Simulator
avr_eeprom.h
Go to the documentation of this file.
1 /*
2  * avr_eeprom.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 it under the terms of the GNU
9  * General Public License as published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * simavr is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
13  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with simavr. If not, see
17  * <http://www.gnu.org/licenses/>.
18  */
19 
25 #ifndef __AVR_EEPROM_H__
26 #define __AVR_EEPROM_H__
27 
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32 
33 #include "sim_avr.h"
34 
35  typedef struct avr_eeprom_t
36  {
38 
39  uint8_t *eeprom;
40  uint16_t size;
41 
42  uint8_t r_eearh;
43  uint8_t r_eearl;
44  uint8_t r_eedr;
45 
47  uint8_t r_eecr;
52 
54  } avr_eeprom_t;
55 
56  void avr_eeprom_init (avr_t * avr, avr_eeprom_t * port);
57 
58  typedef struct avr_eeprom_desc_t
59  {
60  uint8_t *ee;
61  uint16_t offset;
62  uint32_t size;
64 
65 #define AVR_IOCTL_EEPROM_GET AVR_IOCTL_DEF('e','e','g','p')
66 #define AVR_IOCTL_EEPROM_SET AVR_IOCTL_DEF('e','e','s','p')
67 
70 #define AVR_EEPROM_DECLARE(_vector) \
71  .eeprom = { \
72  .size = E2END+1, \
73  .r_eearh = EEARH, \
74  .r_eearl = EEARL, \
75  .r_eedr = EEDR, \
76  .r_eecr = EECR, \
77  .eepm = { AVR_IO_REGBIT(EECR, EEPM0), AVR_IO_REGBIT(EECR, EEPM1) }, \
78  .eempe = AVR_IO_REGBIT(EECR, EEMPE), \
79  .eepe = AVR_IO_REGBIT(EECR, EEPE), \
80  .eere = AVR_IO_REGBIT(EECR, EERE), \
81  .ready = { \
82  .enable = AVR_IO_REGBIT(EECR, EERIE), \
83  .vector = _vector, \
84  }, \
85  }
86 
88 #define AVR_EEPROM_DECLARE_NOEEPM(_vector) \
89  .eeprom = { \
90  .size = E2END+1, \
91  .r_eearh = EEARH, \
92  .r_eearl = EEARL, \
93  .r_eedr = EEDR, \
94  .r_eecr = EECR, \
95  .eepm = { }, \
96  .eempe = AVR_IO_REGBIT(EECR, EEMWE), \
97  .eepe = AVR_IO_REGBIT(EECR, EEWE), \
98  .eere = AVR_IO_REGBIT(EECR, EERE), \
99  .ready = { \
100  .enable = AVR_IO_REGBIT(EECR, EERIE), \
101  .vector = _vector, \
102  }, \
103  }
104 
107 #define AVR_EEPROM_DECLARE_8BIT(_vector) \
108  .eeprom = { \
109  .size = E2END+1, \
110  .r_eearl = EEARL, \
111  .r_eedr = EEDR, \
112  .r_eecr = EECR, \
113  .eepm = { AVR_IO_REGBIT(EECR, EEPM0), AVR_IO_REGBIT(EECR, EEPM1) }, \
114  .eempe = AVR_IO_REGBIT(EECR, EEMPE), \
115  .eepe = AVR_IO_REGBIT(EECR, EEPE), \
116  .eere = AVR_IO_REGBIT(EECR, EERE), \
117  .ready = { \
118  .enable = AVR_IO_REGBIT(EECR, EERIE), \
119  .vector = _vector, \
120  }, \
121  }
122 
123 #ifdef __cplusplus
124 };
125 #endif
126 
127 #endif /* __AVR_EEPROM_H__ */
128 
avr_regbit_t eempe
eeprom master program enable
Definition: avr_eeprom.h:49
uint16_t size
size for this MCU
Definition: avr_eeprom.h:40
uint8_t r_eearl
Definition: avr_eeprom.h:43
uint8_t r_eearh
Definition: avr_eeprom.h:42
avr_regbit_t eepm[4]
Definition: avr_eeprom.h:48
struct avr_eeprom_t avr_eeprom_t
uint8_t r_eedr
Definition: avr_eeprom.h:44
uint8_t * eeprom
actual bytes
Definition: avr_eeprom.h:39
avr_t * avr
Definition: run_avr.c:54
uint32_t size
Definition: avr_eeprom.h:62
uint16_t offset
Definition: avr_eeprom.h:61
avr_regbit_t eere
eeprom read enable
Definition: avr_eeprom.h:51
interrupt vector for the IO modules
Definition: sim_interrupts.h:37
This 'structure' is a packed representation of an IO register 'bit' (or consecutive bits)...
Definition: sim_avr_types.h:47
avr_regbit_t eepe
eeprom program enable
Definition: avr_eeprom.h:50
Definition: avr_eeprom.h:35
Definition: avr_eeprom.h:58
uint8_t * ee
Definition: avr_eeprom.h:60
avr_int_vector_t ready
EERIE vector.
Definition: avr_eeprom.h:53
void avr_eeprom_init(avr_t *avr, avr_eeprom_t *port)
Definition: avr_eeprom.c:145
uint8_t r_eecr
eepm – eeprom write mode
Definition: avr_eeprom.h:47
struct avr_eeprom_desc_t avr_eeprom_desc_t
Main AVR instance.
Definition: sim_avr.h:142
IO module base struct Modules uses that as their first member in their own struct.
Definition: sim_io.h:42
avr_io_t io
Definition: avr_eeprom.h:37