target/unix/asuro_unix.h

Go to the documentation of this file.
00001 /**@file 
00002  * 
00003  * This part attempts to simulate the ATmega8 pin port interface under UNIX.
00004  * 
00005  * @author Denis Martin
00006  * 
00007  * This program is free software; you can redistribute it and/or modify it under
00008  * the terms of the GNU General Public License as published by the Free Software
00009  * Foundation; either version 2 of the License, or (at your option) any later
00010  * version.
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
00014  * details. You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation, Inc.,
00016  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef ASURO_UNIX_H_
00020 #define ASURO_UNIX_H_
00021 
00022 unsigned char AS_unix_ioVector[256];
00023 
00024 int AS_unix_prepareIo(int io_addr);
00025 
00026 #define sei()   {}
00027 #define cli()   {}
00028 
00029 #define SIGNAL(signame) \
00030     void signame (void)
00031 
00032 // the following part comes from avr-gcc package
00033 
00034 #define _VECTOR(N) __vector_ ## N
00035 
00036 // a little tricky...
00037 #define _SFR_IO8(io_addr)   AS_unix_ioVector[AS_unix_prepareIo(io_addr)]
00038 #define _SFR_IO16(io_addr)  AS_unix_ioVector[AS_unix_prepareIo(io_addr)]
00039 
00040 /* I/O registers */
00041 
00042 /* TWI stands for "Two Wire Interface" or "TWI Was I2C(tm)" */
00043 #define TWBR    _SFR_IO8(0x00)
00044 #define TWSR    _SFR_IO8(0x01)
00045 #define TWAR    _SFR_IO8(0x02)
00046 #define TWDR    _SFR_IO8(0x03)
00047 
00048 /* ADC */
00049 #define ADCW    _SFR_IO16(0x04)
00050 #define ADC     _SFR_IO16(0x04)
00051 #define ADCL    _SFR_IO8(0x04)
00052 #define ADCH    _SFR_IO8(0x05)
00053 #define ADCSR   _SFR_IO8(0x06)
00054 #define ADCSRA  _SFR_IO8(0x06)  /* Changed in 2486H-AVR-09/02 */
00055 #define ADMUX   _SFR_IO8(0x07)
00056 
00057 /* analog comparator */
00058 #define ACSR    _SFR_IO8(0x08)
00059 
00060 /* USART */
00061 #define UBRRL   _SFR_IO8(0x09)
00062 #define UCSRB   _SFR_IO8(0x0A)
00063 #define UCSRA   _SFR_IO8(0x0B)
00064 #define UDR     _SFR_IO8(0x0C)
00065 
00066 /* SPI */
00067 #define SPCR    _SFR_IO8(0x0D)
00068 #define SPSR    _SFR_IO8(0x0E)
00069 #define SPDR    _SFR_IO8(0x0F)
00070 
00071 /* Port D */
00072 #define PIND    _SFR_IO8(0x10)
00073 #define DDRD    _SFR_IO8(0x11)
00074 #define PORTD   _SFR_IO8(0x12)
00075 
00076 /* Port C */
00077 #define PINC    _SFR_IO8(0x13)
00078 #define DDRC    _SFR_IO8(0x14)
00079 #define PORTC   _SFR_IO8(0x15)
00080 
00081 /* Port B */
00082 #define PINB    _SFR_IO8(0x16)
00083 #define DDRB    _SFR_IO8(0x17)
00084 #define PORTB   _SFR_IO8(0x18)
00085 
00086 /* 0x1C..0x1F EEPROM */
00087 
00088 #define UCSRC   _SFR_IO8(0x20)
00089 #define UBRRH   _SFR_IO8(0x20)
00090 
00091 #define WDTCR   _SFR_IO8(0x21)
00092 #define ASSR    _SFR_IO8(0x22)
00093 
00094 /* Timer 2 */
00095 #define OCR2    _SFR_IO8(0x23)
00096 #define TCNT2   _SFR_IO8(0x24)
00097 #define TCCR2   _SFR_IO8(0x25)
00098 
00099 /* Timer 1 */
00100 #define ICR1    _SFR_IO16(0x26)
00101 #define ICR1L   _SFR_IO8(0x26)
00102 #define ICR1H   _SFR_IO8(0x27)
00103 #define OCR1B   _SFR_IO16(0x28)
00104 #define OCR1BL  _SFR_IO8(0x28)
00105 #define OCR1BH  _SFR_IO8(0x29)
00106 #define OCR1A   _SFR_IO16(0x2A)
00107 #define OCR1AL  _SFR_IO8(0x2A)
00108 #define OCR1AH  _SFR_IO8(0x2B)
00109 #define TCNT1   _SFR_IO16(0x2C)
00110 #define TCNT1L  _SFR_IO8(0x2C)
00111 #define TCNT1H  _SFR_IO8(0x2D)
00112 #define TCCR1B  _SFR_IO8(0x2E)
00113 #define TCCR1A  _SFR_IO8(0x2F)
00114 
00115 #define SFIOR   _SFR_IO8(0x30)
00116 
00117 #define OSCCAL  _SFR_IO8(0x31)
00118 
00119 /* Timer 0 */
00120 #define TCNT0   _SFR_IO8(0x32)
00121 #define TCCR0   _SFR_IO8(0x33)
00122 
00123 #define MCUCSR  _SFR_IO8(0x34)
00124 #define MCUCR   _SFR_IO8(0x35)
00125 
00126 #define TWCR    _SFR_IO8(0x36)
00127 
00128 #define SPMCR   _SFR_IO8(0x37)
00129 
00130 #define TIFR    _SFR_IO8(0x38)
00131 #define TIMSK   _SFR_IO8(0x39)
00132 
00133 #define GIFR    _SFR_IO8(0x3A)
00134 #define GIMSK   _SFR_IO8(0x3B)
00135 #define GICR    _SFR_IO8(0x3B)   /* Changed in 2486H-AVR-09/02 */
00136 
00137 /* 0x3C reserved (OCR0?) */
00138 
00139 /* 0x3D..0x3E SP */
00140 
00141 /* 0x3F SREG */
00142 
00143 /* Interrupt vectors */
00144 
00145 #define SIG_INTERRUPT0      _VECTOR(1)
00146 #define SIG_INTERRUPT1      _VECTOR(2)
00147 #define SIG_OUTPUT_COMPARE2 _VECTOR(3)
00148 #define SIG_OVERFLOW2       _VECTOR(4)
00149 #define SIG_INPUT_CAPTURE1  _VECTOR(5)
00150 #define SIG_OUTPUT_COMPARE1A    _VECTOR(6)
00151 #define SIG_OUTPUT_COMPARE1B    _VECTOR(7)
00152 #define SIG_OVERFLOW1       _VECTOR(8)
00153 #define SIG_OVERFLOW0       _VECTOR(9)
00154 #define SIG_SPI         _VECTOR(10)
00155 #define SIG_UART_RECV       _VECTOR(11)
00156 #define SIG_UART_DATA       _VECTOR(12)
00157 #define SIG_UART_TRANS      _VECTOR(13)
00158 #define SIG_ADC         _VECTOR(14)
00159 #define SIG_EEPROM_READY    _VECTOR(15)
00160 #define SIG_COMPARATOR      _VECTOR(16)
00161 #define SIG_2WIRE_SERIAL    _VECTOR(17)
00162 #define SIG_SPM_READY       _VECTOR(18)
00163 
00164 #define _VECTORS_SIZE 38
00165 
00166 /* Bit numbers */
00167 
00168 /* GIMSK / GICR */
00169 #define INT1    7
00170 #define INT0    6
00171 #define IVSEL   1
00172 #define IVCE    0
00173 
00174 /* GIFR */
00175 #define INTF1   7
00176 #define INTF0   6
00177 
00178 /* TIMSK */
00179 #define OCIE2   7
00180 #define TOIE2   6
00181 #define TICIE1  5
00182 #define OCIE1A  4
00183 #define OCIE1B  3
00184 #define TOIE1   2
00185 /* bit 1 reserved (OCIE0?) */
00186 #define TOIE0   0
00187 
00188 /* TIFR */
00189 #define OCF2    7
00190 #define TOV2    6
00191 #define ICF1    5
00192 #define OCF1A   4
00193 #define OCF1B   3
00194 #define TOV1    2
00195 /* bit 1 reserved (OCF0?) */
00196 #define TOV0    0
00197 
00198 /* SPMCR */
00199 #define SPMIE   7
00200 #define RWWSB   6
00201 /* bit 5 reserved */
00202 #define RWWSRE  4
00203 #define BLBSET  3
00204 #define PGWRT   2
00205 #define PGERS   1
00206 #define SPMEN   0
00207 
00208 /* TWCR */
00209 #define TWINT   7
00210 #define TWEA    6
00211 #define TWSTA   5
00212 #define TWSTO   4
00213 #define TWWC    3
00214 #define TWEN    2
00215 /* bit 1 reserved (TWI_TST?) */
00216 #define TWIE    0
00217 
00218 /* TWAR */
00219 #define TWA6    7
00220 #define TWA5    6
00221 #define TWA4    5
00222 #define TWA3    4
00223 #define TWA2    3
00224 #define TWA1    2
00225 #define TWA0    1
00226 #define TWGCE   0
00227 
00228 /* TWSR */
00229 #define TWS7    7
00230 #define TWS6    6
00231 #define TWS5    5
00232 #define TWS4    4
00233 #define TWS3    3
00234 /* bit 2 reserved */
00235 #define TWPS1   1
00236 #define TWPS0   0
00237 
00238 /* MCUCR */
00239 #define SE  7
00240 #define SM2 6
00241 #define SM1 5
00242 #define SM0 4
00243 #define ISC11   3
00244 #define ISC10   2
00245 #define ISC01   1
00246 #define ISC00   0
00247 
00248 /* MCUCSR */
00249 /* bits 7-4 reserved */
00250 #define WDRF    3
00251 #define BORF    2
00252 #define EXTRF   1
00253 #define PORF    0
00254 
00255 /* SFIOR */
00256 /* bits 7-5 reserved */
00257 #define ADHSM   4
00258 #define ACME    3
00259 #define PUD 2
00260 #define PSR2    1
00261 #define PSR10   0
00262 
00263 /* TCCR0 */
00264 /* bits 7-3 reserved */
00265 #define CS02    2
00266 #define CS01    1
00267 #define CS00    0
00268 
00269 /* TCCR2 */
00270 #define FOC2    7
00271 #define WGM20   6
00272 #define COM21   5
00273 #define COM20   4
00274 #define WGM21   3
00275 #define CS22    2
00276 #define CS21    1
00277 #define CS20    0
00278 
00279 /* ASSR */
00280 /* bits 7-4 reserved */
00281 #define AS2 3
00282 #define TCN2UB  2
00283 #define OCR2UB  1
00284 #define TCR2UB  0
00285 
00286 /* TCCR1A */
00287 #define COM1A1  7
00288 #define COM1A0  6
00289 #define COM1B1  5
00290 #define COM1B0  4
00291 #define FOC1A   3
00292 #define FOC1B   2
00293 #define WGM11   1
00294 #define WGM10   0
00295 
00296 /* TCCR1B */
00297 #define ICNC1   7
00298 #define ICES1   6
00299 /* bit 5 reserved */
00300 #define WGM13   4
00301 #define WGM12   3
00302 #define CS12    2
00303 #define CS11    1
00304 #define CS10    0
00305 
00306 /* WDTCR */
00307 /* bits 7-5 reserved */
00308 #define WDCE    4
00309 #define WDE 3
00310 #define WDP2    2
00311 #define WDP1    1
00312 #define WDP0    0
00313 
00314 /* UBRRH */
00315 #define URSEL   7
00316 
00317 /* UCSRC */
00318 #define URSEL   7
00319 #define UMSEL   6
00320 #define UPM1    5
00321 #define UPM0    4
00322 #define USBS    3
00323 #define UCSZ1   2
00324 #define UCSZ0   1
00325 #define UCPOL   0
00326 
00327 /* PORTB */
00328 #define PB7 7
00329 #define PB6 6
00330 #define PB5 5
00331 #define PB4 4
00332 #define PB3 3
00333 #define PB2 2
00334 #define PB1 1
00335 #define PB0 0
00336 
00337 /* DDRB */
00338 #define DDB7    7
00339 #define DDB6    6
00340 #define DDB5    5
00341 #define DDB4    4
00342 #define DDB3    3
00343 #define DDB2    2
00344 #define DDB1    1
00345 #define DDB0    0
00346 
00347 /* PINB */
00348 #define PINB7   7
00349 #define PINB6   6
00350 #define PINB5   5
00351 #define PINB4   4
00352 #define PINB3   3
00353 #define PINB2   2
00354 #define PINB1   1
00355 #define PINB0   0
00356 
00357 /* PORTC */
00358 #define PC6  6
00359 #define PC5  5
00360 #define PC4  4
00361 #define PC3  3
00362 #define PC2  2
00363 #define PC1  1
00364 #define PC0  0
00365 
00366 /* DDRC */
00367 #define DDC6    6
00368 #define DDC5    5
00369 #define DDC4    4
00370 #define DDC3    3
00371 #define DDC2    2
00372 #define DDC1    1
00373 #define DDC0    0
00374 
00375 /* PINC */
00376 #define PINC6   6
00377 #define PINC5   5
00378 #define PINC4   4
00379 #define PINC3   3
00380 #define PINC2   2
00381 #define PINC1   1
00382 #define PINC0   0
00383 
00384 /* PORTD */
00385 #define PD7  7
00386 #define PD6  6
00387 #define PD5  5
00388 #define PD4  4
00389 #define PD3  3
00390 #define PD2  2
00391 #define PD1  1
00392 #define PD0  0
00393 
00394 /* DDRD */
00395 #define DDD7    7
00396 #define DDD6    6
00397 #define DDD5    5
00398 #define DDD4    4
00399 #define DDD3    3
00400 #define DDD2    2
00401 #define DDD1    1
00402 #define DDD0    0
00403 
00404 /* PIND */
00405 #define PIND7   7
00406 #define PIND6   6
00407 #define PIND5   5
00408 #define PIND4   4
00409 #define PIND3   3
00410 #define PIND2   2
00411 #define PIND1   1
00412 #define PIND0   0
00413 
00414 /* SPSR */
00415 #define SPIF    7
00416 #define WCOL    6
00417 #define SPI2X   0
00418 
00419 /* SPCR */
00420 #define SPIE    7
00421 #define SPE 6
00422 #define DORD    5
00423 #define MSTR    4
00424 #define CPOL    3
00425 #define CPHA    2
00426 #define SPR1    1
00427 #define SPR0    0
00428 
00429 /* UCSRA */
00430 #define RXC 7
00431 #define TXC 6
00432 #define UDRE    5
00433 #define FE  4
00434 #define DOR 3
00435 #define PE  2
00436 #define U2X 1
00437 #define MPCM    0
00438 
00439 /* UCSRB */
00440 #define RXCIE   7
00441 #define TXCIE   6
00442 #define UDRIE   5
00443 #define RXEN    4
00444 #define TXEN    3
00445 #define UCSZ2   2
00446 #define RXB8    1
00447 #define TXB8    0
00448 
00449 /* ACSR */
00450 #define ACD 7
00451 #define ACBG    6
00452 #define ACO 5
00453 #define ACI 4
00454 #define ACIE    3
00455 #define ACIC    2
00456 #define ACIS1   1
00457 #define ACIS0   0
00458 
00459 /* ADCSR / ADCSRA */
00460 #define ADEN    7
00461 #define ADSC    6
00462 #define ADFR    5
00463 #define ADIF    4
00464 #define ADIE    3
00465 #define ADPS2   2
00466 #define ADPS1   1
00467 #define ADPS0   0
00468 
00469 /* ADMUX */
00470 #define REFS1   7
00471 #define REFS0   6
00472 #define ADLAR   5
00473 /* bit 4 reserved */
00474 #define MUX3    3
00475 #define MUX2    2
00476 #define MUX1    1
00477 #define MUX0    0
00478 
00479 /* Constants */
00480 #define SPM_PAGESIZE 64
00481 #define RAMEND      0x45F
00482 #define XRAMEND     0x45F
00483 #define E2END       0x1FF
00484 #define FLASHEND    0x1FFF
00485 
00486 
00487 #endif /*ASURO_UNIX_H_*/

Generated on Fri May 12 10:11:15 2006 for simsuro by  doxygen 1.4.6