From 7bac19c9a49478582b8756c15928cd7183a34fb8 Mon Sep 17 00:00:00 2001 From: zwsd Date: Mon, 1 Aug 2022 17:06:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0motor=5Fdrive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/CMakeLists.txt | 1 + main/motor_drive.c | 15 +++++++++++++++ main/motor_drive.h | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 main/motor_drive.c create mode 100644 main/motor_drive.h diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index c3cbdfe..8c6393c 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,6 +1,7 @@ idf_component_register(SRCS # "ble_spp_server_demo.c" "main.c" + "motor_drive.c" INCLUDE_DIRS # "../dep/" ".") diff --git a/main/motor_drive.c b/main/motor_drive.c new file mode 100644 index 0000000..93e69c0 --- /dev/null +++ b/main/motor_drive.c @@ -0,0 +1,15 @@ +#include "motor_drive.h" + +void motor_init(motor_t* motor) { return; } +void motor_set_zero_point() { return; } +/** + * @brief 返回当前电机所在位置0->360 + * + * @return uint32_t + */ +uint32_t motor_get_position_degree() { return 0; } +/** + * @brief 电机转到多少度 + */ +void motor_run_to_postion(int potion) { return; } +void motor_reg_event_cb(motor_on_event_t onevent) { return; } diff --git a/main/motor_drive.h b/main/motor_drive.h new file mode 100644 index 0000000..55656fd --- /dev/null +++ b/main/motor_drive.h @@ -0,0 +1,25 @@ +#pragma once +#include + +typedef struct { + int mark; +// int uartNum; +} motor_t; +typedef enum { + kRunToPosition, +} motor_event_t; +typedef void (*motor_on_event_t)(motor_event_t event); + +void motor_init(motor_t* motor); +void motor_set_zero_point(); +/** + * @brief 返回当前电机所在位置0->360 + * + * @return uint32_t + */ +uint32_t motor_get_position_degree(); +/** + * @brief 电机转到多少度 + */ +void motor_run_to_postion(int potion); +void motor_reg_event_cb(motor_on_event_t onevent);