00001 #ifndef _ARCH_AVR_ICC_H_
00002 #define _ARCH_AVR_ICC_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 #include <stddef.h>
00076 #include <macros.h>
00077 #include <eeprom.h>
00078
00086 #if defined(_MCU_enhanced) || defined(_MCU_extended)
00087 #undef __AVR_ENHANCED__
00088 #define __AVR_ENHANCED__
00089 #endif
00090
00098 #ifndef CONST
00099 #define CONST
00100 #endif
00101
00108 #ifndef INLINE
00109 #define INLINE
00110 #endif
00111
00121 #define printf printf_M
00122 #define puts puts_M
00123 #define sprintf sprintf_M
00124 #define vprintf vprintf_M
00125 #define scanf scanf_M
00126 #define gets gets_M
00127 #define malloc malloc_M
00128 #define realloc realloc_M
00129 #define free free_M
00130
00137 #define cprintf printf_P
00138 #define csprintf sprintf_P
00139 #define cscanf scanf_P
00140 #define csscanf sscanf_P
00141
00142 #define memcpy_P(dst, src_P, n) cmemcpy(dst, src_P, n)
00143 #define strcat_P(s1, s2_P) cstrcat(s1, s2_P)
00144 #define strcmp_P(s1_P, s2) cstrcmp(s2, s1_P)
00145 #define strlen_P(s_P) cstrlen(s_P)
00146 #define strncat_P(s1, s2_P, n) cstrncat(s1, s2_P, n)
00147 #define strncmp_P(s1_P, s2, n) cstrncmp(s1_P, s2, n)
00148 #define strcpy_P(dst, src_P) cstrcpy(dst, src_P)
00149 #define strncpy_P(x,y,z) cstrncpy(x,y,z)
00150
00159 #define strcasecmp(s1, s2) strcmp(s1, s2)
00160 #define strncasecmp(s1, s2, n) strncmp(s1, s2, n)
00161
00162
00166 #define __heap_start _bss_end
00167
00173 #define __attribute__(x)
00174
00180 #define PSTR(p) (p)
00181
00185 #define PRG_RDB(p) (*((const char *)(p)))
00186
00190 #define prog_char const char
00191
00195 #define prog_int const int
00196
00200 #define PGM_P prog_char *
00201
00202
00203
00204
00205
00206
00207 #define wdt_enable(tmo) \
00208 { \
00209 register unsigned char s = _BV(WDCE) | _BV(WDE); \
00210 register unsigned char r = tmo | _BV(WDE); \
00211 asm("in R0, 0x3F\n" \
00212 "cli\n" \
00213 "wdr\n" \
00214 "out 0x21, %s\n" \
00215 "out 0x21, %r\n" \
00216 "out 0x3F, R0\n"); \
00217 }
00218
00219 #define wdt_disable() \
00220 { \
00221 register unsigned char s = _BV(WDCE) | _BV(WDE); \
00222 register unsigned char r = 0; \
00223 asm("in R0, $3F\n" \
00224 "cli\n" \
00225 "out 0x21, %s\n" \
00226 "out 0x21, %r\n" \
00227 "out 0x3F, R0\n"); \
00228 }
00229
00230 #define wdt_reset() \
00231 { \
00232 _WDR(); \
00233 }
00234
00235
00236 #define __SFR_OFFSET 0
00237 #define SFR_IO_ADDR(sfr) ((sfr) - __SFR_OFFSET)
00238 #define SFR_MEM_ADDR(sfr) (sfr)
00239 #define SFR_IO_REG_P(sfr) ((sfr) < 0x40 + __SFR_OFFSET)
00240
00241 #define _SFR_MEM8(addr) (addr)
00242 #define _SFR_MEM16(addr) (addr)
00243
00244 #define BV(x) BIT(x)
00245 #define _BV(x) BIT(x)
00246
00247 #define cli() CLI()
00248 #define sei() SEI()
00249 #define cbi(reg, bit) (reg &= ~BIT(bit))
00250 #define sbi(reg, bit) (reg |= BIT(bit))
00251
00252
00253 #define loop_until_bit_is_set(reg, bit) while((reg & BIT(bit)) == 0)
00254
00255 #define bit_is_clear(reg, bit) ((reg & BIT(bit)) == 0)
00256 #define bit_is_set(reg, bit) ((reg & BIT(bit)) != 0)
00257
00258
00259 #define parity_even_bit(x) (0)
00260
00261
00262 #define SIGNAL(x) void x(void)
00263
00264 #define outp(val, reg) (reg = val)
00265 #define outb(reg, val) (reg = val)
00266
00267 #define inp(reg) (reg)
00268 #define inb(reg) (reg)
00269
00270 #include <eeprom.h>
00271
00272 #if defined(_MCU_enhanced) || defined(_MCU_extended)
00273
00274 #ifdef ATMega2560
00275 #include <iom2560v.h>
00276 #define __AVR_ATmega2560__
00277 #ifndef _EE_EXTIO
00278 #error "Looks like wrong platform. Select avrext-icc, not avr-icc."
00279 #endif
00280 #elif defined(ATMega2561)
00281 #include <iom2561v.h>
00282 #define __AVR_ATmega2561__
00283 #ifndef _EE_EXTIO
00284 #error "Looks like wrong platform. Select avrext-icc, not avr-icc."
00285 #endif
00286 #else
00287 #include <iom128v.h>
00288 #define __AVR_ATmega128__
00289 #endif
00290
00291 #ifndef RAMEND
00292 #if defined(ATMega2560) || defined(ATMega2561)
00293 #define RAMEND 0x21FF
00294 #else
00295 #define RAMEND 0x10FF
00296 #endif
00297 #endif
00298
00299 #ifndef SRW
00300 #define SRW 6
00301 #endif
00302
00303
00304 #ifndef TXC
00305 #define TXC TXC0
00306 #endif
00307 #ifndef ADCSR
00308 #define ADCSR ADCSRA
00309 #endif
00310
00311
00312 #define TW_START 0x08
00313 #define TW_REP_START 0x10
00314
00315 #define TW_MT_SLA_ACK 0x18
00316 #define TW_MT_SLA_NACK 0x20
00317 #define TW_MT_DATA_ACK 0x28
00318 #define TW_MT_DATA_NACK 0x30
00319 #define TW_MT_ARB_LOST 0x38
00320
00321 #define TW_MR_ARB_LOST 0x38
00322 #define TW_MR_SLA_ACK 0x40
00323 #define TW_MR_SLA_NACK 0x48
00324 #define TW_MR_DATA_ACK 0x50
00325 #define TW_MR_DATA_NACK 0x58
00326
00327 #define TW_ST_SLA_ACK 0xA8
00328 #define TW_ST_ARB_LOST_SLA_ACK 0xB0
00329 #define TW_ST_DATA_ACK 0xB8
00330 #define TW_ST_DATA_NACK 0xC0
00331 #define TW_ST_LAST_DATA 0xC8
00332
00333 #define TW_SR_SLA_ACK 0x60
00334 #define TW_SR_ARB_LOST_SLA_ACK 0x68
00335 #define TW_SR_GCALL_ACK 0x70
00336 #define TW_SR_ARB_LOST_GCALL_ACK 0x78
00337 #define TW_SR_DATA_ACK 0x80
00338 #define TW_SR_DATA_NACK 0x88
00339 #define TW_SR_GCALL_DATA_ACK 0x90
00340 #define TW_SR_GCALL_DATA_NACK 0x98
00341 #define TW_SR_STOP 0xA0
00342
00343 #define TW_NO_INFO 0xF8
00344 #define TW_BUS_ERROR 0x00
00345
00346
00347 #else
00348
00349 #include <iom103v.h>
00350 #define __AVR_ATmega103__
00351
00352 #ifndef DOR
00353 #define DOR OVR
00354 #endif
00355
00356 #ifndef RAMEND
00357 #define RAMEND 0x0FFF
00358 #endif
00359
00360 #ifndef WDCE
00361 #define WDCE WDTOE
00362 #endif
00363
00364 #endif
00365
00366 #define eeprom_read_block(dst, addr, size) EEPROMReadBytes((int)addr, dst, size)
00367 #define eeprom_write_byte(addr, src) EEPROMwrite((int)addr, src)
00368 #define eeprom_read_byte(addr) EEPROMread((int)addr)
00369
00370
00371 #endif
00372
00373