1 | /* Copyright (c) 2008 Atmel Corporation |
---|
2 | All rights reserved. |
---|
3 | |
---|
4 | Redistribution and use in source and binary forms, with or without |
---|
5 | modification, are permitted provided that the following conditions are met: |
---|
6 | |
---|
7 | * Redistributions of source code must retain the above copyright |
---|
8 | notice, this list of conditions and the following disclaimer. |
---|
9 | |
---|
10 | * Redistributions in binary form must reproduce the above copyright |
---|
11 | notice, this list of conditions and the following disclaimer in |
---|
12 | the documentation and/or other materials provided with the |
---|
13 | distribution. |
---|
14 | |
---|
15 | * Neither the name of the copyright holders nor the names of |
---|
16 | contributors may be used to endorse or promote products derived |
---|
17 | from this software without specific prior written permission. |
---|
18 | |
---|
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
29 | POSSIBILITY OF SUCH DAMAGE. */ |
---|
30 | |
---|
31 | /* $Id$ */ |
---|
32 | |
---|
33 | /* avr/iotn13a.h - definitions for ATtiny13 */ |
---|
34 | |
---|
35 | /* This file should only be included from <avr/io.h>, never directly. */ |
---|
36 | |
---|
37 | #ifndef _AVR_IO_H_ |
---|
38 | # error "Include <avr/io.h> instead of this file." |
---|
39 | #endif |
---|
40 | |
---|
41 | #ifndef _AVR_IOXXX_H_ |
---|
42 | # define _AVR_IOXXX_H_ "iotn13a.h" |
---|
43 | #else |
---|
44 | # error "Attempt to include more than one <avr/ioXXX.h> file." |
---|
45 | #endif |
---|
46 | |
---|
47 | |
---|
48 | #ifndef _AVR_ATTINY13A_H_ |
---|
49 | #define _AVR_ATTINY13A_H_ 1 |
---|
50 | |
---|
51 | |
---|
52 | /* Registers and associated bit numbers. */ |
---|
53 | |
---|
54 | #define ADCSRB _SFR_IO8(0x03) |
---|
55 | #define ADTS0 0 |
---|
56 | #define ADTS1 1 |
---|
57 | #define ADTS2 2 |
---|
58 | #define ACME 6 |
---|
59 | |
---|
60 | #ifndef __ASSEMBLER__ |
---|
61 | #define ADC _SFR_IO16(0x04) |
---|
62 | #endif |
---|
63 | #define ADCW _SFR_IO16(0x04) |
---|
64 | |
---|
65 | #define ADCL _SFR_IO8(0x04) |
---|
66 | #define ADCL0 0 |
---|
67 | #define ADCL1 1 |
---|
68 | #define ADCL2 2 |
---|
69 | #define ADCL3 3 |
---|
70 | #define ADCL4 4 |
---|
71 | #define ADCL5 5 |
---|
72 | #define ADCL6 6 |
---|
73 | #define ADCL7 7 |
---|
74 | |
---|
75 | #define ADCH _SFR_IO8(0x05) |
---|
76 | #define ADCH0 0 |
---|
77 | #define ADCH1 1 |
---|
78 | #define ADCH2 2 |
---|
79 | #define ADCH3 3 |
---|
80 | #define ADCH4 4 |
---|
81 | #define ADCH5 5 |
---|
82 | #define ADCH6 6 |
---|
83 | #define ADCH7 7 |
---|
84 | |
---|
85 | #define ADCSRA _SFR_IO8(0x06) |
---|
86 | #define ADPS0 0 |
---|
87 | #define ADPS1 1 |
---|
88 | #define ADPS2 2 |
---|
89 | #define ADIE 3 |
---|
90 | #define ADIF 4 |
---|
91 | #define ADATE 5 |
---|
92 | #define ADSC 6 |
---|
93 | #define ADEN 7 |
---|
94 | |
---|
95 | #define ADMUX _SFR_IO8(0x07) |
---|
96 | #define MUX0 0 |
---|
97 | #define MUX1 1 |
---|
98 | #define ADLAR 5 |
---|
99 | #define REFS0 6 |
---|
100 | |
---|
101 | #define ACSR _SFR_IO8(0x08) |
---|
102 | #define ACIS0 0 |
---|
103 | #define ACIS1 1 |
---|
104 | #define ACIE 3 |
---|
105 | #define ACI 4 |
---|
106 | #define ACO 5 |
---|
107 | #define ACBG 6 |
---|
108 | #define ACD 7 |
---|
109 | |
---|
110 | #define DIDR0 _SFR_IO8(0x14) |
---|
111 | #define AIN0D 0 |
---|
112 | #define AIN1D 1 |
---|
113 | #define ADC1D 2 |
---|
114 | #define ADC3D 3 |
---|
115 | #define ADC2D 4 |
---|
116 | #define ADC0D 5 |
---|
117 | |
---|
118 | #define PCMSK _SFR_IO8(0x15) |
---|
119 | #define PCINT0 0 |
---|
120 | #define PCINT1 1 |
---|
121 | #define PCINT2 2 |
---|
122 | #define PCINT3 3 |
---|
123 | #define PCINT4 4 |
---|
124 | #define PCINT5 5 |
---|
125 | |
---|
126 | #define PINB _SFR_IO8(0x16) |
---|
127 | #define PINB0 0 |
---|
128 | #define PINB1 1 |
---|
129 | #define PINB2 2 |
---|
130 | #define PINB3 3 |
---|
131 | #define PINB4 4 |
---|
132 | #define PINB5 5 |
---|
133 | |
---|
134 | #define DDRB _SFR_IO8(0x17) |
---|
135 | #define DDB0 0 |
---|
136 | #define DDB1 1 |
---|
137 | #define DDB2 2 |
---|
138 | #define DDB3 3 |
---|
139 | #define DDB4 4 |
---|
140 | #define DDB5 5 |
---|
141 | |
---|
142 | #define PORTB _SFR_IO8(0x18) |
---|
143 | #define PORTB0 0 |
---|
144 | #define PORTB1 1 |
---|
145 | #define PORTB2 2 |
---|
146 | #define PORTB3 3 |
---|
147 | #define PORTB4 4 |
---|
148 | #define PORTB5 5 |
---|
149 | |
---|
150 | #define EECR _SFR_IO8(0x1C) |
---|
151 | #define EERE 0 |
---|
152 | #define EEWE 1 |
---|
153 | #define EEMWE 2 |
---|
154 | #define EERIE 3 |
---|
155 | #define EEPM0 4 |
---|
156 | #define EEPM1 5 |
---|
157 | |
---|
158 | #define EEDR _SFR_IO8(0x1D) |
---|
159 | #define EEDR0 0 |
---|
160 | #define EEDR1 1 |
---|
161 | #define EEDR2 2 |
---|
162 | #define EEDR3 3 |
---|
163 | #define EEDR4 4 |
---|
164 | #define EEDR5 5 |
---|
165 | #define EEDR6 6 |
---|
166 | #define EEDR7 7 |
---|
167 | |
---|
168 | #define EEARL _SFR_IO8(0x1E) |
---|
169 | |
---|
170 | #define EEAR _SFR_IO8(0x1E) |
---|
171 | #define EEAR0 0 |
---|
172 | #define EEAR1 1 |
---|
173 | #define EEAR2 2 |
---|
174 | #define EEAR3 3 |
---|
175 | #define EEAR4 4 |
---|
176 | #define EEAR5 5 |
---|
177 | |
---|
178 | #define WDTCR _SFR_IO8(0x21) |
---|
179 | #define WDP0 0 |
---|
180 | #define WDP1 1 |
---|
181 | #define WDP2 2 |
---|
182 | #define WDE 3 |
---|
183 | #define WDCE 4 |
---|
184 | #define WDP3 5 |
---|
185 | #define WDTIE 6 |
---|
186 | #define WDTIF 7 |
---|
187 | |
---|
188 | #define PRR _SFR_IO8(0x25) |
---|
189 | #define PRADC 0 |
---|
190 | #define PRSPI 1 |
---|
191 | #define PRTIM0 2 |
---|
192 | |
---|
193 | #define CLKPR _SFR_IO8(0x26) |
---|
194 | #define CLKPS0 0 |
---|
195 | #define CLKPS1 1 |
---|
196 | #define CLKPS2 2 |
---|
197 | #define CLKPS3 3 |
---|
198 | #define CLKPCE 7 |
---|
199 | |
---|
200 | #define GTCCR _SFR_IO8(0x28) |
---|
201 | #define PSR10 0 |
---|
202 | #define TSM 7 |
---|
203 | |
---|
204 | #define OCR0B _SFR_IO8(0x29) |
---|
205 | #define OCR0B_0 0 |
---|
206 | #define OCR0B_1 1 |
---|
207 | #define OCR0B_2 2 |
---|
208 | #define OCR0B_3 3 |
---|
209 | #define OCR0B_4 4 |
---|
210 | #define OCR0B_5 5 |
---|
211 | #define OCR0B_6 6 |
---|
212 | #define OCR0B_7 7 |
---|
213 | |
---|
214 | #define DWDR _SFR_IO8(0x2E) |
---|
215 | #define DWDR0 0 |
---|
216 | #define DWDR1 1 |
---|
217 | #define DWDR2 2 |
---|
218 | #define DWDR3 3 |
---|
219 | #define DWDR4 4 |
---|
220 | #define DWDR5 5 |
---|
221 | #define DWDR6 6 |
---|
222 | #define DWDR7 7 |
---|
223 | |
---|
224 | #define TCCR0A _SFR_IO8(0x2F) |
---|
225 | #define WGM00 0 |
---|
226 | #define WGM01 1 |
---|
227 | #define COM0B0 4 |
---|
228 | #define COM0B1 5 |
---|
229 | #define COM0A0 6 |
---|
230 | #define COM0A1 7 |
---|
231 | |
---|
232 | #define BODCR _SFR_IO8(0x30) |
---|
233 | #define BPDSE 0 |
---|
234 | #define BPDS 1 |
---|
235 | |
---|
236 | #define OSCCAL _SFR_IO8(0x31) |
---|
237 | #define CAL0 0 |
---|
238 | #define CAL1 1 |
---|
239 | #define CAL2 2 |
---|
240 | #define CAL3 3 |
---|
241 | #define CAL4 4 |
---|
242 | #define CAL5 5 |
---|
243 | #define CAL6 6 |
---|
244 | |
---|
245 | #define TCNT0 _SFR_IO8(0x32) |
---|
246 | #define TCNT0_0 0 |
---|
247 | #define TCNT0_1 1 |
---|
248 | #define TCNT0_2 2 |
---|
249 | #define TCNT0_3 3 |
---|
250 | #define TCNT0_4 4 |
---|
251 | #define TCNT0_5 5 |
---|
252 | #define TCNT0_6 6 |
---|
253 | #define TCNT0_7 7 |
---|
254 | |
---|
255 | #define TCCR0B _SFR_IO8(0x33) |
---|
256 | #define CS00 0 |
---|
257 | #define CS01 1 |
---|
258 | #define CS02 2 |
---|
259 | #define WGM02 3 |
---|
260 | #define FOC0B 6 |
---|
261 | #define FOC0A 7 |
---|
262 | |
---|
263 | #define MCUSR _SFR_IO8(0x34) |
---|
264 | #define PORF 0 |
---|
265 | #define EXTRF 1 |
---|
266 | #define BORF 2 |
---|
267 | #define WDRF 3 |
---|
268 | |
---|
269 | #define MCUCR _SFR_IO8(0x35) |
---|
270 | #define ISC00 0 |
---|
271 | #define ISC01 1 |
---|
272 | #define SM0 3 |
---|
273 | #define SM1 4 |
---|
274 | #define SE 5 |
---|
275 | #define PUD 6 |
---|
276 | |
---|
277 | #define OCR0A _SFR_IO8(0x36) |
---|
278 | #define OCR0A_0 0 |
---|
279 | #define OCR0A_1 1 |
---|
280 | #define OCR0A_2 2 |
---|
281 | #define OCR0A_3 3 |
---|
282 | #define OCR0A_4 4 |
---|
283 | #define OCR0A_5 5 |
---|
284 | #define OCR0A_6 6 |
---|
285 | #define OCR0A_7 7 |
---|
286 | |
---|
287 | #define SPMCSR _SFR_IO8(0x37) |
---|
288 | #define SPMEN 0 |
---|
289 | #define PGERS 1 |
---|
290 | #define PGWRT 2 |
---|
291 | #define RFLB 3 |
---|
292 | #define CTPB 4 |
---|
293 | |
---|
294 | #define TIFR0 _SFR_IO8(0x38) |
---|
295 | #define TOV0 1 |
---|
296 | #define OCF0A 2 |
---|
297 | #define OCF0B 3 |
---|
298 | |
---|
299 | #define TIMSK0 _SFR_IO8(0x39) |
---|
300 | #define TOIE0 1 |
---|
301 | #define OCIE0A 2 |
---|
302 | #define OCIE0B 3 |
---|
303 | |
---|
304 | #define GIFR _SFR_IO8(0x3A) |
---|
305 | #define PCIF 5 |
---|
306 | #define INTF0 6 |
---|
307 | |
---|
308 | #define GIMSK _SFR_IO8(0x3B) |
---|
309 | #define PCIE 5 |
---|
310 | #define INT0 6 |
---|
311 | |
---|
312 | |
---|
313 | /* Interrupt vectors */ |
---|
314 | /* Vector 0 is the reset vector */ |
---|
315 | #define INT0_vect_num 1 |
---|
316 | #define INT0_vect _VECTOR(1) /* External Interrupt 0 */ |
---|
317 | #define PCINT0_vect_num 2 |
---|
318 | #define PCINT0_vect _VECTOR(2) /* External Interrupt Request 0 */ |
---|
319 | #define TIM0_OVF_vect_num 3 |
---|
320 | #define TIM0_OVF_vect _VECTOR(3) /* Timer/Counter0 Overflow */ |
---|
321 | #define EE_RDY_vect_num 4 |
---|
322 | #define EE_RDY_vect _VECTOR(4) /* EEPROM Ready */ |
---|
323 | #define ANA_COMP_vect_num 5 |
---|
324 | #define ANA_COMP_vect _VECTOR(5) /* Analog Comparator */ |
---|
325 | #define TIM0_COMPA_vect_num 6 |
---|
326 | #define TIM0_COMPA_vect _VECTOR(6) /* Timer/Counter Compare Match A */ |
---|
327 | #define TIM0_COMPB_vect_num 7 |
---|
328 | #define TIM0_COMPB_vect _VECTOR(7) /* Timer/Counter Compare Match B */ |
---|
329 | #define WDT_vect_num 8 |
---|
330 | #define WDT_vect _VECTOR(8) /* Watchdog Time-out */ |
---|
331 | #define ADC_vect_num 9 |
---|
332 | #define ADC_vect _VECTOR(9) /* ADC Conversion Complete */ |
---|
333 | |
---|
334 | #define _VECTOR_SIZE 2 /* Size of individual vector. */ |
---|
335 | #define _VECTORS_SIZE (10 * _VECTOR_SIZE) |
---|
336 | |
---|
337 | |
---|
338 | /* Constants */ |
---|
339 | #define SPM_PAGESIZE (32) |
---|
340 | #define RAMSTART (0x60) |
---|
341 | #define RAMSIZE (64) |
---|
342 | #define RAMEND (RAMSTART + RAMSIZE - 1) |
---|
343 | #define XRAMSTART (NA) |
---|
344 | #define XRAMSIZE (0) |
---|
345 | #define XRAMEND RAMEND |
---|
346 | #define E2END (64 - 1) |
---|
347 | #define E2PAGESIZE (4) |
---|
348 | #define FLASHEND (1024 - 1) |
---|
349 | |
---|
350 | |
---|
351 | /* Fuses */ |
---|
352 | #define FUSE_MEMORY_SIZE 2 |
---|
353 | |
---|
354 | /* Low Fuse Byte */ |
---|
355 | #define FUSE_CKSEL0 (unsigned char)~_BV(0) /* Select Clock Source */ |
---|
356 | #define FUSE_CKSEL1 (unsigned char)~_BV(1) /* Select Clock Source */ |
---|
357 | #define FUSE_SUT0 (unsigned char)~_BV(2) /* Select start-up time */ |
---|
358 | #define FUSE_SUT1 (unsigned char)~_BV(3) /* Select start-up time */ |
---|
359 | #define FUSE_CKDIV8 (unsigned char)~_BV(4) /* Start up with system clock divided by 8 */ |
---|
360 | #define FUSE_WDTON (unsigned char)~_BV(5) /* Watch dog timer always on */ |
---|
361 | #define FUSE_EESAVE (unsigned char)~_BV(6) /* Keep EEprom contents during chip erase */ |
---|
362 | #define FUSE_SPIEN (unsigned char)~_BV(7) /* SPI programming enable */ |
---|
363 | #define LFUSE_DEFAULT (FUSE_SPIEN & FUSE_CKDIV8 & FUSE_SUT0 & FUSE_CKSEL0) |
---|
364 | |
---|
365 | /* High Fuse Byte */ |
---|
366 | #define FUSE_RSTDISBL (unsigned char)~_BV(0) /* Disable external reset */ |
---|
367 | #define FUSE_BODLEVEL0 (unsigned char)~_BV(1) /* Enable BOD and select level */ |
---|
368 | #define FUSE_BODLEVEL1 (unsigned char)~_BV(2) /* Enable BOD and select level */ |
---|
369 | #define FUSE_DWEN (unsigned char)~_BV(3) /* DebugWire Enable */ |
---|
370 | #define FUSE_SELFPRGEN (unsigned char)~_BV(4) /* Self Programming Enable */ |
---|
371 | #define HFUSE_DEFAULT (0xFF) |
---|
372 | |
---|
373 | |
---|
374 | /* Lock Bits */ |
---|
375 | #define __LOCK_BITS_EXIST |
---|
376 | |
---|
377 | |
---|
378 | /* Signature */ |
---|
379 | #define SIGNATURE_0 0x1E |
---|
380 | #define SIGNATURE_1 0x90 |
---|
381 | #define SIGNATURE_2 0x07 |
---|
382 | |
---|
383 | |
---|
384 | #endif /* _AVR_ATTINY13A_H_ */ |
---|
385 | |
---|