#ifndef __SYSTEM_H #define __SYSTEM_H // Refer to all header files you need //引用所有需要用到的头文件 #include "FreeRTOSConfig.h" //FreeRTOS相关头文件 //FreeRTOS related header files #include "FreeRTOS.h" #include "stm32f4xx.h" #include "task.h" #include "queue.h" #include "timers.h" #include "semphr.h" //The associated header file for the peripheral //外设的相关头文件 #include "sys.h" #include "delay.h" #include "usart.h" #include "balance.h" #include "led.h" #include "oled.h" #include "usart.h" #include "usartx.h" #include "adc.h" #include "can.h" #include "motor.h" #include "timer.h" #include "encoder.h" #include "show.h" #include "pstwo.h" #include "key.h" #include "robot_select_init.h" #include "I2C.h" #include "MPU6050.h" // Enumeration of car types //小车型号的枚举定义 typedef enum { Mec_Car = 0, Omni_Car, Akm_Car, Diff_Car, FourWheel_Car, Tank_Car } CarMode; //Motor speed control related parameters of the structure //电机速度控制相关参数结构体 typedef struct { float Encoder; //Read the real time speed of the motor by encoder //编码器数值,读取电机实时速度 float Motor_Pwm; //Motor PWM value, control the real-time speed of the motor //电机PWM数值,控制电机实时速度 float Target; //Control the target speed of the motor //电机目标速度值,控制电机目标速度 float Velocity_KP; //Speed control PID parameters //速度控制PID参数 float Velocity_KI; //Speed control PID parameters //速度控制PID参数 }Motor_parameter; //Smoothed the speed of the three axes //平滑处理后的三轴速度 typedef struct { float VX; float VY; float VZ; }Smooth_Control; /****** external variable definition. When system.h is referenced in other C files, other C files can also use the variable defined by system.c ******/ /****** 外部变量定义,当其它c文件引用system.h时,也可以使用system.c定义的变量 ******/ extern u8 Flag_Stop; extern int Divisor_Mode; extern u8 Car_Mode; extern int Servo; extern float RC_Velocity; extern float Move_X, Move_Y, Move_Z; extern float Velocity_KP, Velocity_KI; extern Smooth_Control smooth_control; extern Motor_parameter MOTOR_A, MOTOR_B, MOTOR_C, MOTOR_D; extern float Encoder_precision; extern float Wheel_perimeter; extern float Wheel_spacing; extern float Axle_spacing; extern float Omni_turn_radiaus; extern u8 PS2_ON_Flag, APP_ON_Flag, Remote_ON_Flag, CAN_ON_Flag, Usart1_ON_Flag, Usart5_ON_Flag; extern u8 Flag_Left, Flag_Right, Flag_Direction, Turn_Flag; extern u8 PID_Send; extern float PS2_LX,PS2_LY,PS2_RX,PS2_RY,PS2_KEY; extern int Check, Checking, Checked, CheckCount, CheckPhrase1, CheckPhrase2; extern long int ErrorCode; void systemInit(void); /***Macros define***/ /***宏定义***/ //Collect IMU zero-bias samples for 2 seconds at 100 Hz before enabling control. //开机后以100Hz采集2秒IMU零偏,再允许控制小车运动 #define CONTROL_DELAY 200 //Balance_task counter needed to represent the same 2 second startup delay. #define CONTROL_STARTUP_DELAY_COUNT (2 * CONTROL_FREQUENCY) //The number of robot types to determine the value of Divisor_Mode. There are currently 6 car types //机器人型号数量,决定Divisor_Mode的值,目前有6种小车类型 #define CAR_NUMBER 6 #define RATE_1_HZ 1 #define RATE_5_HZ 5 #define RATE_10_HZ 10 #define RATE_20_HZ 20 #define RATE_25_HZ 25 #define RATE_50_HZ 50 #define RATE_100_HZ 100 #define RATE_200_HZ 200 #define RATE_250_HZ 250 #define RATE_500_HZ 500 #define RATE_1000_HZ 1000 /***Macros define***/ /***宏定义***/ //C library function related header file //C库函数的相关头文件 #include #include #include #include #include #include "stdarg.h" #endif