添加文件1和文件2

This commit is contained in:
2025-11-27 20:08:38 +08:00
parent 5d4099938c
commit edc427c423
1675 changed files with 1068907 additions and 2830 deletions

View File

@@ -0,0 +1,33 @@
#ifndef __CToC_H
#define __CToC_H
#include "main.h"
#include "M3508.h"
#define CToC_MasterID1 0x019//ID1
#define CToC_SlaveID1 0x149//ID1
#define CToC_SlaveID2 0x189//ID2
//<2F>жϻص<CFBB><D8B5><EFBFBD><EFBFBD><EFBFBD>
//<2F>жϽ<D0B6><CFBD>ܶ<EFBFBD><DCB6><EFBFBD><EFBFBD><EFBFBD>ID-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>
//motor_chassis<69><73>motor_measure_t <20><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD>װ<EFBFBD>е<EFBFBD><D0B5><EFBFBD>ת<EFBFBD>ӽǶȣ<C7B6><C8A3><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>ת<EFBFBD>٣<EFBFBD><D9A3><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><E5BAAF>
#define get_motor_measure(ptr, data) \
{ \
(ptr)->last_ecd = (ptr)->ecd; \
(ptr)->ecd = (uint16_t)((data)[0] << 8 | (data)[1]); \
(ptr)->speed_rpm = (uint16_t)((data)[2] << 8 | (data)[3]); \
(ptr)->given_current = (uint16_t)((data)[4] << 8 | (data)[5]); \
(ptr)->temperate = (data)[6]; \
}
extern uint8_t CToC_SlaveSendRefereeSystemData(void);
extern void can_filter_init(void);
extern void CToC_CANDataProcess(uint32_t ID,uint8_t *Data);
extern void Update_Motor_Measure(uint8_t motor_id, motor_measure_t* measure);
extern void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan);
#endif

View File

@@ -0,0 +1,42 @@
#ifndef __M3508_H
#define __M3508_H
#include "main.h"
#include "PID.h"
// <20><><EFBFBD>̲<EFBFBD><CCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʻ<EFBFBD>е<EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define WHEEL_RADIUS 0.075f// <20><><EFBFBD>Ӱ뾶 (<28><>)
#define WHEELBASE_WIDTH 0.21f // <20>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD>/2 (<28><>)
#define WHEELBASE_LENGTH 0.17f // <20>־೤<D6BE><E0B3A4>/2 (<28><>)
typedef struct
{
uint16_t ecd;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ -16384--+16384
int16_t speed_rpm;//ת<><D7AA> תÿ<D7AA><C3BF><EFBFBD><EFBFBD>
int16_t given_current;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
uint8_t temperate;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int16_t last_ecd;//<2F>ϴα<CFB4><CEB1><EFBFBD><EFBFBD><EFBFBD>ֵ
} motor_measure_t;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<C6BD><E1B9B9>
typedef struct {
motor_measure_t measure; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ٶȵ<D9B6>λ<EFBFBD><CEBB>RPM<50><4D>
PID_Controller_t speed_pid; // <20>ٶȻ<D9B6>PID
float target_speed; // Ŀ<><C4BF><EFBFBD>ٶ<EFBFBD> (rad/s)
} Motor_Controller_t;
extern motor_measure_t motor_chassis[4];
extern Motor_Controller_t motor_controller[4];
extern int16_t motor_commands[4];
extern void CAN_cmd_chassis(int16_t motor1, int16_t motor2, int16_t motor3, int16_t motor4);
extern float RPM_To_RadPerSec(int16_t rpm);
extern int16_t RadPerSec_To_RPM(float rad_per_sec);
extern void Set_Motor_Target_Speed(uint8_t motor_id, float target_speed_rad_s);
extern void Motor_Speed_Control_Task(float dt);
extern void Drive_Motor(float vx, float vy, float vz);
extern float Map_Remote_to_Speed(int16_t input, float max_speed);
extern void Process_Remote_Control(void);
#endif

View File

@@ -0,0 +1,9 @@
#ifndef __RefreeSystem_H
#define __RefreeSystem_H
#include "main.h"
extern uint8_t RefereeSystem_Status;
extern uint8_t RefereeSystem_ShooterStatus;
#endif

View File

@@ -0,0 +1,39 @@
#ifndef __Remote_H
#define __Remote_H
#include "main.h"
typedef struct
{
uint16_t Remote_R_RL;
uint16_t Remote_R_UD;
uint16_t Remote_L_RL;
uint16_t Remote_L_UD;
uint8_t Remote_LS;
uint8_t Remote_RS;
int16_t Remote_Mouse_RL;
int16_t Remote_Mouse_DU;
int16_t Remote_Mouse_Wheel;
uint8_t Remote_Mouse_KeyL;
uint8_t Remote_Mouse_KeyR;
uint8_t Remote_Key_W;
uint8_t Remote_Key_S;
uint8_t Remote_Key_A;
uint8_t Remote_Key_D;
uint8_t Remote_Key_Q;
uint8_t Remote_Key_E;
uint8_t Remote_Key_Shift;
uint8_t Remote_Key_Ctrl;
uint8_t Remote_KeyPush_Ctrl;
uint8_t Remote_KeyPush_Shift;
int16_t Remote_ThumbWheel;
}Remote_Data;
extern Remote_Data Remote_RxData;
extern uint8_t Remote_Status;
extern uint8_t Remote_StartFlag;
#endif

View File

@@ -34,11 +34,14 @@ extern "C" {
extern CAN_HandleTypeDef hcan1;
extern CAN_HandleTypeDef hcan2;
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_CAN1_Init(void);
void MX_CAN2_Init(void);
/* USER CODE BEGIN Prototypes */

View File

@@ -1,52 +0,0 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file dma.h
* @brief This file contains all the function prototypes for
* the dma.c file
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __DMA_H__
#define __DMA_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* DMA memory to memory transfer handles -------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_DMA_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /* __DMA_H__ */

View File

@@ -60,33 +60,8 @@ void Error_Handler(void);
/* Private defines -----------------------------------------------------------*/
/* USER CODE BEGIN Private defines */
#define DBUS_MAX_LEN (50)
#define DBUS_BUFLEN (18)
#define DBUS_HUART huart3
typedef __packed struct
{
int16_t ch0;
int16_t ch1;
int16_t ch2;
int16_t ch3;
int16_t roll;
uint8_t sw1;
uint8_t sw2;
} rc_info_t;
#define rc_Init \
{ \
0, \
0, \
0, \
0, \
0, \
0, \
0, \
}
void uart_receive_handler(UART_HandleTypeDef *huart);
void dbus_uart_init(void);
void rc_callback_handler(rc_info_t *rc, uint8_t *buff);
/* USER CODE END Private defines */

View File

@@ -0,0 +1,22 @@
#ifndef __PID_H
#define __PID_H
#include "main.h"
typedef struct {
float kp; // ????
float ki; // ????
float kd; // ????
float integral; // ???
float prev_error; // ?????
float output; // ???
float integral_limit; // ????
float output_limit; // ????
} PID_Controller_t;
extern void PID_Init(PID_Controller_t* pid, float kp, float ki, float kd, float integral_limit, float output_limit);
extern float PID_Calculate(PID_Controller_t* pid, float error, float dt);
extern void Motor_PID_Init();
extern void PID_PositionClean(PID_Controller_t* pid);
#endif

View File

@@ -64,7 +64,7 @@
/* #define HAL_MMC_MODULE_ENABLED */
/* #define HAL_SPI_MODULE_ENABLED */
/* #define HAL_TIM_MODULE_ENABLED */
#define HAL_UART_MODULE_ENABLED
/* #define HAL_UART_MODULE_ENABLED */
/* #define HAL_USART_MODULE_ENABLED */
/* #define HAL_IRDA_MODULE_ENABLED */
/* #define HAL_SMARTCARD_MODULE_ENABLED */

View File

@@ -55,9 +55,8 @@ void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void DMA1_Stream1_IRQHandler(void);
void CAN1_RX0_IRQHandler(void);
void USART3_IRQHandler(void);
void CAN2_RX0_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */

View File

@@ -1,52 +0,0 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file usart.h
* @brief This file contains all the function prototypes for
* the usart.c file
******************************************************************************
* @attention
*
* Copyright (c) 2025 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USART_H__
#define __USART_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
extern UART_HandleTypeDef huart3;
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_USART3_UART_Init(void);
/* USER CODE BEGIN Prototypes */
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /* __USART_H__ */