1
/* Copyright (c) 2002, Steinar Haugen
4
Redistribution and use in source and binary forms, with or without
5
modification, are permitted provided that the following conditions are met:
7
* Redistributions of source code must retain the above copyright
8
notice, this list of conditions and the following disclaimer.
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
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.
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. */
31
/* $Id: iom8535.h 2235 2011-03-17 04:13:14Z arcanum $ */
33
/* avr/iom8535.h - definitions for ATmega8535 */
35
#ifndef _AVR_IOM8535_H_
36
#define _AVR_IOM8535_H_ 1
38
/* This file should only be included from <avr/io.h>, never directly. */
41
# error "Include <avr/io.h> instead of this file."
45
# define _AVR_IOXXX_H_ "iom8535.h"
47
# error "Attempt to include more than one <avr/ioXXX.h> file."
52
/* TWI stands for "Two Wire Interface" or "TWI Was I2C(tm)" */
53
#define TWBR _SFR_IO8(0x00)
54
#define TWSR _SFR_IO8(0x01)
55
#define TWAR _SFR_IO8(0x02)
56
#define TWDR _SFR_IO8(0x03)
58
/* ADC Data register */
60
#define ADC _SFR_IO16(0x04)
62
#define ADCW _SFR_IO16(0x04)
63
#define ADCL _SFR_IO8(0x04)
64
#define ADCH _SFR_IO8(0x05)
66
/* ADC Control and Status Register */
67
#define ADCSRA _SFR_IO8(0x06)
70
#define ADMUX _SFR_IO8(0x07)
72
/* Analog Comparator Control and Status Register */
73
#define ACSR _SFR_IO8(0x08)
75
/* USART Baud Rate Register */
76
#define UBRRL _SFR_IO8(0x09)
78
/* USART Control and Status Register B */
79
#define UCSRB _SFR_IO8(0x0A)
81
/* USART Control and Status Register A */
82
#define UCSRA _SFR_IO8(0x0B)
84
/* USART I/O Data Register */
85
#define UDR _SFR_IO8(0x0C)
87
/* SPI Control Register */
88
#define SPCR _SFR_IO8(0x0D)
90
/* SPI Status Register */
91
#define SPSR _SFR_IO8(0x0E)
93
/* SPI I/O Data Register */
94
#define SPDR _SFR_IO8(0x0F)
96
/* Input Pins, Port D */
97
#define PIND _SFR_IO8(0x10)
99
/* Data Direction Register, Port D */
100
#define DDRD _SFR_IO8(0x11)
102
/* Data Register, Port D */
103
#define PORTD _SFR_IO8(0x12)
105
/* Input Pins, Port C */
106
#define PINC _SFR_IO8(0x13)
108
/* Data Direction Register, Port C */
109
#define DDRC _SFR_IO8(0x14)
111
/* Data Register, Port C */
112
#define PORTC _SFR_IO8(0x15)
114
/* Input Pins, Port B */
115
#define PINB _SFR_IO8(0x16)
117
/* Data Direction Register, Port B */
118
#define DDRB _SFR_IO8(0x17)
120
/* Data Register, Port B */
121
#define PORTB _SFR_IO8(0x18)
123
/* Input Pins, Port A */
124
#define PINA _SFR_IO8(0x19)
126
/* Data Direction Register, Port A */
127
#define DDRA _SFR_IO8(0x1A)
129
/* Data Register, Port A */
130
#define PORTA _SFR_IO8(0x1B)
132
/* EEPROM Control Register */
133
#define EECR _SFR_IO8(0x1C)
135
/* EEPROM Data Register */
136
#define EEDR _SFR_IO8(0x1D)
138
/* EEPROM Address Register */
139
#define EEAR _SFR_IO16(0x1E)
140
#define EEARL _SFR_IO8(0x1E)
141
#define EEARH _SFR_IO8(0x1F)
143
/* USART Baud Rate Register HI */
144
/* USART Control and Status Register C */
145
#define UBRRH _SFR_IO8(0x20)
148
/* Watchdog Timer Control Register */
149
#define WDTCR _SFR_IO8(0x21)
151
/* Asynchronous mode Status Register */
152
#define ASSR _SFR_IO8(0x22)
154
/* Timer/Counter2 Output Compare Register */
155
#define OCR2 _SFR_IO8(0x23)
157
/* Timer/Counter 2 */
158
#define TCNT2 _SFR_IO8(0x24)
160
/* Timer/Counter 2 Control Register */
161
#define TCCR2 _SFR_IO8(0x25)
163
/* T/C 1 Input Capture Register */
164
#define ICR1 _SFR_IO16(0x26)
165
#define ICR1L _SFR_IO8(0x26)
166
#define ICR1H _SFR_IO8(0x27)
168
/* Timer/Counter1 Output Compare Register B */
169
#define OCR1B _SFR_IO16(0x28)
170
#define OCR1BL _SFR_IO8(0x28)
171
#define OCR1BH _SFR_IO8(0x29)
173
/* Timer/Counter1 Output Compare Register A */
174
#define OCR1A _SFR_IO16(0x2A)
175
#define OCR1AL _SFR_IO8(0x2A)
176
#define OCR1AH _SFR_IO8(0x2B)
178
/* Timer/Counter 1 */
179
#define TCNT1 _SFR_IO16(0x2C)
180
#define TCNT1L _SFR_IO8(0x2C)
181
#define TCNT1H _SFR_IO8(0x2D)
183
/* Timer/Counter 1 Control and Status Register */
184
#define TCCR1B _SFR_IO8(0x2E)
186
/* Timer/Counter 1 Control Register */
187
#define TCCR1A _SFR_IO8(0x2F)
189
/* Special Function IO Register */
190
#define SFIOR _SFR_IO8(0x30)
192
/* Oscillator Calibration Register */
193
#define OSCCAL _SFR_IO8(0x31)
195
/* Timer/Counter 0 */
196
#define TCNT0 _SFR_IO8(0x32)
198
/* Timer/Counter 0 Control Register */
199
#define TCCR0 _SFR_IO8(0x33)
201
/* MCU Control and Status Register */
202
#define MCUCSR _SFR_IO8(0x34)
204
/* MCU Control Register */
205
#define MCUCR _SFR_IO8(0x35)
207
/* TWI Control Register */
208
#define TWCR _SFR_IO8(0x36)
210
/* Store Program Memory Control Register */
211
#define SPMCR _SFR_IO8(0x37)
213
/* Timer/Counter Interrupt Flag register */
214
#define TIFR _SFR_IO8(0x38)
216
/* Timer/Counter Interrupt MaSK register */
217
#define TIMSK _SFR_IO8(0x39)
219
/* General Interrupt Flag Register */
220
#define GIFR _SFR_IO8(0x3A)
222
/* General Interrupt MaSK register */
223
#define GICR _SFR_IO8(0x3B)
225
/* Timer/Counter 0 Output Compare Register */
226
#define OCR0 _SFR_IO8(0x3C)
232
/* Interrupt vectors */
234
/* External Interrupt 0 */
235
#define INT0_vect_num 1
236
#define INT0_vect _VECTOR(1)
237
#define SIG_INTERRUPT0 _VECTOR(1)
239
/* External Interrupt 1 */
240
#define INT1_vect_num 2
241
#define INT1_vect _VECTOR(2)
242
#define SIG_INTERRUPT1 _VECTOR(2)
244
/* Timer/Counter2 Compare Match */
245
#define TIMER2_COMP_vect_num 3
246
#define TIMER2_COMP_vect _VECTOR(3)
247
#define SIG_OUTPUT_COMPARE2 _VECTOR(3)
249
/* Timer/Counter2 Overflow */
250
#define TIMER2_OVF_vect_num 4
251
#define TIMER2_OVF_vect _VECTOR(4)
252
#define SIG_OVERFLOW2 _VECTOR(4)
254
/* Timer/Counter1 Capture Event */
255
#define TIMER1_CAPT_vect_num 5
256
#define TIMER1_CAPT_vect _VECTOR(5)
257
#define SIG_INPUT_CAPTURE1 _VECTOR(5)
259
/* Timer/Counter1 Compare Match A */
260
#define TIMER1_COMPA_vect_num 6
261
#define TIMER1_COMPA_vect _VECTOR(6)
262
#define SIG_OUTPUT_COMPARE1A _VECTOR(6)
264
/* Timer/Counter1 Compare Match B */
265
#define TIMER1_COMPB_vect_num 7
266
#define TIMER1_COMPB_vect _VECTOR(7)
267
#define SIG_OUTPUT_COMPARE1B _VECTOR(7)
269
/* Timer/Counter1 Overflow */
270
#define TIMER1_OVF_vect_num 8
271
#define TIMER1_OVF_vect _VECTOR(8)
272
#define SIG_OVERFLOW1 _VECTOR(8)
274
/* Timer/Counter0 Overflow */
275
#define TIMER0_OVF_vect_num 9
276
#define TIMER0_OVF_vect _VECTOR(9)
277
#define SIG_OVERFLOW0 _VECTOR(9)
279
/* SPI Serial Transfer Complete */
280
#define SPI_STC_vect_num 10
281
#define SPI_STC_vect _VECTOR(10)
282
#define SIG_SPI _VECTOR(10)
284
/* USART, RX Complete */
285
#define USART_RX_vect_num 11
286
#define USART_RX_vect _VECTOR(11)
287
#define SIG_UART_RECV _VECTOR(11)
289
/* USART Data Register Empty */
290
#define USART_UDRE_vect_num 12
291
#define USART_UDRE_vect _VECTOR(12)
292
#define SIG_UART_DATA _VECTOR(12)
294
/* USART, TX Complete */
295
#define USART_TX_vect_num 13
296
#define USART_TX_vect _VECTOR(13)
297
#define SIG_UART_TRANS _VECTOR(13)
299
/* ADC Conversion Complete */
300
#define ADC_vect_num 14
301
#define ADC_vect _VECTOR(14)
302
#define SIG_ADC _VECTOR(14)
305
#define EE_RDY_vect_num 15
306
#define EE_RDY_vect _VECTOR(15)
307
#define SIG_EEPROM_READY _VECTOR(15)
309
/* Analog Comparator */
310
#define ANA_COMP_vect_num 16
311
#define ANA_COMP_vect _VECTOR(16)
312
#define SIG_COMPARATOR _VECTOR(16)
314
/* Two-wire Serial Interface */
315
#define TWI_vect_num 17
316
#define TWI_vect _VECTOR(17)
317
#define SIG_2WIRE_SERIAL _VECTOR(17)
319
/* External Interrupt Request 2 */
320
#define INT2_vect_num 18
321
#define INT2_vect _VECTOR(18)
322
#define SIG_INTERRUPT2 _VECTOR(18)
324
/* TimerCounter0 Compare Match */
325
#define TIMER0_COMP_vect_num 19
326
#define TIMER0_COMP_vect _VECTOR(19)
327
#define SIG_OUTPUT_COMPARE0 _VECTOR(19)
329
/* Store Program Memory Read */
330
#define SPM_RDY_vect_num 20
331
#define SPM_RDY_vect _VECTOR(20)
332
#define SIG_SPM_READY _VECTOR(20)
334
#define _VECTORS_SIZE 42
337
The Register Bit names are represented by their bit number (0-7).
340
/* General Interrupt Control Register */
347
/* General Interrupt Flag Register */
352
/* Timer/Counter Interrupt MaSK register */
362
/* Timer/Counter Interrupt Flag register */
372
/* Store Program Memory Control Register */
381
/* TWI Control Register */
390
/* MCU Control Register */
400
/* MCU Control and Status Register */
407
/* Timer/Counter 0 Control Register */
418
The ADHSM bit has been removed from all documentation,
419
as being not needed at all since the comparator has proven
420
to be fast enough even without feeding it more power.
423
/* Special Function IO Register */
432
/* Timer/Counter 1 Control Register */
442
/* Timer/Counter 1 Control and Status Register */
451
/* Timer/Counter 2 Control Register */
461
/* Asynchronous mode Status Register */
467
/* Watchdog Timer Control Register */
474
/* USART Control and Status Register C */
484
/* Data Register, Port A */
494
/* Data Direction Register, Port A */
504
/* Input Pins, Port A */
514
/* Data Register, Port B */
524
/* Data Direction Register, Port B */
534
/* Input Pins, Port B */
544
/* Data Register, Port C */
554
/* Data Direction Register, Port C */
564
/* Input Pins, Port C */
574
/* Data Register, Port D */
584
/* Data Direction Register, Port D */
594
/* Input Pins, Port D */
604
/* SPI Status Register */
609
/* SPI Control Register */
619
/* USART Control and Status Register A */
629
/* USART Control and Status Register B */
639
/* Analog Comparator Control and Status Register */
649
/* ADC Multiplexer Selection Register */
659
/* ADC Control and Status Register */
669
/* TWI (Slave) Address Register */
672
/* TWI Status Register */
681
/* EEPROM Control Register */
688
#define SPM_PAGESIZE 64
689
#define RAMSTART (0x60)
690
#define RAMEND 0x25F /* Last On-Chip SRAM Location */
691
#define XRAMEND RAMEND
694
#define FLASHEND 0x1FFF
699
#define FUSE_MEMORY_SIZE 2
702
#define FUSE_CKSEL0 (unsigned char)~_BV(0)
703
#define FUSE_CKSEL1 (unsigned char)~_BV(1)
704
#define FUSE_CKSEL2 (unsigned char)~_BV(2)
705
#define FUSE_CKSEL3 (unsigned char)~_BV(3)
706
#define FUSE_SUT0 (unsigned char)~_BV(4)
707
#define FUSE_SUT1 (unsigned char)~_BV(5)
708
#define FUSE_BODEN (unsigned char)~_BV(6)
709
#define FUSE_BODLEVEL (unsigned char)~_BV(7)
710
#define LFUSE_DEFAULT (FUSE_CKSEL1 & FUSE_CKSEL2 & FUSE_CKSEL3 & FUSE_SUT0 & FUSE_SUT1)
713
#define FUSE_BOOTRST (unsigned char)~_BV(0)
714
#define FUSE_BOOTSZ0 (unsigned char)~_BV(1)
715
#define FUSE_BOOTSZ1 (unsigned char)~_BV(2)
716
#define FUSE_EESAVE (unsigned char)~_BV(3)
717
#define FUSE_CKOPT (unsigned char)~_BV(4)
718
#define FUSE_SPIEN (unsigned char)~_BV(5)
719
#define FUSE_WDTON (unsigned char)~_BV(6)
720
#define FUSE_S8535C (unsigned char)~_BV(7)
721
#define HFUSE_DEFAULT (FUSE_BOOTSZ0 & FUSE_BOOTSZ1 & FUSE_SPIEN)
725
#define __LOCK_BITS_EXIST
726
#define __BOOT_LOCK_BITS_0_EXIST
727
#define __BOOT_LOCK_BITS_1_EXIST
731
#define SIGNATURE_0 0x1E
732
#define SIGNATURE_1 0x93
733
#define SIGNATURE_2 0x08
736
/* Deprecated items */
737
#if !defined(__AVR_LIBC_DEPRECATED_ENABLE__)
739
#pragma GCC system_header
741
#pragma GCC poison SIG_INTERRUPT0
742
#pragma GCC poison SIG_INTERRUPT1
743
#pragma GCC poison SIG_OUTPUT_COMPARE2
744
#pragma GCC poison SIG_OVERFLOW2
745
#pragma GCC poison SIG_INPUT_CAPTURE1
746
#pragma GCC poison SIG_OUTPUT_COMPARE1A
747
#pragma GCC poison SIG_OUTPUT_COMPARE1B
748
#pragma GCC poison SIG_OVERFLOW1
749
#pragma GCC poison SIG_OVERFLOW0
750
#pragma GCC poison SIG_SPI
751
#pragma GCC poison SIG_UART_RECV
752
#pragma GCC poison SIG_UART_DATA
753
#pragma GCC poison SIG_UART_TRANS
754
#pragma GCC poison SIG_ADC
755
#pragma GCC poison SIG_EEPROM_READY
756
#pragma GCC poison SIG_COMPARATOR
757
#pragma GCC poison SIG_2WIRE_SERIAL
758
#pragma GCC poison SIG_INTERRUPT2
759
#pragma GCC poison SIG_OUTPUT_COMPARE0
760
#pragma GCC poison SIG_SPM_READY
762
#endif /* !defined(__AVR_LIBC_DEPRECATED_ENABLE__) */
766
#endif /* _AVR_IOM8535_H_ */