avr-libc
2.0.0
Standard C library for AVR-GCC
|
AVR Libc Home Page |
![]() |
AVR Libc Development Pages |
|||
Main Page |
User Manual |
Library Reference |
FAQ |
Example Projects |
Macros | |
#define | PROGMEM __ATTR_PROGMEM__ |
#define | PGM_P const char * |
#define | PGM_VOID_P const void * |
#define | PSTR(s) ((const PROGMEM char *)(s)) |
#define | pgm_read_byte_near(address_short) __LPM((uint16_t)(address_short)) |
#define | pgm_read_word_near(address_short) __LPM_word((uint16_t)(address_short)) |
#define | pgm_read_dword_near(address_short) __LPM_dword((uint16_t)(address_short)) |
#define | pgm_read_float_near(address_short) __LPM_float((uint16_t)(address_short)) |
#define | pgm_read_ptr_near(address_short) (void*)__LPM_word((uint16_t)(address_short)) |
#define | pgm_read_byte_far(address_long) __ELPM((uint32_t)(address_long)) |
#define | pgm_read_word_far(address_long) __ELPM_word((uint32_t)(address_long)) |
#define | pgm_read_dword_far(address_long) __ELPM_dword((uint32_t)(address_long)) |
#define | pgm_read_float_far(address_long) __ELPM_float((uint32_t)(address_long)) |
#define | pgm_read_ptr_far(address_long) (void*)__ELPM_word((uint32_t)(address_long)) |
#define | pgm_read_byte(address_short) pgm_read_byte_near(address_short) |
#define | pgm_read_word(address_short) pgm_read_word_near(address_short) |
#define | pgm_read_dword(address_short) pgm_read_dword_near(address_short) |
#define | pgm_read_float(address_short) pgm_read_float_near(address_short) |
#define | pgm_read_ptr(address_short) pgm_read_ptr_near(address_short) |
#define | pgm_get_far_address(var) |
The functions in this module provide interfaces for a program to access data stored in program space (flash memory) of the device. In order to use these functions, the target device must support either the LPM
or ELPM
instructions.
_P
require their arguments to be in the lower 64 KB of the flash ROM, as they do not use ELPM instructions. This is normally not a big concern as the linker setup arranges any program space constants declared using the macros from this header file so they are placed right after the interrupt vectors, and in front of any executable code. However, it can become a problem if there are too many of these constants, or for bootloaders on devices with more than 64 KB of ROM. All these functions will not work in that situation.NVM.CMD
or NVM_CMD
) is set to 0x00 (NOP) before using any of these functions. #define pgm_get_far_address | ( | var | ) |
This macro facilitates the obtention of a 32 bit "far" pointer (only 24 bits used) to data even passed the 64KB limit for the 16 bit ordinary pointer. It is similar to the '&' operator, with some limitations.
Comments:
#define PGM_P const char * |
Used to declare a variable that is a pointer to a string in program space.
#define pgm_read_byte | ( | address_short | ) | pgm_read_byte_near(address_short) |
Read a byte from the program space with a 16-bit (near) address.
#define pgm_read_byte_far | ( | address_long | ) | __ELPM((uint32_t)(address_long)) |
Read a byte from the program space with a 32-bit (far) address.
#define pgm_read_byte_near | ( | address_short | ) | __LPM((uint16_t)(address_short)) |
Read a byte from the program space with a 16-bit (near) address.
#define pgm_read_dword | ( | address_short | ) | pgm_read_dword_near(address_short) |
Read a double word from the program space with a 16-bit (near) address.
#define pgm_read_dword_far | ( | address_long | ) | __ELPM_dword((uint32_t)(address_long)) |
Read a double word from the program space with a 32-bit (far) address.
#define pgm_read_dword_near | ( | address_short | ) | __LPM_dword((uint16_t)(address_short)) |
Read a double word from the program space with a 16-bit (near) address.
#define pgm_read_float | ( | address_short | ) | pgm_read_float_near(address_short) |
Read a float from the program space with a 16-bit (near) address.
#define pgm_read_float_far | ( | address_long | ) | __ELPM_float((uint32_t)(address_long)) |
Read a float from the program space with a 32-bit (far) address.
#define pgm_read_float_near | ( | address_short | ) | __LPM_float((uint16_t)(address_short)) |
Read a float from the program space with a 16-bit (near) address.
#define pgm_read_ptr | ( | address_short | ) | pgm_read_ptr_near(address_short) |
Read a pointer from the program space with a 16-bit (near) address.
#define pgm_read_ptr_far | ( | address_long | ) | (void*)__ELPM_word((uint32_t)(address_long)) |
Read a pointer from the program space with a 32-bit (far) address.
#define pgm_read_ptr_near | ( | address_short | ) | (void*)__LPM_word((uint16_t)(address_short)) |
Read a pointer from the program space with a 16-bit (near) address.
#define pgm_read_word | ( | address_short | ) | pgm_read_word_near(address_short) |
Read a word from the program space with a 16-bit (near) address.
#define pgm_read_word_far | ( | address_long | ) | __ELPM_word((uint32_t)(address_long)) |
Read a word from the program space with a 32-bit (far) address.
#define pgm_read_word_near | ( | address_short | ) | __LPM_word((uint16_t)(address_short)) |
Read a word from the program space with a 16-bit (near) address.
#define PGM_VOID_P const void * |
Used to declare a generic pointer to an object in program space.
#define PROGMEM __ATTR_PROGMEM__ |
Attribute to use in order to declare an object being located in flash ROM.
#define PSTR | ( | s | ) | ((const PROGMEM char *)(s)) |
Used to declare a static pointer to a string in program space.