Main Page   Compound List   File List   Compound Members   File Members  

pgmspace.h

Go to the documentation of this file.
00001 /*
00002    pgmspace.h
00003 
00004    Contributors:
00005      Created by Marek Michalkiewicz <marekm@linux.org.pl>
00006 
00007    THIS SOFTWARE IS NOT COPYRIGHTED
00008 
00009    This source code is offered for use in the public domain.  You may
00010    use, modify or distribute it freely.
00011 
00012    This code is distributed in the hope that it will be useful, but
00013    WITHOUT ANY WARRANTY.  ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
00014    DISCLAIMED.  This includes but is not limited to warranties of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  */
00017 
00018 /*
00019    pgmspace.h - this is an attempt to provide some compatibility with
00020    header files that come with IAR C, to make porting applications
00021    between different compilers easier.  No 100% compatibility though
00022    (GCC does not have full support for multiple address spaces yet).
00023  */
00024 
00025 #ifndef __PGMSPACE_H_
00026 #define __PGMSPACE_H_ 1
00027 
00028 #define __need_size_t
00029 #include <stddef.h>
00030 
00031 /* #include <io.h> */
00032 
00033 #ifndef __ATTR_CONST__
00034 #define __ATTR_CONST__ __attribute__((__const__))
00035 #endif
00036 
00037 #ifndef __ATTR_PROGMEM__
00038 #define __ATTR_PROGMEM__ __attribute__((__progmem__))
00039 #endif
00040 
00041 #ifndef __ATTR_PURE__
00042 #define __ATTR_PURE__ __attribute__((__pure__))
00043 #endif
00044 
00045 #define PROGMEM __ATTR_PROGMEM__
00046 
00047 typedef void prog_void PROGMEM;
00048 typedef char prog_char PROGMEM;
00049 typedef unsigned char prog_uchar PROGMEM;
00050 typedef int prog_int PROGMEM;
00051 typedef long prog_long PROGMEM;
00052 typedef long long prog_long_long PROGMEM;
00053 
00054 #define PSTR(s) ({static char __c[] PROGMEM = (s); __c;})
00055 
00056 /* _LPM(), _ELPM() */
00057 #include <ina90.h>
00058 
00059 static inline unsigned char __lpm_inline(unsigned short __addr) __ATTR_CONST__;
00060 static inline unsigned char __lpm_inline(unsigned short __addr)
00061 {
00062         return _LPM(__addr);
00063 }
00064 
00065 #ifdef RAMPZ  /* >64K program memory (ATmega103) */
00066 /*
00067    use this for access to >64K program memory (ATmega103),
00068    addr = RAMPZ:r31:r30 (if possible, put your constant tables in the
00069    lower 64K and use "lpm" - it is more efficient that way, and you can
00070    still use the upper 64K for executable code).
00071  */
00072 
00073 static inline unsigned char __elpm_inline(unsigned long __addr) __ATTR_CONST__;
00074 static inline unsigned char __elpm_inline(unsigned long __addr)
00075 {
00076         return _ELPM(__addr);
00077 }
00078 #endif
00079 
00080 #if 0
00081 #define PRG_RDB(addr) __lpm_inline((unsigned short)(addr))
00082 #else
00083 #define PRG_RDB(addr) _LPM((unsigned short)(addr))
00084 #endif
00085 
00086 #ifndef PGM_P
00087 #define PGM_P const prog_char *
00088 #endif
00089 
00090 #ifndef PGM_VOID_P
00091 #define PGM_VOID_P const prog_void *
00092 #endif
00093 
00094 extern void *memcpy_P(void *, PGM_VOID_P, size_t);
00095 extern char *strcat_P(char *, PGM_P);
00096 extern int strcmp_P(const char *, PGM_P) __ATTR_PURE__;
00097 extern char *strcpy_P(char *, PGM_P);
00098 extern int strcasecmp_P(const char *, PGM_P) __ATTR_PURE__;
00099 extern size_t strlen_P(PGM_P) __ATTR_CONST__; /* program memory can't change */
00100 extern int strncmp_P(const char *, PGM_P, size_t) __ATTR_PURE__;
00101 extern int strncasecmp_P(const char *, PGM_P) __ATTR_PURE__;
00102 extern char *strncpy_P(char *, PGM_P, size_t);
00103 
00104 #if 0  /* not implemented yet */
00105 extern int printf_P(PGM_P, ...);
00106 extern int puts_P(PGM_P);
00107 extern int scanf_P(PGM_P, ...);
00108 extern int sprintf_P(char *, PGM_P, ...);
00109 extern int sscanf_P(const char *, PGM_P, ...);
00110 extern PGM_P strerror_P(int);
00111 #endif
00112 
00113 #endif /* __PGMSPACE_H_ */
00114 

Generated at Fri Jul 19 14:55:41 2002 for avrgcc by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001