加入C板样例的bsp_can和CAN_receive函数库

This commit is contained in:
2026-07-14 19:57:46 +08:00
parent c4e1ed7a3d
commit cbef3e6fc4
18 changed files with 13010 additions and 37 deletions

24
Core/Src/bsp_can.c Normal file
View 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);
}