RTEMS CPU Kit with SuperCore  4.11.3
iotn13.h
Go to the documentation of this file.
1 
11 /*
12  * Copyright (c) 2004, Theodore A. Roth
13  * All rights reserved.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions are met:
17  *
18  * * Redistributions of source code must retain the above copyright
19  * notice, this list of conditions and the following disclaimer.
20  *
21  * * Redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in
23  * the documentation and/or other materials provided with the
24  * distribution.
25  *
26  * * Neither the name of the copyright holders nor the names of
27  * contributors may be used to endorse or promote products derived
28  * from this software without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40  * POSSIBILITY OF SUCH DAMAGE.
41  */
42 
43 #ifndef _AVR_IOTN13_H_
44 #define _AVR_IOTN13_H_ 1
45 
53 #ifndef _AVR_IO_H_
54 # error "Include <avr/io.h> instead of this file."
55 #endif
56 
57 #ifndef _AVR_IOXXX_H_
58 # define _AVR_IOXXX_H_ "iotn13.h"
59 #else
60 # error "Attempt to include more than one <avr/ioXXX.h> file."
61 #endif
62 
63 /* I/O registers and bit names */
64 
65 /* ADC Control and Status Register B */
66 #define ADCSRB _SFR_IO8(0x03)
67 # define ACME 6
68 # define ADTS2 2
69 # define ADTS1 1
70 # define ADTS0 0
71 
72 /* ADC Data Register */
73 #ifndef __ASSEMBLER__
74 #define ADC _SFR_IO16 (0x04)
75 #endif
76 #define ADCW _SFR_IO16 (0x04)
77 #define ADCL _SFR_IO8(0x04)
78 #define ADCH _SFR_IO8(0x05)
79 
80 /* ADC Control and Status Register A */
81 #define ADCSRA _SFR_IO8(0x06)
82 # define ADEN 7
83 # define ADSC 6
84 # define ADATE 5
85 # define ADIF 4
86 # define ADIE 3
87 # define ADPS2 2
88 # define ADPS1 1
89 # define ADPS0 0
90 
91 /* ADC Multiplex Selection Register */
92 #define ADMUX _SFR_IO8(0x07)
93 # define REFS0 6
94 # define ADLAR 5
95 # define MUX1 1
96 # define MUX0 0
97 
98 /* Analog Comparator Control and Status Register */
99 #define ACSR _SFR_IO8(0x08)
100 # define ACD 7
101 # define ACBG 6
102 # define ACO 5
103 # define ACI 4
104 # define ACIE 3
105 # define ACIS1 1
106 # define ACIS0 0
107 
108 /* Digital Input Disable Register 0 */
109 #define DIDR0 _SFR_IO8(0x14)
110 # define ADC0D 5
111 # define ADC2D 4
112 # define ADC3D 3
113 # define ADC1D 2
114 # define AIN1D 1
115 # define AIN0D 0
116 
117 /* PIN Change Mask Register */
118 #define PCMSK _SFR_IO8(0x15)
119 # define PCINT5 5
120 # define PCINT4 4
121 # define PCINT3 3
122 # define PCINT2 2
123 # define PCINT1 1
124 # define PCINT0 0
125 
126 /* Port B Pin Utilization [2535D-AVR-04/04]
127  - PORTB5 = PCINT5/RESET#/ADC0/dW
128  - PORTB4 = PCINT4/ADC2
129  - PORTB3 = PCINT3/CLKI/ADC3
130  - PORTB2 = SCK/ADC1/T0/PCINT2
131  - PORTB1 = MISO/AIN1/OC0B/INT0/PCINT1
132  - PORTB0 = MOSI/AIN0/OC0A/PCINT0 */
133 
134 /* Input Pins, Port B */
135 #define PINB _SFR_IO8(0x16)
136 # define PINB5 5
137 # define PINB4 4
138 # define PINB3 3
139 # define PINB2 2
140 # define PINB1 1
141 # define PINB0 0
142 
143 /* Data Direction Register, Port B */
144 #define DDRB _SFR_IO8(0x17)
145 # define DDB5 5
146 # define DDB4 4
147 # define DDB3 3
148 # define DDB2 2
149 # define DDB1 1
150 # define DDB0 0
151 
152 /* Data Register, Port B */
153 #define PORTB _SFR_IO8(0x18)
154 # define PB5 5
155 # define PB4 4
156 # define PB3 3
157 # define PB2 2
158 # define PB1 1
159 # define PB0 0
160 
161 /* ATtiny EEPROM Control Register EECR */
162 #define EECR _SFR_IO8(0x1C)
163 #define EEPM1 5
164 #define EEPM0 4
165 #define EERIE 3
166 #define EEMPE 2
167 #define EEPE 1
168 #define EERE 0
169 
170 /* EEPROM Data Register */
171 #define EEDR _SFR_IO8(0x1D)
172 
173 /* The EEPROM Address Register EEAR[6:0] */
174 #define EEAR _SFR_IO8(0x1E)
175 #define EEARL _SFR_IO8(0x1E)
176 
177 /* Watchdog Timer Control Register */
178 #define WDTCR _SFR_IO8(0x21)
179 # define WDTIF 7
180 # define WDTIE 6
181 # define WDP3 5
182 # define WDCE 4
183 # define WDE 3
184 # define WDP2 2
185 # define WDP1 1
186 # define WDP0 0
187 
188 /* Clock Prescale Register */
189 #define CLKPR _SFR_IO8(0x26)
190 # define CLKPCE 7
191 # define CLKPS3 3
192 # define CLKPS2 2
193 # define CLKPS1 1
194 # define CLKPS0 0
195 
196 /* General Timer/Counter Control Register */
197 #define GTCCR _SFR_IO8(0x28)
198 # define TSM 7
199 # define PSR10 0
200 
201 /* Output Compare 0 Register B */
202 #define OCR0B _SFR_IO8(0x29)
203 
204 /* debugWIRE Data Register */
205 #define DWDR _SFR_IO8(0x2e)
206 
207 /* Timer/Counter 0 Control Register A */
208 #define TCCR0A _SFR_IO8(0x2f)
209 # define COM0A1 7
210 # define COM0A0 6
211 # define COM0B1 5
212 # define COM0B0 4
213 # define WGM01 1
214 # define WGM00 0
215 
216 /* Oscillator Calibration Register */
217 #define OSCCAL _SFR_IO8(0x31)
218 
219 /* Timer/Counter0 (8-bit) */
220 #define TCNT0 _SFR_IO8(0x32)
221 
222 /* Timer/Counter 0 Control Register B */
223 #define TCCR0B _SFR_IO8(0x33)
224 # define FOC0A 7
225 # define FOC0B 6
226 # define WGM02 3
227 # define CS02 2
228 # define CS01 1
229 # define CS00 0
230 
231 /* MCU General Status Register */
232 #define MCUSR _SFR_IO8(0x34)
233 # define WDRF 3
234 # define BORF 2
235 # define EXTRF 1
236 # define PORF 0
237 
238 /* MCU General Control Register */
239 #define MCUCR _SFR_IO8(0x35)
240 # define PUD 6
241 # define SE 5
242 # define SM1 4
243 # define SM0 3
244 # define ISC01 1
245 # define ISC00 0
246 
247 /* Output Compare 0 REgister A */
248 #define OCR0A _SFR_IO8(0x36)
249 
250 /* Store Program Memory Control and Status Register */
251 #define SPMCSR _SFR_IO8(0x37)
252 # define CTPB 4
253 # define RFLB 3
254 # define PGWRT 2
255 # define PGERS 1
256 # define SPMEN 0
257 # define SELFPRGEN 0
258 
259 /* Timer/Counter 0 Interrupt Flag Register */
260 #define TIFR0 _SFR_IO8(0x38)
261 # define OCF0B 3
262 # define OCF0A 2
263 # define TOV0 1
264 
265 /* Timer/Counter 0 Interrupt MaSK Register */
266 #define TIMSK0 _SFR_IO8(0x39)
267 # define OCIE0B 3
268 # define OCIE0A 2
269 # define TOIE0 1
270 
271 /* General Interrupt Flag Register */
272 #define GIFR _SFR_IO8(0x3a)
273 # define INTF0 6
274 # define PCIF 5
275 
276 /* General Interrupt MaSK register */
277 #define GIMSK _SFR_IO8(0x3b)
278 # define INT0 6
279 # define PCIE 5
280 
281 /* SPL and SREG are defined in <avr/io.h> */
282 
283 /* From the datasheet:
284  1 0x0000 RESET External Pin, Power-on Reset, Brown-out Reset, Watchdog Reset
285  2 0x0001 INT0 External Interrupt Request 0
286  3 0x0002 PCINT0 Pin Change Interrupt Request 0
287  4 0x0003 TIM0_OVF Timer/Counter Overflow
288  5 0x0004 EE_RDY EEPROM Ready
289  6 0x0005 ANA_COMP Analog Comparator
290  7 0x0006 TIM0_COMPA Timer/Counter Compare Match A
291  8 0x0007 TIM0_COMPB Timer/Counter Compare Match B
292  9 0x0008 WDT Watchdog Time-out
293  10 0x0009 ADC ADC Conversion Complete */
294 
295 /* External Interrupt 0 */
296 #define INT0_vect _VECTOR(1)
297 #define SIG_INTERRUPT0 _VECTOR(1)
298 
299 /* External Interrupt Request 0 */
300 #define PCINT0_vect _VECTOR(2)
301 #define SIG_PIN_CHANGE0 _VECTOR(2)
302 
303 /* Timer/Counter0 Overflow */
304 #define TIM0_OVF_vect _VECTOR(3)
305 #define SIG_OVERFLOW0 _VECTOR(3)
306 
307 /* EEPROM Ready */
308 #define EE_RDY_vect _VECTOR(4)
309 #define SIG_EEPROM_READY _VECTOR(4)
310 
311 /* Analog Comparator */
312 #define ANA_COMP_vect _VECTOR(5)
313 #define SIG_COMPARATOR _VECTOR(5)
314 
315 /* Timer/Counter Compare Match A */
316 #define TIM0_COMPA_vect _VECTOR(6)
317 #define SIG_OUTPUT_COMPARE0A _VECTOR(6)
318 
319 /* Timer/Counter Compare Match B */
320 #define TIM0_COMPB_vect _VECTOR(7)
321 #define SIG_OUTPUT_COMPARE0B _VECTOR(7)
322 
323 /* Watchdog Time-out */
324 #define WDT_vect _VECTOR(8)
325 #define SIG_WATCHDOG_TIMEOUT _VECTOR(8)
326 
327 /* ADC Conversion Complete */
328 #define ADC_vect _VECTOR(9)
329 #define SIG_ADC _VECTOR(9)
330 
331 #define _VECTORS_SIZE 20
332 
333 #define SPM_PAGESIZE 32
334 #define RAMEND 0x9F
335 #define XRAMEND RAMEND
336 #define E2END 0x3F
337 #define E2PAGESIZE 4
338 #define FLASHEND 0x3FF
339 
340 
341 /* Fuses */
342 
343 #define FUSE_MEMORY_SIZE 2
344 
345 /* Low Fuse Byte */
346 #define FUSE_CKSEL0 (unsigned char)~_BV(0)
347 #define FUSE_CKSEL1 (unsigned char)~_BV(1)
348 #define FUSE_SUT0 (unsigned char)~_BV(2)
349 #define FUSE_SUT1 (unsigned char)~_BV(3)
350 #define FUSE_CKDIV8 (unsigned char)~_BV(4)
351 #define FUSE_WDTON (unsigned char)~_BV(5)
352 #define FUSE_EESAVE (unsigned char)~_BV(6)
353 #define FUSE_SPIEN (unsigned char)~_BV(7)
354 #define LFUSE_DEFAULT (FUSE_CKSEL0 & FUSE_SUT0 & FUSE_CKDIV8 & FUSE_SPIEN)
355 
356 /* High Fuse Byte */
357 #define FUSE_RSTDISBL (unsigned char)~_BV(0)
358 #define FUSE_BODLEVEL0 (unsigned char)~_BV(1)
359 #define FUSE_BODLEVEL1 (unsigned char)~_BV(2)
360 #define FUSE_DWEN (unsigned char)~_BV(3)
361 #define FUSE_SPMEN (unsigned char)~_BV(4)
362 #define HFUSE_DEFAULT (0xFF)
363 
364 
365 /* Lock Bits */
366 #define __LOCK_BITS_EXIST
367 
368 
369 /* Signature */
370 #define SIGNATURE_0 0x1E
371 #define SIGNATURE_1 0x90
372 #define SIGNATURE_2 0x07
373 
374 
376 #endif /* _AVR_IOTN13_H_*/