Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Hal_Atomic_Start() and Hal_Atomic_Stop(), but with error "undefined reference to `hal_atomic_start'"

hi, I am trying to use Hal_Atomic_Start() and Hal_Atomic_Stop() to imply an atomic block, in order to avoid interrupt from system when execute the atomic block, source code like below:
#include "hal_atomic.h"
atomic_t atomic = 0;

hal_atomic_start(&atomic);
setPinOutput(pin);
writePinLow(pin);
hal_atomic_end(&atomic);
but when I compile it, I got belwo error:
| c:/msys64/mingw64/bin/../lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/bin/ld.exe: .build/example/matrix.o: in function `setPinOutput_writeLow':
| D:\Projects\example/matrix.c:83: undefined reference to `hal_atomic_start'
| c:/msys64/mingw64/bin/../lib/gcc/arm-none-eabi/10.1.0/../../../../arm-none-eabi/bin/ld.exe: D:\Projects\example/matrix.c:85: undefined reference to `hal_atomic_end'
I check whole SDK, do not find implimentation of Hal_Atomic_Start() and Hal_Atomic_Stop().
Question is that why I got the above error? how to imply Atomic block in NRF5?
Related