1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00

Merge pull request #1170 from jensh/jens/patch-pgmspace-c

Make pgm_read_byte() and pgm_read_word() usable from c.
This commit is contained in:
Ivan Grokhotkov 2015-12-07 22:09:14 +03:00
commit 6d32c6743e

View File

@ -78,7 +78,7 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut
(__extension__({ \
PGM_P __local = (PGM_P)(addr); /* isolate varible for macro expansion */ \
ptrdiff_t __offset = ((uint32_t)__local & 0x00000003); /* byte aligned mask */ \
const uint32_t* __addr32 = reinterpret_cast<const uint32_t*>(reinterpret_cast<const uint8_t*>(__local)-__offset); \
const uint32_t* __addr32 = (const uint32_t*)((const uint8_t*)(__local)-__offset); \
uint8_t __result = ((*__addr32) >> (__offset * 8)); \
__result; \
}))
@ -87,7 +87,7 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut
(__extension__({ \
PGM_P __local = (PGM_P)(addr); /* isolate varible for macro expansion */ \
ptrdiff_t __offset = ((uint32_t)__local & 0x00000002); /* word aligned mask */ \
const uint32_t* __addr32 = reinterpret_cast<const uint32_t*>(reinterpret_cast<const uint8_t*>(__local) - __offset); \
const uint32_t* __addr32 = (const uint32_t*)((const uint8_t*)(__local) - __offset); \
uint16_t __result = ((*__addr32) >> (__offset * 8)); \
__result; \
}))