-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Medium
-
SITSW-7512
-
11.00.00
-
11.02.00
-
The HwiP_inISR API description in the MCU+SDK documentation tells the API will only be checking for ISR.
If the execution is in ISR, the API should return 1, otherwise it should return 0.
/**
- \brief Check if the caller of this function is inside a ISR or not
- In some cases, like with freertos, some functions cannot be called from within the OS
- ISR handler, this API allows the user and some driver porting layer (DPL) APIs
- to check and call the appropiate ISR safe API when in ISR handler mode.
- To get the exact CPU mode of the executing CPU, use the low level CPU specific system calls/registers.
- \note In case of ARM R5F, this only checks if caller is inside IRQ or not.
- This means when HwiP_inISR returns 1, CPU is in IRQ mode and when HwiP_inISR return 0, CPU could be in system mode or FIQ or abort mode and so on *
- \return 0 not in interrupt mode, 1 in interrupt mode
*/
uint32_t HwiP_inISR(void);
But the implementation of the API doesn't check for IRQ condition, but only checks that the execution currently is not in System Mode.
It will return 0 only when the execution is in System mode and will return 1 for IRQ, FIQ, User Mode, Abort which doesn't align with the description.
uint32_t HWI_SECTION HwiP_inISR(void)
{
uint32_t mode = (HwiP_getCPSR() & 0x1FU);
uint32_t result =0;
if(mode != ARMV7R_SYSTEM_MODE)
return result;
}
Update the comments in the code