2021-11-04 09:06 AM
Probably elementary stuff, but am brand new to ARM and STM32. I'm using a USB stack libusb_stm32 for learning. In this stack, when data arrives from the host PC, a callback in the USB ISR runs a function of mine to put the data into my queue. In this function of mine I have disabled interrupts, but I do NOT think I need to. Is this a correct assumption?
void Enqueue_Callback(uint8_t bytefromhost)
{
uint32_t old_primask; // VECTACTIVE is 0x24
old_primask = __get_PRIMASK(); // old primask was 0x0000 0000
__disable_irq(); // primask becomes 0x0000 0001
myenqueue(bytefromhost); // I have shared vars in here (counter, etc).
__set_PRIMASK( old_primask );
}
In my main code, I dequeue that data and I assume I need to disable interrupts there.
bool Dequeue(uint8_t *ch_ptr)
{
uint32_t old_primask; // VECTACTIVE is 0x00
old_primask = __get_PRIMASK(); // old primask is 0x0000 0000
__disable_irq(); // becomes 0x0000 0001
if( thereisdata() ) // <pseudocode>
{
mydequeue(ch_ptr); // I have shared vars in here (count, etc).
__set_PRIMASK( old_primask );
return 0;
}
__set_PRIMASK( old_primask );
return 1;
}
I am used to simple 8-bit architecture where there is a single IRQ mask bit and IRQs are automatically (and visibly) masked when an ISR runs. I don't "get" the primask thing, especially in light of what I see here.
2021-11-08 10:33 AM
This question was seen and answered over here:
https://community.arm.com/support-forums/f/keil-forum/51761/isrs-flags-and-enables-question-stm32