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