Luciano
Luciano

Reputation: 33

How to transplant pgm_read_byte inside Arduino to other systems?

Everyone.

I am using Renesas RA series MCU,

How to transplant pgm_read_byte()?

Can someone teach me?

Thankyou so much.=]

Upvotes: -1

Views: 390

Answers (1)

emacs drives me nuts
emacs drives me nuts

Reputation: 3888

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.

Upvotes: 0

Related Questions