STM32G0 Concurrency Question
I have some data that is accessed from a normal context and also from an IRQ. I am disabling the interrupt to prevent interrupted access. So no concerns there. However, what about forcing both the normal context and the interrupt context to have the same data? Do I need to declare every accessed variable as std::atomic? Or can I wrap the section of code in something else that ensures every variable inside of it gets flushed or something once that function is exited?
example code
void PRL_Receive::CleanStart()
{
uint32_t ien;
ien = NVIC_GetEnableIRQ(UCPD1_2_IRQn);
NVIC_DisableIRQ(UCPD1_2_IRQn);
state = PRL_Rx_Wait_for_PHY_Message;
entry = true;
bMsgReceivedFlag = false;
isSoftReset = false;
MessageID = 0U;
bMsgIDRecvd = false;
isCRCSent = false;
u8txResult=0;
bResultValid=false;
prlRxRecvBytes = 0U;
if(ien){
NVIC_EnableIRQ(UCPD1_2_IRQn);
}
}
after this is called by the IRQ I want the normal context to see all the updated values the next time it accesses any of these. Or if its called by the normal context, the next time the IRQ access them I want it to have the latest value as well. Apparently, in c/c++ volatile is not enough.
