stm32库升级到3.3.0 后原来的函数NVIC_SystemHandlerPriorityConfig没有了。
这个函数是用来定义Cortex-M3 中断的,在V3.3.0中没找到与之相对应的函数。
请高手指点一二,谢谢
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); // 2 bit for pre-emption priority, 2 bits for subpriority
NVIC_SetPriority (SysTick_IRQn, 0); // the highest priority */
谢谢,高人指点。我找到了他的函数原型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 */
}
使用ST的库配置太麻烦了,浪费不少CPU时间和代码空间。
比如配置IO,你一个个库函数的调用,代码写得常常的一串。而直接写寄存器只要:
RCC->APB2ENR &= ~GPIO_APB2_BUS;
RCC->APB2ENR |= WAKEUP_GPIO_APB2;
#if (__WAKEUP_AFIO_CEN & 0x01) /* AFIO 配置 */
#if (__WAKEUP_AFIO_CEN & 0x02)
AFIO->EVCR = __WAKEUP_AFIO_EVCR;
#endif
#if (__WAKEUP_AFIO_CEN & 0x04)
AFIO->MAPR = __WAKEUP_AFIO_MAPR;
#endif
#if (__WAKEUP_AFIO_CEN & 0x08)
AFIO->EXTICR[0] = __WAKEUP_AFIO_EXTICR1;
AFIO->EXTICR[1] = __WAKEUP_AFIO_EXTICR2;
AFIO->EXTICR[2] = __WAKEUP_AFIO_EXTICR3;
AFIO->EXTICR[3] = __WAKEUP_AFIO_EXTICR4;
#endif
#endif
#if __WAKEUP_GPIOA_CEN
GPIOA->ODR = __WAKEUP_GPIOA_DR;
GPIOA->CRL = __WAKEUP_GPIOA_CRL;
GPIOA->CRH = __WAKEUP_GPIOA_CRH;
#endif
#if __WAKEUP_GPIOB_CEN
GPIOB->ODR = __WAKEUP_GPIOB_DR;
GPIOB->CRL = __WAKEUP_GPIOB_CRL;
GPIOB->CRH = __WAKEUP_GPIOB_CRH;
#endif
#if __WAKEUP_GPIOC_CEN
GPIOC->ODR = __WAKEUP_GPIOC_DR;
GPIOC->CRL = __WAKEUP_GPIOC_CRL;
GPIOC->CRH = __WAKEUP_GPIOC_CRH;
#endif
#if __WAKEUP_GPIOD_CEN
GPIOD->ODR = __WAKEUP_GPIOD_DR;
GPIOD->CRL = __WAKEUP_GPIOD_CRL;
GPIOD->CRH = __WAKEUP_GPIOD_CRH;
#endif
#if __WAKEUP_GPIOE_CEN
GPIOE->ODR = __WAKEUP_GPIOE_DR;
GPIOE->CRL = __WAKEUP_GPIOE_CRL;
GPIOE->CRH = __WAKEUP_GPIOE_CRH;
#endif
直接找寄存器配置,程序的可读性会很差,只有自己看得懂了,时间长了,可能自己也忘了