AnsweredAssumed Answered

CubeMx STM32F4 feature request implement critical section

Question asked by adib on May 1, 2016
Hello ST team,

I like to see a critical section implementation similar to atmel avrlib ATOMIC_BLOCK implementation.
example:
ATOMIC_BLOCK(5) {
    uint8_t status get_spi_device_info();
    if(status == 0) return;
    do_some_more_spi_communication();
}
pls refer  http://www.nongnu.org/avr-libc/user-manual/group__util__atomic.html
and http://www.mikrocontroller.net/topic/312246#new

basically:
- the code should avoid blocking all interrupts
- the code must allow to use break and return
- the MCU status after the code must be the same as before the code squence
- the code should higher the baseprio based on given argument
- the code must not lower the baseprio if current cpuprio is higher than given baseprio

use cases:
- SPI device with notification signal
   main thead avoids to be interrupted by pin event handler
- I2C devices
  communication from main thread and ISR
- semaphore like operations

ST there is obviously a need for this and many people are implementing self brewed implementation.
Pls provide some proven code.

Regards, Adib.
--

Outcomes