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