X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=mware%2Fpgm.h;h=4bd1018c451f7020f598f2800b6f812698591795;hb=3b33848a29f6a9ba49a2913ba6b721e01d8b95f5;hp=20bb416e3aab2e202629bf562b3681a8d0db7549;hpb=cdf3e45aaa38fc701dceeb57e6ceedd6ca68f408;p=bertos.git diff --git a/mware/pgm.h b/mware/pgm.h index 20bb416e..4bd1018c 100755 --- a/mware/pgm.h +++ b/mware/pgm.h @@ -22,7 +22,9 @@ #ifndef MWARE_PGM_H #define MWARE_PGM_H -#include +#include +#include /* For intXX_t */ +#include /* For CPU_HARVARD */ #if CPU_AVR @@ -74,7 +76,8 @@ }) - #else + #else /* !__AVR_ENHANCED__ */ + #define pgm_read_char(addr) \ ({ \ uint16_t __addr16 = (uint16_t)(addr); \ @@ -133,10 +136,20 @@ __result; \ }) + #endif /* !__AVR_ENHANCED__ */ + + #if SIZEOF_INT == 2 + #define pgm_read_int(addr) ((int)pgm_read_uint16_t(addr)) + #else + #error Missing support for CPU word size != 16bit #endif + #ifndef PROGMEM #define PROGMEM __attribute__((__progmem__)) + #endif + #ifndef PSTR #define PSTR(s) ({ static const char __c[] PROGMEM = (s); &__c[0]; }) + #endif #elif CPU_HARVARD #error Missing CPU support @@ -147,7 +160,7 @@ #endif #ifndef PROGMEM -#define PROGMEM /* nothing */ +#define PROGMEM /* nothing */ #endif /*! @@ -197,10 +210,12 @@ typedef PROGMEM uint32_t pgm_uint32_t; #ifdef _PROGMEM #define PGM_READ_CHAR(s) pgm_read_char(s) #define PGM_FUNC(x) x ## _P + #define PGM_STR(x) PSTR(x) #define PGM_ATTR PROGMEM #else #define PGM_READ_CHAR(s) (*(s)) #define PGM_FUNC(x) x + #define PGM_STR(x) x #define PGM_ATTR /* nothing */ #endif /* \} */