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
00076
00077
00078
00079
00080
00081 #include <stddef.h>
00082 #include <macros.h>
00083 #include <eeprom.h>
00084
00085
00086 #if defined(_MCU_Enhanced) && !defined(_MCU_enhanced)
00087 #define _MCU_enhanced
00088 #endif
00089
00090 #if defined(_MCU_Extended) && !defined(_MCU_extended)
00091 #define _MCU_extended
00092 #endif
00093
00101 #if defined(_MCU_enhanced) || defined(_MCU_extended)
00102 #undef __AVR_ENHANCED__
00103 #define __AVR_ENHANCED__
00104 #endif
00105
00113 #ifndef CONST
00114 #define CONST const
00115 #endif
00116
00123 #ifndef INLINE
00124 #define INLINE
00125 #endif
00126
00136 #define printf printf_M
00137 #define puts puts_M
00138 #define sprintf sprintf_M
00139 #define vprintf vprintf_M
00140 #define scanf scanf_M
00141 #define gets gets_M
00142 #define malloc malloc_M
00143 #define calloc calloc_M
00144 #define realloc realloc_M
00145 #define free free_M
00146
00153 #define cprintf printf_P
00154 #define csprintf sprintf_P
00155 #define cscanf scanf_P
00156 #define csscanf sscanf_P
00157
00158 #define memcpy_P(dst, src_P, n) cmemcpy(dst, src_P, n)
00159 #define strcat_P(s1, s2_P) cstrcat(s1, s2_P)
00160 #define strcmp_P(s1, s2_P) (-cstrcmp(s2_P, s1))
00161 #define strlen_P(s_P) cstrlen(s_P)
00162 #define strncat_P(s1, s2_P, n) cstrncat(s1, s2_P, n)
00163 #define strncmp_P(s1_P, s2, n) cstrncmp(s1_P, s2, n)
00164 #define strcpy_P(dst, src_P) cstrcpy(dst, src_P)
00165 #define strncpy_P(x,y,z) cstrncpy(x,y,z)
00166
00175 #define strcasecmp(s1, s2) strcmp(s1, s2)
00176 #define strncasecmp(s1, s2, n) strncmp(s1, s2, n)
00177
00178
00182 #define __heap_start _bss_end
00183
00189 #define __attribute__(x)
00190
00196 #define PSTR(p) (p)
00197
00201 #define PRG_RDB(p) (*((__flash char *)(p)))
00202
00206 #define prog_char __flash char
00207
00211 #define prog_int __flash int
00212
00216 #define PGM_P prog_char *
00217
00218
00219
00220
00221
00222
00223 #define wdt_enable(tmo) \
00224 { \
00225 register unsigned char s = _BV(WDCE) | _BV(WDE); \
00226 register unsigned char r = tmo | _BV(WDE); \
00227 asm("in R0, 0x3F\n" \
00228 "cli\n" \
00229 "wdr\n" \
00230 "out 0x21, %s\n" \
00231 "out 0x21, %r\n" \
00232 "out 0x3F, R0\n"); \
00233 }
00234
00235 #define wdt_disable() \
00236 { \
00237 register unsigned char s = _BV(WDCE) | _BV(WDE); \
00238 register unsigned char r = 0; \
00239 asm("in R0, $3F\n" \
00240 "cli\n" \
00241 "out 0x21, %s\n" \
00242 "out 0x21, %r\n" \
00243 "out 0x3F, R0\n"); \
00244 }
00245
00246 #define wdt_reset() \
00247 { \
00248 _WDR(); \
00249 }
00250
00251
00252 #define __SFR_OFFSET 0
00253 #define SFR_IO_ADDR(sfr) ((sfr) - __SFR_OFFSET)
00254 #define SFR_MEM_ADDR(sfr) (sfr)
00255 #define SFR_IO_REG_P(sfr) ((sfr) < 0x40 + __SFR_OFFSET)
00256
00257 #define _SFR_MEM8(addr) (addr)
00258 #define _SFR_MEM16(addr) (addr)
00259
00260 #define BV(x) BIT(x)
00261 #define _BV(x) BIT(x)
00262
00263 #define cli() CLI()
00264 #define sei() SEI()
00265 #define cbi(reg, bit) (reg &= ~BIT(bit))
00266 #define sbi(reg, bit) (reg |= BIT(bit))
00267
00268
00269 #define loop_until_bit_is_set(reg, bit) while((reg & BIT(bit)) == 0)
00270
00271 #define bit_is_clear(reg, bit) ((reg & BIT(bit)) == 0)
00272 #define bit_is_set(reg, bit) ((reg & BIT(bit)) != 0)
00273
00274
00275 #define parity_even_bit(x) (0)
00276
00277
00278 #define SIGNAL(x) void x(void)
00279
00280 #define outb(reg, val) (reg = val)
00281
00282 #define inb(reg) (reg)
00283
00284 #include <eeprom.h>
00285
00286 #if defined(_MCU_enhanced) || defined(_MCU_extended)
00287
00288 #ifdef ATMega2560
00289 #include <iom2560v.h>
00290 #define __AVR_ATmega2560__
00291 #ifndef _EE_EXTIO
00292 #error "Looks like wrong platform. Select avrext-icc, not avr-icc."
00293 #endif
00294 #elif defined(ATMega2561)
00295 #include <iom2561v.h>
00296 #define __AVR_ATmega2561__
00297 #ifndef _EE_EXTIO
00298 #error "Looks like wrong platform. Select avrext-icc, not avr-icc."
00299 #endif
00300 #else
00301 #include <iom128v.h>
00302 #define __AVR_ATmega128__
00303 #endif
00304
00305 #ifndef RAMEND
00306 #if defined(ATMega2560) || defined(ATMega2561)
00307 #define RAMEND 0x21FF
00308 #else
00309 #define RAMEND 0x10FF
00310 #endif
00311 #endif
00312
00313 #ifndef SRW
00314 #define SRW 6
00315 #endif
00316
00317
00318 #ifndef TXC
00319 #define TXC TXC0
00320 #endif
00321 #ifndef ADCSR
00322 #define ADCSR ADCSRA
00323 #endif
00324
00325
00326 #define TW_START 0x08
00327 #define TW_REP_START 0x10
00328
00329 #define TW_MT_SLA_ACK 0x18
00330 #define TW_MT_SLA_NACK 0x20
00331 #define TW_MT_DATA_ACK 0x28
00332 #define TW_MT_DATA_NACK 0x30
00333 #define TW_MT_ARB_LOST 0x38
00334
00335 #define TW_MR_ARB_LOST 0x38
00336 #define TW_MR_SLA_ACK 0x40
00337 #define TW_MR_SLA_NACK 0x48
00338 #define TW_MR_DATA_ACK 0x50
00339 #define TW_MR_DATA_NACK 0x58
00340
00341 #define TW_ST_SLA_ACK 0xA8
00342 #define TW_ST_ARB_LOST_SLA_ACK 0xB0
00343 #define TW_ST_DATA_ACK 0xB8
00344 #define TW_ST_DATA_NACK 0xC0
00345 #define TW_ST_LAST_DATA 0xC8
00346
00347 #define TW_SR_SLA_ACK 0x60
00348 #define TW_SR_ARB_LOST_SLA_ACK 0x68
00349 #define TW_SR_GCALL_ACK 0x70
00350 #define TW_SR_ARB_LOST_GCALL_ACK 0x78
00351 #define TW_SR_DATA_ACK 0x80
00352 #define TW_SR_DATA_NACK 0x88
00353 #define TW_SR_GCALL_DATA_ACK 0x90
00354 #define TW_SR_GCALL_DATA_NACK 0x98
00355 #define TW_SR_STOP 0xA0
00356
00357 #define TW_NO_INFO 0xF8
00358 #define TW_BUS_ERROR 0x00
00359
00360
00361 #else
00362
00363 #include <iom103v.h>
00364 #define __AVR_ATmega103__
00365
00366 #ifndef DOR
00367 #define DOR OVR
00368 #endif
00369
00370 #ifndef RAMEND
00371 #define RAMEND 0x0FFF
00372 #endif
00373
00374 #ifndef WDCE
00375 #define WDCE WDTOE
00376 #endif
00377
00378 #endif
00379
00380 #define eeprom_read_block(dst, addr, size) EEPROMReadBytes((int)addr, dst, size)
00381 #define eeprom_write_byte(addr, src) EEPROMwrite((int)addr, src)
00382 #define eeprom_read_byte(addr) EEPROMread((int)addr)
00383
00384 extern void *calloc(size_t num, size_t size);
00385 extern char *strdup(const char *str);
00386
00387 #include <string.h>
00388
00389
00390 #endif
00391
00392