projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add support for ATMEGA1281.
[bertos.git]
/
mware
/
pgm.h
diff --git
a/mware/pgm.h
b/mware/pgm.h
index d8ef9f5426df09b5996b9c0c0ce64a7cf70d762c..5f10d002ea5a6c153048467cd1746da88a79a20b 100755
(executable)
--- a/
mware/pgm.h
+++ b/
mware/pgm.h
@@
-1,4
+1,4
@@
-/*
!
+/*
*
* \file
* <!--
* Copyright 2005 Develer S.r.l. (http://www.develer.com/)
* \file
* <!--
* Copyright 2005 Develer S.r.l. (http://www.develer.com/)
@@
-22,7
+22,9
@@
#ifndef MWARE_PGM_H
#define MWARE_PGM_H
#ifndef MWARE_PGM_H
#define MWARE_PGM_H
-#include <cpu_detect.h>
+#include <cfg/cpu_detect.h>
+#include <cfg/compiler.h> /* For intXX_t */
+#include <cfg/cpu.h> /* For CPU_HARVARD */
#if CPU_AVR
#if CPU_AVR
@@
-74,7
+76,8
@@
})
})
- #else
+ #else /* !__AVR_ENHANCED__ */
+
#define pgm_read_char(addr) \
({ \
uint16_t __addr16 = (uint16_t)(addr); \
#define pgm_read_char(addr) \
({ \
uint16_t __addr16 = (uint16_t)(addr); \
@@
-133,10
+136,23
@@
__result; \
})
__result; \
})
+ #endif /* !__AVR_ENHANCED__ */
+
+ #if SIZEOF_INT == 2
+ #define pgm_read_int(addr) ((int)pgm_read_uint16_t(addr))
+ #else
+ #error Missing support for CPU word size != 16bit
#endif
#endif
+ #ifndef PROGMEM
#define PROGMEM __attribute__((__progmem__))
#define PROGMEM __attribute__((__progmem__))
+ #endif
+ #ifndef PSTR
#define PSTR(s) ({ static const char __c[] PROGMEM = (s); &__c[0]; })
#define PSTR(s) ({ static const char __c[] PROGMEM = (s); &__c[0]; })
+ #endif
+ #ifndef PFUNC
+ #define PFUNC(x) x ## _P
+ #endif
#elif CPU_HARVARD
#error Missing CPU support
#elif CPU_HARVARD
#error Missing CPU support
@@
-146,11
+162,15
@@
#define PSTR /* nothing */
#endif
#define PSTR /* nothing */
#endif
+#ifndef PFUNC
+#define PFUNC(x) x
+#endif
+
#ifndef PROGMEM
#ifndef PROGMEM
-#define PROGMEM
/* nothing */
+#define PROGMEM /* nothing */
#endif
#endif
-/*
!
+/*
*
* \name Types for variables stored in program memory (harvard processors).
* \{
*/
* \name Types for variables stored in program memory (harvard processors).
* \{
*/
@@
-163,10
+183,8
@@
typedef PROGMEM int32_t pgm_int32_t;
typedef PROGMEM uint32_t pgm_uint32_t;
/*\}*/
typedef PROGMEM uint32_t pgm_uint32_t;
/*\}*/
-/*!
- * \def PGM_READ_CHAR
- * \def PGM_FUNC
- * \def PGM_ATTR
+/**
+ * \name PGM support macros.
*
* These macros enable dual compilation of code for both program
* and data memory.
*
* These macros enable dual compilation of code for both program
* and data memory.
@@
-193,16
+211,21
@@
typedef PROGMEM uint32_t pgm_uint32_t;
* // To be used when invoking inside other PGM_FUNC functions:
* PGM_FUNC(lcd_puts)(some_string);
* \endcode
* // To be used when invoking inside other PGM_FUNC functions:
* PGM_FUNC(lcd_puts)(some_string);
* \endcode
+ *
+ * \{
*/
#ifdef _PROGMEM
#define PGM_READ_CHAR(s) pgm_read_char(s)
*/
#ifdef _PROGMEM
#define PGM_READ_CHAR(s) pgm_read_char(s)
- #define PGM_FUNC(x) x ## _P
+ #define PGM_FUNC(x) PFUNC(x)
+ #define PGM_STR(x) PSTR(x)
#define PGM_ATTR PROGMEM
#else
#define PGM_READ_CHAR(s) (*(s))
#define PGM_FUNC(x) x
#define PGM_ATTR PROGMEM
#else
#define PGM_READ_CHAR(s) (*(s))
#define PGM_FUNC(x) x
+ #define PGM_STR(x) x
#define PGM_ATTR /* nothing */
#endif
#define PGM_ATTR /* nothing */
#endif
+/* \} */
#endif /* MWARE_PGM_H */
#endif /* MWARE_PGM_H */