Hi,
it seems that a simple inline function is not compiled properly. Here is the inline function that clears register bit:
static inline void CAN_disableMailbox(uint32_t base, uint16_t mbx) { (*((volatile uint32_t *)((uintptr_t)(base + 0U + 0x0U)))) &= ~(((uint32_t) 1U) << (mbx-1U)); }
Let's assume that initial value of register being modified is 0. When the above function is implemented as "inline", the register after function is 0xFFFF0000, and when it is implemented as regular static function, the register is 0x00000000.
I am still trying to figure out from asm what is the root cause for this problem.
Is there anything you could see as being problematic for the above implementation?
It works as expected if I expand the function line as:
uintptr_t ptr = (uintptr_t) (priv->base + 0U + 0x0U); volatile uint32_t *pptr = (volatile uint32_t *) ptr; uint32_t reg = *pptr & ~(((uint32_t) 1U) << (mbx - 1U)); *pptr = reg;
However, it does not work in the abbreviated form:
*pptr &= ~(((uint32_t) 1U) << (mbx - 1U));