教学视频中讲解了这个函数:
static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
if(IRQn < 0) {
SCB->SHP[((uint32_t)(IRQn) & 0xF)-4] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for Cortex-M3 System Interrupts */
else {
NVIC->IP[(uint32_t)(IRQn)] = ((priority << (8 - __NVIC_PRIO_BITS)) & 0xff); } /* set Priority for device specific Interrupts */
}
对于(priority << (8 - __NVIC_PRIO_BITS))这个我是明白了,但不明白为什么后面要& 0xff,任何二进制数与0xff相与不是不变吗?那干嘛要多此一举? |