First of all, we have to know how the critical part are organized.
the dependency:
goes into it→
the usage is like:
there is a trait to define the work:
and what we need to do to adapt to our boards is implementing by using this macro :
maybe we need to know this important macro
it’s very easy to understand, just detach the bound with the same _critical_section_1_0_acquire function. And offer a more tight interface to use.
and it’s easy to find that cortex-m has already given such a implementation:
—in
and we can dig deeper to see what interrupt::disable() do:
—in
file src/interrupt.rs : 35
it use call_asm to do:
we should know the meaning of
cpsid i
and the followed optionsyou should aware that this type of critical section mask all the interrupt including systick, maybe we can change it to use
basepri
register in the later, but just keep it now. It’s already enough in most of time.And you may wonder what the return type—RawRetoreState
is
and the critical-section wrap it with a opaque “restore state”