mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-07 16:23:38 +03:00
Fix according to the discussion of issue #3140 https://github.com/esp8266/Arduino/issues/3140
pgm_read_byte() and pgm_read_word() need to be macros, as some third party libraries and sketches testing macro existence.
This commit is contained in:
parent
db8868da1d
commit
c52b0da11c
@ -99,19 +99,23 @@ int vsnprintf_P(char *str, size_t strSize, PGM_P formatP, va_list ap) __attribut
|
|||||||
:"1"(addr) \
|
:"1"(addr) \
|
||||||
:);
|
:);
|
||||||
|
|
||||||
static inline uint8_t pgm_read_byte(const void* addr) {
|
static inline uint8_t pgm_read_byte_inlined(const void* addr) {
|
||||||
register uint32_t res;
|
register uint32_t res;
|
||||||
pgm_read_with_offset(addr, res);
|
pgm_read_with_offset(addr, res);
|
||||||
return (uint8_t) res; /* This masks the lower byte from the returned word */
|
return (uint8_t) res; /* This masks the lower byte from the returned word */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Although this says "word", it's actually 16 bit, i.e. half word on Xtensa */
|
/* Although this says "word", it's actually 16 bit, i.e. half word on Xtensa */
|
||||||
static inline uint16_t pgm_read_word(const void* addr) {
|
static inline uint16_t pgm_read_word_inlined(const void* addr) {
|
||||||
register uint32_t res;
|
register uint32_t res;
|
||||||
pgm_read_with_offset(addr, res);
|
pgm_read_with_offset(addr, res);
|
||||||
return (uint16_t) res; /* This masks the lower half-word from the returned word */
|
return (uint16_t) res; /* This masks the lower half-word from the returned word */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure, that libraries checking existence of this macro are not failing
|
||||||
|
#define pgm_read_byte(addr) pgm_read_byte_inlined(addr)
|
||||||
|
#define pgm_read_word(addr) pgm_read_word_inlined(addr)
|
||||||
|
|
||||||
#else //__ets__
|
#else //__ets__
|
||||||
#define pgm_read_byte(addr) (*reinterpret_cast<const uint8_t*>(addr))
|
#define pgm_read_byte(addr) (*reinterpret_cast<const uint8_t*>(addr))
|
||||||
#define pgm_read_word(addr) (*reinterpret_cast<const uint16_t*>(addr))
|
#define pgm_read_word(addr) (*reinterpret_cast<const uint16_t*>(addr))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user