Bit-band - via a linker.
Can anyone come in handy ...
Code for linker GCC.xxx_sram/flash.ldMEMORY
{
ROM (rx) : ORIGIN = 0x08000000, LENGTH = __
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = __
BITRAM (rw) : ORIGIN = 0x22000000, LENGTH = 2048K // - LENGTH(RAM) * 128
}
----
/* SRAM base address in the bit-band region*/
_sramflag = .;
sflagadres = ((_sramflag - ORIGIN(RAM)) << 5 );
.flag (NOLOAD):
{
. += sflagadres;
. = ALIGN(4);
_sflag = .;
KEEP(*(.flag))
. = ALIGN(128);
_eflag = .;
} > BITRAM
_eramflag = ((_eflag - _sflag) >> 5);
/* SRAM base address in the bit-band region*/
.bss (NOLOAD):
{
__bss_start__ = .;
. += _eramflag;
*(.bss*)
*(COMMON)
__bss_end__ = .;
} > RAM
&sharpdefine _FLAG __attribute__ ((section(''.flag'')))
After that, any global flag automatically becomes atomic. In addition - reduced memory consumption. But the main thing - the simplicity of the ad.
volatile uint32_t tmp_name_flag _FLAG;
Translated from Russian by Google,????? ????????? ????? ??????????. #bit-band #bitband