STM32Cube的CAN滤波如何设置

2019-03-23 17:57发布

STM32Cube的CAN滤波如何设置,需要只让两个需要的ID进去中断,其他的全部过滤。请问如何设置?
/*##-2- Configure the CAN1 Filter ###########################################*/
        sFilterConfig.FilterNumber = 0;
        sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
        sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
        sFilterConfig.FilterIdHigh = AllowID_F507<<5;
        sFilterConfig.FilterIdLow = 0|CAN_ID_STD;;
        sFilterConfig.FilterMaskIdHigh = 0xFFFF;
        sFilterConfig.FilterMaskIdLow = 0xFFFF;
        sFilterConfig.FilterFIFOAssignment = CAN_FIFO0;
        sFilterConfig.FilterActivation = ENABLE;
        sFilterConfig.BankNumber = 0;
        HAL_CAN_ConfigFilter(&hcan, &sFilterConfig);

        /*##-2- Configure the CAN1 Filter ###########################################*/
        sFilterConfig.FilterNumber = 1;
        sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
        sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
        sFilterConfig.FilterIdHigh = AllowID2_F507<<5;
        sFilterConfig.FilterIdLow = 0|CAN_ID_STD;;
        sFilterConfig.FilterMaskIdHigh = 0xFFFF;
        sFilterConfig.FilterMaskIdLow = 0xFFFF;
        sFilterConfig.FilterFIFOAssignment = CAN_FIFO0;
        sFilterConfig.FilterActivation = ENABLE;
        sFilterConfig.BankNumber = 0;
        HAL_CAN_ConfigFilter(&hcan, &sFilterConfig);

        HAL_CAN_Receive_IT(&hcan,CAN_FIFO0);

芯片是用STM32F103VET的。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。