I'm looking at file stm8l10x_gpio.c from the "standard peripheral library"
and there does not seem to be a function to switch individual GPIO bits atomically.
For example the following compiles with Cosmic compiler to read-modify-write sequence
void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint8_t GPIO_Pin)
GPIOx->ODR |= GPIO_Pin;
as well as this:
void GPIO_WriteBit(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, BitAction GPIO_BitVal)
if (GPIO_BitVal != RESET)
So when interrupt handler drives some GPIO pin and the main program/other ISR uses other pin in same GPIO register, locking is needed. But ST8 has special instructions for manipulating single bits.
Macros SetBit, ClrBit are defined in stm8l10x.h and neither these are atomic.
Are there any intrinsic functions for bit set/clear (Cosmic compiler if possible)?