14 #include <sys/pgmspace.h> 31 #ifndef FLASH_MEMORY_START_ADDR 32 #define FLASH_MEMORY_START_ADDR 0 38 #define isFlashPtr(ptr) ((uint32_t)ptr >= FLASH_MEMORY_START_ADDR) 43 #define IS_ALIGNED(_x) (((uint32_t)(_x)&3) == 0) 48 #define ALIGNUP4(n) (((n) + 3) & ~3) 53 #define ALIGNDOWN4(n) ((n) & ~3) 55 #define printf_P_heap(f_P, ...) \ 57 char* __localF = (char*)malloc(strlen_P(f_P) + 1); \ 58 strcpy_P(__localF, f_P); \ 59 int __result = os_printf_plus(__localF, ##__VA_ARGS__); \ 64 #define printf_P_stack(f_P, ...) \ 67 strncpy_P(__localF, f_P, sizeof(__localF)); \ 68 __localF[sizeof(__localF) - 1] = '\0'; \ 69 m_printf(__localF, ##__VA_ARGS__); \ 72 #define printf_P printf_P_stack 81 #define PSTR_COUNTED(str) \ 83 static const char __pstr__[] PROGMEM = str; \ 94 DEFINE_PSTR_LOCAL(__pstr__, str); \ 95 LOAD_PSTR(buf, __pstr__); \ 122 int memcmp_aligned(
const void* ptr1,
const void* ptr2,
unsigned len);
128 #define DEFINE_PSTR(name, str) const char name[] PROGMEM_PSTR = str; 134 #define DEFINE_PSTR_LOCAL(name, str) static DEFINE_PSTR(name, str) 140 #define DECLARE_PSTR(name) extern const char name[] PROGMEM; 158 #define LOAD_PSTR(name, flash_str) \ 159 char name[ALIGNUP4(sizeof(flash_str))] __attribute__((aligned(4))); \ 160 memcpy_aligned(name, flash_str, sizeof(flash_str)); 162 #define _FLOAD(pstr) \ 164 LOAD_PSTR(_buf, pstr); \ 186 #define PSTR_ARRAY(name, str) \ 187 DEFINE_PSTR_LOCAL(__pstr__##name, str); \ 188 LOAD_PSTR(name, __pstr__##name) void * memcpy_aligned(void *dst, const void *src, unsigned len)
copy memory aligned to word boundaries
int memcmp_aligned(const void *ptr1, const void *ptr2, unsigned len)
compare memory aligned to word boundaries