How to transplant pgm_read_byte inside Arduino to other systems?

123 Views Asked by At

Everyone.

I am using Renesas RA series MCU,

How to transplant pgm_read_byte()?

Can someone teach me?

Thankyou so much.=]

1

There are 1 best solutions below

0
On

How to transplant pgm_read_byte()?

The data is already const and / or constexpr. For sources that are compatible across non-AVR targets, you would:

#if defined __AVR__ && defined __GNUC__
#include <avr/pgmspace.h>
#else // not avr-gcc
#define PROGMEM /* empty */
#define pgm_read_byte(x) (*(x))
#define pgm_read_word(x) (*(x))
#define pgm_read_dword(x) (*(x))
#define pgm_read_float(x) (*(x))
...
#endif

Or, if it need not be cross-target compatible, just do vanilla C/C++ and

  • Drop #include <avr/pgmspace.h>.
  • Drop PROGMEM.
  • Replace any pgm_read_xxx(&var) my just accessing var directly.