11#ifndef __PGMSPACE_H_
22#define __PGMSPACE_H_
33
4+ #include <stdint.h>
5+ #include <stdio.h>
6+
7+ #ifdef __ets__
8+
49#ifdef __cplusplus
510extern "C" {
611#endif
7- #include <stdint.h>
8- #include <stdio.h>
912#include "ets_sys.h"
1013#include "osapi.h"
1114#ifdef __cplusplus
@@ -16,6 +19,13 @@ extern "C" {
1619#define PGM_P const char *
1720#define PGM_VOID_P const void *
1821#define PSTR (s ) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))
22+ #else //__ets__
23+ #define PROGMEM
24+ #define PGM_P const char *
25+ #define PGM_VOID_P const void *
26+ #define PSTR (s ) (s)
27+
28+ #endif // __ets__
1929
2030
2131#define _SFR_BYTE (n ) (n)
@@ -62,6 +72,8 @@ int strncasecmp_P(const char* str1, PGM_P str2P, size_t size);
6272size_t strnlen_P (PGM_P s , size_t size );
6373#define strlen_P (strP ) strnlen_P((strP), SIZE_IRRELEVANT)
6474
75+ char * strstr_P (const char * haystack , PGM_P needle );
76+
6577int printf_P (PGM_P formatP , ...) __attribute__((format (printf , 1 , 2 )));
6678int sprintf_P (char * str , PGM_P formatP , ...) __attribute__((format (printf , 2 , 3 )));
6779int snprintf_P (char * str , size_t strSize , PGM_P formatP , ...) __attribute__((format (printf , 3 , 4 )));
@@ -74,6 +86,7 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut
7486// b3, b2, b1, b0
7587// w1, w0
7688
89+ #ifdef __ets__
7790#define pgm_read_byte (addr ) \
7891(__extension__({ \
7992 PGM_P __local = (PGM_P)(addr); /* isolate varible for macro expansion */ \
@@ -91,6 +104,10 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut
91104 uint16_t __result = ((* __addr32 ) >> (__offset * 8 )); \
92105 __result ; \
93106}))
107+ #else //__ets__
108+ #define pgm_read_byte (addr ) (*reinterpret_cast<const uint8_t*>(addr))
109+ #define pgm_read_word (addr ) (*reinterpret_cast<const uint16_t*>(addr))
110+ #endif //__ets__
94111
95112#define pgm_read_dword (addr ) (*reinterpret_cast<const uint32_t*>(addr))
96113#define pgm_read_float (addr ) (*reinterpret_cast<const float*>(addr))
0 commit comments