Files
P4-USB-transfer/main/MOTOR/motor.h
T
zhengxinandCursor 851e347cf5 初始提交卡包 USB 工程
纳入固件源码、屏幕组件、nand_xfer 工具和文档。忽略本机构建产物、sdkconfig,以及含本机路径的依赖锁。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-13 21:54:50 +08:00

104 lines
3.0 KiB
C

// #ifndef _MOTOR_H_
// #define _MOTOR_H_
// #ifdef __cplusplus
// extern "C" {
// #endif
// #include <math.h>
// #include <stdio.h>
// #include "freertos/FreeRTOS.h"
// #include "freertos/task.h"
// #include "freertos/queue.h"
// #include "driver/ledc.h"
// #include "driver/gpio.h"
// #include "esp_log.h"
// #include "esp_timer.h"
// #include <string.h>
// #include "nvs.h"
// #include "nvs_flash.h"
// #include <stdint.h>
// void motor_init(void);
// void motor_set_speed(int32_t speed);
// void motor_set_angle(float angle); //外部接口 -60 主驾 +60副驾
// void motor_set_motor_speed(uint32_t speed); //调整目标转速
// static void set_flag(bool state);
// bool get_flag(void);
// // 用于标识角度数据的键名
// #define STORAGE_NAMESPACE "motor_data"
// #define ANGLE_KEY "current_angle"
// // DRV8837引脚定义
// #define MOTOR_AIN1_GPIO GPIO_NUM_1
// #define MOTOR_AIN2_GPIO GPIO_NUM_2
// // #define MOTOR_AIN1_GPIO GPIO_NUM_9
// // #define MOTOR_AIN2_GPIO GPIO_NUM_46
// //#define MOTOR_BIN1_GPIO GPIO_NUM_14 // 可选,用于第二个电机
// //#define MOTOR_BIN2_GPIO GPIO_NUM_15 // 可选,用于第二个电机
// // PWM配置
// #define LEDC_TIMER LEDC_TIMER_0
// #define LEDC_MODE LEDC_LOW_SPEED_MODE
// #define LEDC_CHANNEL_AIN1 LEDC_CHANNEL_0
// #define LEDC_CHANNEL_AIN2 LEDC_CHANNEL_1
// #define LEDC_DUTY_RES LEDC_TIMER_10_BIT // 10位分辨率(0-1023)
// #define LEDC_FREQ 1000 // 1kHz PWM频率
// // 电机参数
// #define MOTOR_MAX_PWM 100
// #define MOTOR_90_SPEED 90
// #define MOTOR_90_PWM 42
// #define MOTOR_60_SPEED 60
// #define MOTOR_60_PWM 53 //30 50
// // #define MOTOR_30_SPEED 30
// // #define MOTOR_50_SPEED 50
// // #define MOTOR_50_PWM 44
// // #define MOTOR_45_SPEED 45
// // #define MOTOR_45_PWM 34
// // #define MOTOR_40_SPEED 40
// // #define MOTOR_40_PWM 28
// // #define MOTOR_36_SPEED 36
// // #define MOTOR_36_PWM 25
// // #define MOTOR_30_SPEED 30
// // #define MOTOR_30_PWM 21
// #define ANGLE_LIMIT 3
// extern TaskHandle_t angle_control_handle;
// typedef enum
// {
// motor_stop = 0 ,
// motor_turn_to_right,
// motor_turn_to_left,
// }MOTOR_STATE;
// // typedef enum
// // {
// // position_zero = 0,
// // position_right_15,//右边偏移15度
// // position_right_30,//右边偏移30度
// // position_right_60,//右边偏移60度
// // position_left_15,//左边偏移15度
// // position_left_30,//左边偏移30度
// // position_left_60,//左边偏移60度
// // position_left_180,//左边偏移180度
// // position_left_120,//左边偏移180度
// // position_left_240,//左边偏移180度
// // }MOTOR_POSITION;
// void motor_turn_aroud(uint8_t cmd);
// /** 请求电机立即停止(用于哨兵模式等可中断场景) */
// void motor_request_stop(void);
// #ifdef __cplusplus
// }
// #endif
// #endif /* TEST_H_ */