加入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

92
Core/Inc/CAN_receive.h Normal file
View File

@@ -0,0 +1,92 @@
/**
****************************(C) COPYRIGHT 2019 DJI****************************
* @file can_receive.c/h
* @brief there is CAN interrupt function to receive motor data,
* and CAN send function to send motor current to control motor.
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN<41>жϽ<D0B6><CFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CAN<41><4E><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>.
* @note
* @history
* Version Date Author Modification
* V1.0.0 Dec-26-2018 RM 1. done
*
@verbatim
==============================================================================
==============================================================================
@endverbatim
****************************(C) COPYRIGHT 2019 DJI****************************
*/
#ifndef CAN_RECEIVE_H
#define CAN_RECEIVE_H
#include "main.h"
#define CHASSIS_CAN hcan1
/* CAN send and receive ID */
typedef enum
{
CAN_CHASSIS_ALL_ID = 0x200,
CAN_3508_M1_ID = 0x201,
CAN_3508_M2_ID = 0x202,
CAN_3508_M3_ID = 0x203,
CAN_3508_M4_ID = 0x204,
} can_msg_id_e;
//rm motor data
typedef struct
{
uint16_t ecd;
int16_t speed_rpm;
int16_t given_current;
uint8_t temperate;
int16_t last_ecd;
} motor_measure_t;
/**
* @brief send CAN packet of ID 0x700, it will set chassis motor 3508 to quick ID setting
* @param[in] none
* @retval none
*/
/**
* @brief <20><><EFBFBD><EFBFBD>IDΪ0x700<30><30>CAN<41><4E>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
* @param[in] none
* @retval none
*/
extern void CAN_cmd_chassis_reset_ID(void);
/**
* @brief send control current of motor (0x201, 0x202, 0x203, 0x204)
* @param[in] motor1: (0x201) 3508 motor control current, range [-16384,16384]
* @param[in] motor2: (0x202) 3508 motor control current, range [-16384,16384]
* @param[in] motor3: (0x203) 3508 motor control current, range [-16384,16384]
* @param[in] motor4: (0x204) 3508 motor control current, range [-16384,16384]
* @retval none
*/
/**
* @brief <20><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>(0x201,0x202,0x203,0x204)
* @param[in] motor1: (0x201) 3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>, <20><>Χ [-16384,16384]
* @param[in] motor2: (0x202) 3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>, <20><>Χ [-16384,16384]
* @param[in] motor3: (0x203) 3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>, <20><>Χ [-16384,16384]
* @param[in] motor4: (0x204) 3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>, <20><>Χ [-16384,16384]
* @retval none
*/
extern void CAN_cmd_chassis(int16_t motor1, int16_t motor2, int16_t motor3, int16_t motor4);
/**
* @brief return the chassis 3508 motor data point
* @param[in] i: motor number,range [0,3]
* @retval motor data point
*/
/**
* @brief <20><><EFBFBD>ص<EFBFBD><D8B5>̵<EFBFBD><CCB5> 3508<30><38><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
* @param[in] i: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>Χ[0,3]
* @retval <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
*/
extern const motor_measure_t *get_chassis_motor_measure_point(uint8_t i);
#endif

View File

@@ -51,7 +51,6 @@
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
#include <stdint.h>
extern uint32_t SystemCoreClock;
void xPortSysTickHandler(void);
#endif
#ifndef CMSIS_device_header
#define CMSIS_device_header "stm32f4xx.h"
@@ -162,7 +161,7 @@ standard names. */
/* IMPORTANT: After 10.3.1 update, Systick_Handler comes from NVIC (if SYS timebase = systick), otherwise from cmsis_os2.c */
#define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 1
#define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 0
/* USER CODE BEGIN Defines */
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */

8
Core/Inc/bsp_can.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef BSP_CAN_H
#define BSP_CAN_H
#include "main.h"
extern void can_filter_init(void);
#endif

View File

@@ -63,7 +63,7 @@
/* #define HAL_SD_MODULE_ENABLED */
/* #define HAL_MMC_MODULE_ENABLED */
/* #define HAL_SPI_MODULE_ENABLED */
/* #define HAL_TIM_MODULE_ENABLED */
#define HAL_TIM_MODULE_ENABLED
/* #define HAL_UART_MODULE_ENABLED */
/* #define HAL_USART_MODULE_ENABLED */
/* #define HAL_IRDA_MODULE_ENABLED */

View File

@@ -52,7 +52,7 @@ void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void DebugMon_Handler(void);
void SysTick_Handler(void);
void TIM6_DAC_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */