各位大大安安,我在BSP中CAN范例遇到CAN bus中断进到bus-off状态问题,导至message无法传送,想问除了重新上电复位之外,如何初始化让CAN bus自动恢复?- void CAN0_IRQHandler(void)
- {
- uint32_t u8IIDRstatus;
- u8IIDRstatus = CAN0->IIDR;
- if(u8IIDRstatus == 0x00008000) { /* Check Status Interrupt Flag (Error status Int and Status change Int) */
- /**************************/
- /* Status Change interrupt*/
- /**************************/
- if(CAN0->STATUS & CAN_STATUS_RXOK_Msk) {
- CAN0->STATUS &= ~CAN_STATUS_RXOK_Msk; /* Clear RxOK status*/
- printf("RxOK INT\n") ;
- }
- if(CAN0->STATUS & CAN_STATUS_TXOK_Msk) {
- CAN0->STATUS &= ~CAN_STATUS_TXOK_Msk; /* Clear TxOK status*/
- printf("TxOK INT\n") ;
- }
- /**************************/
- /* Error Status interrupt */
- /**************************/
- if(CAN0->STATUS & CAN_STATUS_EWARN_Msk) {
- printf("EWARN INT\n") ;
- }
- if(CAN0->STATUS & CAN_STATUS_BOFF_Msk) {
- printf("BOFF INT\n") ;
- }
- } else if(u8IIDRstatus != 0) {
- printf("=> Interrupt Pointer = %d\n", CAN0->IIDR - 1);
- CAN_MsgInterrupt(CAN0, u8IIDRstatus);
- CAN_CLR_INT_PENDING_BIT(CAN0, ((CAN0->IIDR) - 1)); /* Clear Interrupt Pending */
- } else if(CAN0->WU_STATUS == 1) {
- printf("Wake up\n");
- CAN0->WU_STATUS = 0; /* Write '0' to clear */
- }
- }
复制代码
|