Bit mapped memory operation may be appreciated that the LED programming file descriptor, which corresponds to the function mmap
The formula is:
bit register #define band alias = 0x42000000 + (address register -0x40000000) . 8 4+ pin number . 4
embodiment:
#define Peout (X) (uint32_t ) (0x42000000 + ((uint32_t) & GPIOE-> the ODR-0x40000000) . 8 4+ (X) . 4)
GPIOE-> Get the ODR port pin level
The volatile keyword is to allow the compiler not optimize the variable refers is to prevent compiler optimization appears excessive, leading to failure of code to run
Applications:
1) multi-threaded programming shared global variable, the global variable modified to add e volatile, do not let the compiler to optimize the variable.
2) bare metal programming, a function of time and interrupt service functions in a shared global variable, the global variable modified to add e volatile, do not let the compiler to optimize the variable.
3) ARM defined register, the register is a pointer to an address that was modified to add e volatile, do not let the compiler to optimize the variable.