|
1 |
| -/* |
2 |
| - pgmspace.h - Definitions for compatibility with AVR pgmspace macros |
3 |
| -
|
4 |
| - Copyright (c) 2015 Arduino LLC |
5 |
| -
|
6 |
| - Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com) |
7 |
| -
|
8 |
| - Permission is hereby granted, free of charge, to any person obtaining a copy |
9 |
| - of this software and associated documentation files (the "Software"), to deal |
10 |
| - in the Software without restriction, including without limitation the rights |
11 |
| - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
12 |
| - copies of the Software, and to permit persons to whom the Software is |
13 |
| - furnished to do so, subject to the following conditions: |
14 |
| -
|
15 |
| - The above copyright notice and this permission notice shall be included in |
16 |
| - all copies or substantial portions of the Software. |
17 |
| -
|
18 |
| - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19 |
| - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20 |
| - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
21 |
| - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22 |
| - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
23 |
| - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
24 |
| - THE SOFTWARE |
25 |
| -*/ |
26 |
| - |
27 |
| -#ifndef __PGMSPACE_H_ |
28 |
| -#define __PGMSPACE_H_ 1 |
29 |
| - |
30 |
| -#include <inttypes.h> |
31 |
| - |
32 |
| -#define PROGMEM |
33 |
| -#define PGM_P const char * |
34 |
| -#define PSTR(str) (str) |
35 |
| - |
36 |
| -#define _SFR_BYTE(n) (n) |
37 |
| - |
38 |
| -typedef void prog_void; |
39 |
| -typedef char prog_char; |
40 |
| -typedef unsigned char prog_uchar; |
41 |
| -typedef int8_t prog_int8_t; |
42 |
| -typedef uint8_t prog_uint8_t; |
43 |
| -typedef int16_t prog_int16_t; |
44 |
| -typedef uint16_t prog_uint16_t; |
45 |
| -typedef int32_t prog_int32_t; |
46 |
| -typedef uint32_t prog_uint32_t; |
47 |
| -typedef int64_t prog_int64_t; |
48 |
| -typedef uint64_t prog_uint64_t; |
49 |
| - |
50 |
| -typedef const void* int_farptr_t; |
51 |
| -typedef const void* uint_farptr_t; |
52 |
| - |
53 |
| -#define memchr_P(s, c, n) memchr((s), (c), (n)) |
54 |
| -#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n)) |
55 |
| -#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n)) |
56 |
| -#define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) |
57 |
| -#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen)) |
58 |
| -#define memrchr_P(s, c, n) memrchr((s), (c), (n)) |
59 |
| -#define strcat_P(dest, src) strcat((dest), (src)) |
60 |
| -#define strchr_P(s, c) strchr((s), (c)) |
61 |
| -#define strchrnul_P(s, c) strchrnul((s), (c)) |
62 |
| -#define strcmp_P(a, b) strcmp((a), (b)) |
63 |
| -#define strcpy_P(dest, src) strcpy((dest), (src)) |
64 |
| -#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2)) |
65 |
| -#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle)) |
66 |
| -#define strcspn_P(s, accept) strcspn((s), (accept)) |
67 |
| -#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n)) |
68 |
| -#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n)) |
69 |
| -#define strlen_P(a) strlen((a)) |
70 |
| -#define strnlen_P(s, n) strnlen((s), (n)) |
71 |
| -#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n)) |
72 |
| -#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n)) |
73 |
| -#define strncat_P(s1, s2, n) strncat((s1), (s2), (n)) |
74 |
| -#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n)) |
75 |
| -#define strpbrk_P(s, accept) strpbrk((s), (accept)) |
76 |
| -#define strrchr_P(s, c) strrchr((s), (c)) |
77 |
| -#define strsep_P(sp, delim) strsep((sp), (delim)) |
78 |
| -#define strspn_P(s, accept) strspn((s), (accept)) |
79 |
| -#define strstr_P(a, b) strstr((a), (b)) |
80 |
| -#define strtok_P(s, delim) strtok((s), (delim)) |
81 |
| -#define strtok_rP(s, delim, last) strtok((s), (delim), (last)) |
82 |
| - |
83 |
| -#define strlen_PF(a) strlen((a)) |
84 |
| -#define strnlen_PF(src, len) strnlen((src), (len)) |
85 |
| -#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len)) |
86 |
| -#define strcpy_PF(dest, src) strcpy((dest), (src)) |
87 |
| -#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len)) |
88 |
| -#define strcat_PF(dest, src) strcat((dest), (src)) |
89 |
| -#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len)) |
90 |
| -#define strncat_PF(dest, src, len) strncat((dest), (src), (len)) |
91 |
| -#define strcmp_PF(s1, s2) strcmp((s1), (s2)) |
92 |
| -#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n)) |
93 |
| -#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2)) |
94 |
| -#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n)) |
95 |
| -#define strstr_PF(s1, s2) strstr((s1), (s2)) |
96 |
| -#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n)) |
97 |
| -#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n)) |
98 |
| - |
99 |
| -#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) |
100 |
| -#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__) |
101 |
| - |
102 |
| -#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) |
103 |
| -#define pgm_read_word(addr) (*(const unsigned short *)(addr)) |
104 |
| -#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) |
105 |
| -#define pgm_read_float(addr) (*(const float *)(addr)) |
106 |
| -#define pgm_read_ptr(addr) (*(const void **)(addr)) |
107 |
| - |
108 |
| -#define pgm_read_byte_near(addr) pgm_read_byte(addr) |
109 |
| -#define pgm_read_word_near(addr) pgm_read_word(addr) |
110 |
| -#define pgm_read_dword_near(addr) pgm_read_dword(addr) |
111 |
| -#define pgm_read_float_near(addr) pgm_read_float(addr) |
112 |
| -#define pgm_read_ptr_near(addr) pgm_read_ptr(addr) |
113 |
| - |
114 |
| -#define pgm_read_byte_far(addr) pgm_read_byte(addr) |
115 |
| -#define pgm_read_word_far(addr) pgm_read_word(addr) |
116 |
| -#define pgm_read_dword_far(addr) pgm_read_dword(addr) |
117 |
| -#define pgm_read_float_far(addr) pgm_read_float(addr) |
118 |
| -#define pgm_read_ptr_far(addr) pgm_read_ptr(addr) |
119 |
| - |
120 |
| -#define pgm_get_far_address(addr) (&(addr)) |
121 |
| - |
122 |
| -#endif |
| 1 | +/* |
| 2 | + pgmspace.h - Definitions for compatibility with AVR pgmspace macros |
| 3 | +
|
| 4 | + Copyright (c) 2015 Arduino LLC |
| 5 | +
|
| 6 | + Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com) |
| 7 | +
|
| 8 | + Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | + of this software and associated documentation files (the "Software"), to deal |
| 10 | + in the Software without restriction, including without limitation the rights |
| 11 | + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | + copies of the Software, and to permit persons to whom the Software is |
| 13 | + furnished to do so, subject to the following conditions: |
| 14 | +
|
| 15 | + The above copyright notice and this permission notice shall be included in |
| 16 | + all copies or substantial portions of the Software. |
| 17 | +
|
| 18 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | + THE SOFTWARE |
| 25 | +*/ |
| 26 | + |
| 27 | +#ifndef __PGMSPACE_H_ |
| 28 | +#define __PGMSPACE_H_ 1 |
| 29 | + |
| 30 | +#include <inttypes.h> |
| 31 | + |
| 32 | +#define PROGMEM |
| 33 | +#define PGM_P const char * |
| 34 | +#define PSTR(str) (str) |
| 35 | + |
| 36 | +#define _SFR_BYTE(n) (n) |
| 37 | + |
| 38 | +typedef void prog_void; |
| 39 | +typedef char prog_char; |
| 40 | +typedef unsigned char prog_uchar; |
| 41 | +typedef int8_t prog_int8_t; |
| 42 | +typedef uint8_t prog_uint8_t; |
| 43 | +typedef int16_t prog_int16_t; |
| 44 | +typedef uint16_t prog_uint16_t; |
| 45 | +typedef int32_t prog_int32_t; |
| 46 | +typedef uint32_t prog_uint32_t; |
| 47 | +typedef int64_t prog_int64_t; |
| 48 | +typedef uint64_t prog_uint64_t; |
| 49 | + |
| 50 | +typedef const void* int_farptr_t; |
| 51 | +typedef const void* uint_farptr_t; |
| 52 | + |
| 53 | +#define memchr_P(s, c, n) memchr((s), (c), (n)) |
| 54 | +#define memcmp_P(s1, s2, n) memcmp((s1), (s2), (n)) |
| 55 | +#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n)) |
| 56 | +#define memcpy_P(dest, src, n) memcpy((dest), (src), (n)) |
| 57 | +#define memmem_P(haystack, haystacklen, needle, needlelen) memmem((haystack), (haystacklen), (needle), (needlelen)) |
| 58 | +#define memrchr_P(s, c, n) memrchr((s), (c), (n)) |
| 59 | +#define strcat_P(dest, src) strcat((dest), (src)) |
| 60 | +#define strchr_P(s, c) strchr((s), (c)) |
| 61 | +#define strchrnul_P(s, c) strchrnul((s), (c)) |
| 62 | +#define strcmp_P(a, b) strcmp((a), (b)) |
| 63 | +#define strcpy_P(dest, src) strcpy((dest), (src)) |
| 64 | +#define strcasecmp_P(s1, s2) strcasecmp((s1), (s2)) |
| 65 | +#define strcasestr_P(haystack, needle) strcasestr((haystack), (needle)) |
| 66 | +#define strcspn_P(s, accept) strcspn((s), (accept)) |
| 67 | +#define strlcat_P(s1, s2, n) strlcat((s1), (s2), (n)) |
| 68 | +#define strlcpy_P(s1, s2, n) strlcpy((s1), (s2), (n)) |
| 69 | +#define strlen_P(a) strlen((a)) |
| 70 | +#define strnlen_P(s, n) strnlen((s), (n)) |
| 71 | +#define strncmp_P(s1, s2, n) strncmp((s1), (s2), (n)) |
| 72 | +#define strncasecmp_P(s1, s2, n) strncasecmp((s1), (s2), (n)) |
| 73 | +#define strncat_P(s1, s2, n) strncat((s1), (s2), (n)) |
| 74 | +#define strncpy_P(s1, s2, n) strncpy((s1), (s2), (n)) |
| 75 | +#define strpbrk_P(s, accept) strpbrk((s), (accept)) |
| 76 | +#define strrchr_P(s, c) strrchr((s), (c)) |
| 77 | +#define strsep_P(sp, delim) strsep((sp), (delim)) |
| 78 | +#define strspn_P(s, accept) strspn((s), (accept)) |
| 79 | +#define strstr_P(a, b) strstr((a), (b)) |
| 80 | +#define strtok_P(s, delim) strtok((s), (delim)) |
| 81 | +#define strtok_rP(s, delim, last) strtok((s), (delim), (last)) |
| 82 | + |
| 83 | +#define strlen_PF(a) strlen((a)) |
| 84 | +#define strnlen_PF(src, len) strnlen((src), (len)) |
| 85 | +#define memcpy_PF(dest, src, len) memcpy((dest), (src), (len)) |
| 86 | +#define strcpy_PF(dest, src) strcpy((dest), (src)) |
| 87 | +#define strncpy_PF(dest, src, len) strncpy((dest), (src), (len)) |
| 88 | +#define strcat_PF(dest, src) strcat((dest), (src)) |
| 89 | +#define strlcat_PF(dest, src, len) strlcat((dest), (src), (len)) |
| 90 | +#define strncat_PF(dest, src, len) strncat((dest), (src), (len)) |
| 91 | +#define strcmp_PF(s1, s2) strcmp((s1), (s2)) |
| 92 | +#define strncmp_PF(s1, s2, n) strncmp((s1), (s2), (n)) |
| 93 | +#define strcasecmp_PF(s1, s2) strcasecmp((s1), (s2)) |
| 94 | +#define strncasecmp_PF(s1, s2, n) strncasecmp((s1), (s2), (n)) |
| 95 | +#define strstr_PF(s1, s2) strstr((s1), (s2)) |
| 96 | +#define strlcpy_PF(dest, src, n) strlcpy((dest), (src), (n)) |
| 97 | +#define memcmp_PF(s1, s2, n) memcmp((s1), (s2), (n)) |
| 98 | + |
| 99 | +#define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__) |
| 100 | +#define snprintf_P(s, f, ...) snprintf((s), (f), __VA_ARGS__) |
| 101 | + |
| 102 | +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) |
| 103 | +#define pgm_read_word(addr) (*(const unsigned short *)(addr)) |
| 104 | +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) |
| 105 | +#define pgm_read_float(addr) (*(const float *)(addr)) |
| 106 | +#define pgm_read_ptr(addr) (*(const void **)(addr)) |
| 107 | + |
| 108 | +#define pgm_read_byte_near(addr) pgm_read_byte(addr) |
| 109 | +#define pgm_read_word_near(addr) pgm_read_word(addr) |
| 110 | +#define pgm_read_dword_near(addr) pgm_read_dword(addr) |
| 111 | +#define pgm_read_float_near(addr) pgm_read_float(addr) |
| 112 | +#define pgm_read_ptr_near(addr) pgm_read_ptr(addr) |
| 113 | + |
| 114 | +#define pgm_read_byte_far(addr) pgm_read_byte(addr) |
| 115 | +#define pgm_read_word_far(addr) pgm_read_word(addr) |
| 116 | +#define pgm_read_dword_far(addr) pgm_read_dword(addr) |
| 117 | +#define pgm_read_float_far(addr) pgm_read_float(addr) |
| 118 | +#define pgm_read_ptr_far(addr) pgm_read_ptr(addr) |
| 119 | + |
| 120 | +#define pgm_get_far_address(addr) (&(addr)) |
| 121 | + |
| 122 | +#endif |
0 commit comments