diff options
author | Mark Kriegsman <kriegsman@tr.org> | 2017-03-25 02:52:48 +0300 |
---|---|---|
committer | Mark Kriegsman <kriegsman@tr.org> | 2017-03-25 02:52:48 +0300 |
commit | 06a5abcf1fa65115adb42a79e112a34e6c8ff5a7 (patch) | |
tree | f528cf9e5ce7a1801dc6bbbd3cf5af4a8857cc38 | |
parent | fbe8c5bb38139370592b52b303e00851208bb2fe (diff) |
Force gradient palettes to be aligned in memory on ARM. Only needed on some ARM platforms, but rather than play whack-a-mole with future chipsets and their requirements, we'll just be a little extra careful here. Fixes #428.
-rw-r--r-- | colorutils.h | 2 | ||||
-rw-r--r-- | fastled_progmem.h | 13 |
2 files changed, 15 insertions, 0 deletions
diff --git a/colorutils.h b/colorutils.h index f9c2d9d0..4fcf3940 100644 --- a/colorutils.h +++ b/colorutils.h @@ -1668,9 +1668,11 @@ void nblendPaletteTowardPalette( CRGBPalette16& currentPalette, // #define DEFINE_GRADIENT_PALETTE(X) \ + FL_ALIGN_PROGMEM \ extern const TProgmemRGBGradientPalette_byte X[] FL_PROGMEM = #define DECLARE_GRADIENT_PALETTE(X) \ + FL_ALIGN_PROGMEM \ extern const TProgmemRGBGradientPalette_byte X[] FL_PROGMEM diff --git a/fastled_progmem.h b/fastled_progmem.h index f182712a..cafb5369 100644 --- a/fastled_progmem.h +++ b/fastled_progmem.h @@ -63,6 +63,19 @@ FASTLED_NAMESPACE_BEGIN #endif +// On some platforms, most notably ARM M0, unaligned access +// to 'PROGMEM' for multibyte values (eg read dword) is +// not allowed and causes a crash. This macro can help +// force 4-byte alignment as needed. The FastLED gradient +// palette code uses 'read dword', and now uses this macro +// to make sure that gradient palettes are 4-byte aligned. +#ifdef FASTLED_ARM +#define FL_ALIGN_PROGMEM __attribute__ ((aligned (4))) +#else +#define FL_ALIGN_PROGMEM +#endif + + FASTLED_NAMESPACE_END #endif |