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: iotn13a.h 2460 2014-12-03 05:39:25Z pitchumani $ */
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 EEPE EEWE
154 #define EEMWE 2
155 #define EEMPE EEMWE
156 #define EERIE 3
157 #define EEPM0 4
158 #define EEPM1 5
159 
160 #define EEDR _SFR_IO8(0x1D)
161 #define EEDR0 0
162 #define EEDR1 1
163 #define EEDR2 2
164 #define EEDR3 3
165 #define EEDR4 4
166 #define EEDR5 5
167 #define EEDR6 6
168 #define EEDR7 7
169 
170 #define EEARL _SFR_IO8(0x1E)
171 
172 #define EEAR _SFR_IO8(0x1E)
173 #define EEAR0 0
174 #define EEAR1 1
175 #define EEAR2 2
176 #define EEAR3 3
177 #define EEAR4 4
178 #define EEAR5 5
179 
180 #define WDTCR _SFR_IO8(0x21)
181 #define WDP0 0
182 #define WDP1 1
183 #define WDP2 2
184 #define WDE 3
185 #define WDCE 4
186 #define WDP3 5
187 #define WDTIE 6
188 #define WDTIF 7
189 
190 #define PRR _SFR_IO8(0x25)
191 #define PRADC 0
192 #define PRTIM0 1
193 
194 #define __AVR_HAVE_PRR	((1<<PRADC)|(1<<PRTIM0))
195 #define __AVR_HAVE_PRR_PRADC
196 #define __AVR_HAVE_PRR_PRTIM0
197 
198 #define CLKPR _SFR_IO8(0x26)
199 #define CLKPS0 0
200 #define CLKPS1 1
201 #define CLKPS2 2
202 #define CLKPS3 3
203 #define CLKPCE 7
204 
205 #define GTCCR _SFR_IO8(0x28)
206 #define PSR10 0
207 #define TSM 7
208 
209 #define OCR0B _SFR_IO8(0x29)
210 #define OCR0B_0 0
211 #define OCR0B_1 1
212 #define OCR0B_2 2
213 #define OCR0B_3 3
214 #define OCR0B_4 4
215 #define OCR0B_5 5
216 #define OCR0B_6 6
217 #define OCR0B_7 7
218 
219 #define DWDR _SFR_IO8(0x2E)
220 #define DWDR0 0
221 #define DWDR1 1
222 #define DWDR2 2
223 #define DWDR3 3
224 #define DWDR4 4
225 #define DWDR5 5
226 #define DWDR6 6
227 #define DWDR7 7
228 
229 #define TCCR0A _SFR_IO8(0x2F)
230 #define WGM00 0
231 #define WGM01 1
232 #define COM0B0 4
233 #define COM0B1 5
234 #define COM0A0 6
235 #define COM0A1 7
236 
237 #define BODCR _SFR_IO8(0x30)
238 #define BODSE 0
239 #define BODS 1
240 
241 #define OSCCAL _SFR_IO8(0x31)
242 #define CAL0 0
243 #define CAL1 1
244 #define CAL2 2
245 #define CAL3 3
246 #define CAL4 4
247 #define CAL5 5
248 #define CAL6 6
249 
250 #define TCNT0 _SFR_IO8(0x32)
251 #define TCNT0_0 0
252 #define TCNT0_1 1
253 #define TCNT0_2 2
254 #define TCNT0_3 3
255 #define TCNT0_4 4
256 #define TCNT0_5 5
257 #define TCNT0_6 6
258 #define TCNT0_7 7
259 
260 #define TCCR0B _SFR_IO8(0x33)
261 #define CS00 0
262 #define CS01 1
263 #define CS02 2
264 #define WGM02 3
265 #define FOC0B 6
266 #define FOC0A 7
267 
268 #define MCUSR _SFR_IO8(0x34)
269 #define PORF 0
270 #define EXTRF 1
271 #define BORF 2
272 #define WDRF 3
273 
274 #define MCUCR _SFR_IO8(0x35)
275 #define ISC00 0
276 #define ISC01 1
277 #define SM0 3
278 #define SM1 4
279 #define SE 5
280 #define PUD 6
281 
282 #define OCR0A _SFR_IO8(0x36)
283 #define OCR0A_0 0
284 #define OCR0A_1 1
285 #define OCR0A_2 2
286 #define OCR0A_3 3
287 #define OCR0A_4 4
288 #define OCR0A_5 5
289 #define OCR0A_6 6
290 #define OCR0A_7 7
291 
292 #define SPMCSR _SFR_IO8(0x37)
293 #define SPMEN 0
294 #define PGERS 1
295 #define PGWRT 2
296 #define RFLB 3
297 #define CTPB 4
298 
299 #define TIFR0 _SFR_IO8(0x38)
300 #define TOV0 1
301 #define OCF0A 2
302 #define OCF0B 3
303 
304 #define TIMSK0 _SFR_IO8(0x39)
305 #define TOIE0 1
306 #define OCIE0A 2
307 #define OCIE0B 3
308 
309 #define GIFR _SFR_IO8(0x3A)
310 #define PCIF 5
311 #define INTF0 6
312 
313 #define GIMSK _SFR_IO8(0x3B)
314 #define PCIE 5
315 #define INT0 6
316 
317 
318 /* Interrupt vectors */
319 /* Vector 0 is the reset vector */
320 #define INT0_vect_num  1
321 #define INT0_vect      _VECTOR(1)  /* External Interrupt 0 */
322 #define PCINT0_vect_num  2
323 #define PCINT0_vect      _VECTOR(2)  /* External Interrupt Request 0 */
324 #define TIM0_OVF_vect_num  3
325 #define TIM0_OVF_vect      _VECTOR(3)  /* Timer/Counter0 Overflow */
326 #define EE_RDY_vect_num  4
327 #define EE_RDY_vect      _VECTOR(4)  /* EEPROM Ready */
328 #define ANA_COMP_vect_num  5
329 #define ANA_COMP_vect      _VECTOR(5)  /* Analog Comparator */
330 #define TIM0_COMPA_vect_num  6
331 #define TIM0_COMPA_vect      _VECTOR(6)  /* Timer/Counter Compare Match A */
332 #define TIM0_COMPB_vect_num  7
333 #define TIM0_COMPB_vect      _VECTOR(7)  /* Timer/Counter Compare Match B */
334 #define WDT_vect_num  8
335 #define WDT_vect      _VECTOR(8)  /* Watchdog Time-out */
336 #define ADC_vect_num  9
337 #define ADC_vect      _VECTOR(9)  /* ADC Conversion Complete */
338 
339 #define _VECTOR_SIZE 2 /* Size of individual vector. */
340 #define _VECTORS_SIZE (10 * _VECTOR_SIZE)
341 
342 
343 /* Constants */
344 #define SPM_PAGESIZE (32)
345 #define RAMSTART     (0x60)
346 #define RAMSIZE      (64)
347 #define RAMEND       (RAMSTART + RAMSIZE - 1)
348 #define XRAMSTART    (NA)
349 #define XRAMSIZE     (0)
350 #define XRAMEND      RAMEND
351 #define E2END        (64 - 1)
352 #define E2PAGESIZE   (4)
353 #define FLASHEND     (1024 - 1)
354 
355 
356 /* Fuses */
357 #define FUSE_MEMORY_SIZE 2
358 
359 /* Low Fuse Byte */
360 #define FUSE_CKSEL0 (unsigned char)~_BV(0)  /* Select Clock Source */
361 #define FUSE_CKSEL1 (unsigned char)~_BV(1)  /* Select Clock Source */
362 #define FUSE_SUT0 (unsigned char)~_BV(2)  /* Select start-up time */
363 #define FUSE_SUT1 (unsigned char)~_BV(3)  /* Select start-up time */
364 #define FUSE_CKDIV8 (unsigned char)~_BV(4)  /* Start up with system clock divided by 8 */
365 #define FUSE_WDTON (unsigned char)~_BV(5)  /* Watch dog timer always on */
366 #define FUSE_EESAVE (unsigned char)~_BV(6)  /* Keep EEprom contents during chip erase */
367 #define FUSE_SPIEN (unsigned char)~_BV(7)  /* SPI programming enable */
368 #define LFUSE_DEFAULT (FUSE_SPIEN & FUSE_CKDIV8 & FUSE_SUT0 & FUSE_CKSEL0)
369 
370 /* High Fuse Byte */
371 #define FUSE_RSTDISBL (unsigned char)~_BV(0)  /* Disable external reset */
372 #define FUSE_BODLEVEL0 (unsigned char)~_BV(1)  /* Enable BOD and select level */
373 #define FUSE_BODLEVEL1 (unsigned char)~_BV(2)  /* Enable BOD and select level */
374 #define FUSE_DWEN (unsigned char)~_BV(3)  /* DebugWire Enable */
375 #define FUSE_SELFPRGEN (unsigned char)~_BV(4)  /* Self Programming Enable */
376 #define HFUSE_DEFAULT (0xFF)
377 
378 
379 /* Lock Bits */
380 #define __LOCK_BITS_EXIST
381 
382 
383 /* Signature */
384 #define SIGNATURE_0 0x1E
385 #define SIGNATURE_1 0x90
386 #define SIGNATURE_2 0x07
387 
388 
389 
390 #define SLEEP_MODE_IDLE (0x00<<3)
391 #define SLEEP_MODE_ADC (0x01<<3)
392 #define SLEEP_MODE_PWR_DOWN (0x02<<3)
393 
394 #endif /* _AVR_ATTINY13A_H_ */
395 
396