15 #define PROGMEM ICACHE_RODATA_ATTR
16 #define PGM_P const char *
17 #define PGM_VOID_P const void *
18 #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))
21 #define _SFR_BYTE(n) (n)
23 typedef void prog_void;
24 typedef char prog_char;
25 typedef unsigned char prog_uchar;
26 typedef int8_t prog_int8_t;
27 typedef uint8_t prog_uint8_t;
28 typedef int16_t prog_int16_t;
29 typedef uint16_t prog_uint16_t;
30 typedef int32_t prog_int32_t;
31 typedef uint32_t prog_uint32_t;
33 #define SIZE_IRRELEVANT 0x7fffffff
43 int memcmp_P(
const void* buf1, PGM_VOID_P buf2P,
size_t size);
46 void* memccpy_P(
void* dest, PGM_VOID_P src,
int c,
size_t count);
47 void* memmem_P(
const void* buf,
size_t bufSize, PGM_VOID_P findP,
size_t findPSize);
48 void* memcpy_P(
void* dest, PGM_VOID_P src,
size_t count);
50 char* strncpy_P(
char* dest, PGM_P src,
size_t size);
51 #define strcpy_P(dest, src) strncpy_P((dest), (src), SIZE_IRRELEVANT)
53 char* strncat_P(
char* dest, PGM_P src,
size_t size);
54 #define strcat_P(dest, src) strncat_P((dest), (src), SIZE_IRRELEVANT)
56 int strncmp_P(
const char* str1, PGM_P str2P,
size_t size);
57 #define strcmp_P(str1, str2P) strncmp_P((str1), (str2P), SIZE_IRRELEVANT)
59 int strncasecmp_P(
const char* str1, PGM_P str2P,
size_t size);
60 #define strcasecmp_P(str1, str2P) strncasecmp_P((str1), (str2P), SIZE_IRRELEVANT)
62 size_t strnlen_P(PGM_P s,
size_t size);
63 #define strlen_P(strP) strnlen_P((strP), SIZE_IRRELEVANT)
65 int printf_P(PGM_P formatP, ...) __attribute__((format(printf, 1, 2)));
66 int sprintf_P(
char *str, PGM_P formatP, ...) __attribute__((format(printf, 2, 3)));
67 int snprintf_P(
char *str,
size_t strSize, PGM_P formatP, ...) __attribute__((format(printf, 3, 4)));
68 int vsnprintf_P(
char *str,
size_t strSize, PGM_P formatP, va_list ap) __attribute__((format(printf, 3, 0)));
77 #define pgm_read_byte(addr) \
79 PGM_P __local = (PGM_P)(addr); \
80 ptrdiff_t __offset = ((uint32_t)__local & 0x00000003); \
81 const uint32_t* __addr32 = (const uint32_t*)((const uint8_t*)(__local)-__offset); \
82 uint8_t __result = ((*__addr32) >> (__offset * 8)); \
86 #define pgm_read_word(addr) \
88 PGM_P __local = (PGM_P)(addr); \
89 ptrdiff_t __offset = ((uint32_t)__local & 0x00000002); \
90 const uint32_t* __addr32 = (const uint32_t*)((const uint8_t*)(__local) - __offset); \
91 uint16_t __result = ((*__addr32) >> (__offset * 8)); \
95 #define pgm_read_dword(addr) (*reinterpret_cast<const uint32_t*>(addr))
96 #define pgm_read_float(addr) (*reinterpret_cast<const float*>(addr))
98 #define pgm_read_byte_near(addr) pgm_read_byte(addr)
99 #define pgm_read_word_near(addr) pgm_read_word(addr)
100 #define pgm_read_dword_near(addr) pgm_read_dword(addr)
101 #define pgm_read_float_near(addr) pgm_read_float(addr)
102 #define pgm_read_byte_far(addr) pgm_read_byte(addr)
103 #define pgm_read_word_far(addr) pgm_read_word(addr)
104 #define pgm_read_dword_far(addr) pgm_read_dword(addr)
105 #define pgm_read_float_far(addr) pgm_read_float(addr)
107 #endif //__PGMSPACE_H_