Skip to content

Commit eebb7a2

Browse files
committed
Expand pgm_read_... macros
Using arduino-1.8.8/hardware/tools/avr/avr/include/avr/pgmspace.h as reference.
1 parent f0b54cf commit eebb7a2

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

cpp/arduino/avr/pgmspace.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,26 @@ out.each { |l| puts d(l) }
2929

3030
// everything's a no-op
3131
#define PSTR(s) ((const char *)(s))
32-
#define pgm_read_byte_near(x) (x)
33-
#define pgm_read_word_near(x) (x)
34-
#define pgm_read_dword_near(x) (x)
35-
#define pgm_read_float_near(x) (x)
36-
#define pgm_read_ptr_near(x) (x)
3732

38-
#define pgm_read_byte_far(x) (x)
39-
#define pgm_read_word_far(x) (x)
40-
#define pgm_read_dword_far(x) (x)
41-
#define pgm_read_float_far(x) (x)
42-
#define pgm_read_ptr_far(x) (x)
33+
#define pgm_read_byte_near(address_short) (* (const uint8_t *) (address_short) )
34+
#define pgm_read_word_near(address_short) (* (const uint16_t *) (address_short) )
35+
#define pgm_read_dword_near(address_short) (* (const uint32_t *) (address_short) )
36+
#define pgm_read_float_near(address_short) (* (const float *) (address_short) )
37+
#define pgm_read_ptr_near(address_short) (* (const void *) (address_short) )
4338

39+
#define pgm_read_byte_far(address_long) (* (const uint8_t *) (address_long) )
40+
#define pgm_read_word_far(address_long) (* (const uint16_t *) (address_long) )
41+
#define pgm_read_dword_far(address_long) (* (const uint32_t *) (address_long) )
42+
#define pgm_read_float_far(address_long) (* (const float *) (address_long) )
43+
#define pgm_read_ptr_far(address_long) (* (const void *) (address_long) )
4444

45-
#define pgm_read_byte(addr) (*(const uint8_t *)(addr))
46-
#define pgm_read_word(x) (x)
47-
#define pgm_read_dword(x) (x)
48-
#define pgm_read_float(x) (x)
49-
#define pgm_read_ptr(x) (x)
50-
#define pgm_get_far_address(x) (x)
45+
#define pgm_read_byte(address_short) pgm_read_byte_near(address_short)
46+
#define pgm_read_word(address_short) pgm_read_word_near(address_short)
47+
#define pgm_read_dword(address_short) pgm_read_dword_near(address_short)
48+
#define pgm_read_float(address_short) pgm_read_float_near(address_short)
49+
#define pgm_read_ptr(address_short) pgm_read_ptr_near(address_short)
50+
51+
#define pgm_get_far_address(var) ( (uint_farptr_t) (&(var)) )
5152

5253
#define memchr_P(...) ::memchr(__VA_ARGS__)
5354
#define memcmp_P(...) ::memcmp(__VA_ARGS__)

0 commit comments

Comments
 (0)