|
一段大神级的单片机代码!原来单片机还可以这么玩!碉堡了!!
[复制链接]
#ifndef UTILS_PROGMEM_H
#define UTILS_PROGMEM_H
/**
* \defgroup group_xmega_utils_progmem Program memory
*
* \ingroup group_xmega_utils
*
* \{
*/
/*! \name Program memory
*
* Macros for locating and accessing data in program memory.
*
* @{
*/
#if defined(__GNUC__) || defined(__DOXYGEN__)
# include
# define PROGMEM_LOCATION(type, name, loc) \
type name __attribute__((section (#loc)))
# define PROGMEM_DECLARE(type, name) const type name __attribute__((__progmem__))
# define PROGMEM_STRING(x) PSTR(x)
# define PROGMEM_STRING_T PGM_P
# define PROGMEM_T const
# define PROGMEM_PTR_T const *
# define PROGMEM_BYTE_ARRAY_T uint8_t*
# define PROGMEM_WORD_ARRAY_T uint16_t*
# define PROGMEM_READ_BYTE(x) pgm_read_byte(x)
# define PROGMEM_READ_WORD(x) pgm_read_word(x)
#elif defined(__ICCAVR__)
# include
# ifndef __HAS_ELPM__
# define _MEMATTR_ASF __flash
# else /* __HAS_ELPM__ */
# define _MEMATTR_ASF __hugeflash
# endif /* __HAS_ELPM__ */
# define PROGMEM_LOCATION(type, name, loc) const _MEMATTR_ASF type name @ loc
# define PROGMEM_DECLARE(type, name) _MEMATTR_ASF type name
# define PROGMEM_STRING(x) ((_MEMATTR_ASF const char *)(x))
# define PROGMEM_STRING_T char const _MEMATTR_ASF *
# define PROGMEM_T const _MEMATTR_ASF
# define PROGMEM_PTR_T const _MEMATTR_ASF *
# define PROGMEM_BYTE_ARRAY_T uint8_t const _MEMATTR_ASF *
# define PROGMEM_WORD_ARRAY_T uint16_t const _MEMATTR_ASF *
# define PROGMEM_READ_BYTE(x) *(x)
# define PROGMEM_READ_WORD(x) *(x)
#endif
//! @}
/**
* \}
*/
#endif /* UTILS_PROGMEM_H */
|
|