加入C板样例的bsp_can和CAN_receive函数库
This commit is contained in:
24
Core/Src/bsp_can.c
Normal file
24
Core/Src/bsp_can.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "bsp_can.h"
|
||||
#include "main.h"
|
||||
|
||||
|
||||
extern CAN_HandleTypeDef hcan1;
|
||||
|
||||
void can_filter_init(void)
|
||||
{
|
||||
|
||||
CAN_FilterTypeDef can_filter_st;
|
||||
can_filter_st.FilterActivation = ENABLE;
|
||||
can_filter_st.FilterMode = CAN_FILTERMODE_IDMASK;
|
||||
can_filter_st.FilterScale = CAN_FILTERSCALE_32BIT;
|
||||
can_filter_st.FilterIdHigh = 0x0000;
|
||||
can_filter_st.FilterIdLow = 0x0000;
|
||||
can_filter_st.FilterMaskIdHigh = 0x0000;
|
||||
can_filter_st.FilterMaskIdLow = 0x0000;
|
||||
can_filter_st.FilterBank = 0;
|
||||
can_filter_st.FilterFIFOAssignment = CAN_RX_FIFO0;
|
||||
HAL_CAN_ConfigFilter(&hcan1, &can_filter_st);
|
||||
HAL_CAN_Start(&hcan1);
|
||||
HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user