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