From a8f7e43644636a3a519d149c486d6bc21d198948 Mon Sep 17 00:00:00 2001 From: zwsd Date: Wed, 3 Aug 2022 08:50:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/CMakeLists.txt | 1 + main/ble_spp_server_demo.c | 2 +- main/main.c | 3 ++- main/motor_drive.c | 15 +++++++-------- main/port.c | 2 ++ 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index 8c6393c..669693e 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -2,6 +2,7 @@ idf_component_register(SRCS # "ble_spp_server_demo.c" "main.c" "motor_drive.c" + "port.c" INCLUDE_DIRS # "../dep/" ".") diff --git a/main/ble_spp_server_demo.c b/main/ble_spp_server_demo.c index 27b544d..6f8c752 100644 --- a/main/ble_spp_server_demo.c +++ b/main/ble_spp_server_demo.c @@ -701,7 +701,7 @@ void blerxprocess(uint8_t *rxmessage, size_t rxsize) { } void bleuart_schedule() { - if (s_module->has_rx_size != 0 && port_haspassedms(s_module->last_rx_ticket) > 1000) { + if (s_module->has_rx_size != 0 && port_haspassedms(s_module->last_rx_ticket) > 200) { s_module->receive_data_processing_flag = true; s_cb(s_module->rxbuf, s_module->has_rx_size); diff --git a/main/main.c b/main/main.c index 1a00606..062e971 100644 --- a/main/main.c +++ b/main/main.c @@ -78,6 +78,7 @@ void blerxcb(uint8_t *rxmessage, size_t rxsize) { } void motor_on_event(motor_event_t event) { + //打算使用sprintf if (event == kRunToPosition) { //组包 //上报 @@ -94,6 +95,6 @@ void app_main(void) { while (true) { bleuart_schedule(); - motor_module_schedule(); + // motor_module_schedule(); } } diff --git a/main/motor_drive.c b/main/motor_drive.c index 23829d4..68d9385 100644 --- a/main/motor_drive.c +++ b/main/motor_drive.c @@ -16,7 +16,7 @@ static motor_t *motor_init_structer; /** * @brief 电机初始化 - * + * * @param motor 初始化的结构体(暂时写死,所以结构体为空) */ void motor_init(motor_t *motor) { @@ -37,7 +37,6 @@ void motor_init(motor_t *motor) { return; } - static double motor_drive_read_encoder(); static uint8_t motor_drive_set_packages_ctr(double position, int direction); @@ -82,7 +81,7 @@ void motor_run_to_postion(int rotation_direction, double position, int speed_lev uint8_t checksum = 0; uint32_t limit_speed = 0; uint8_t buffer[14] = {0x3E, 0XA6, MOTOR_ID, 0X08, 0XED, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00, 0X00}; -// char *notify_err = "set size error"; + // char *notify_err = "set size error"; // forward if ((rotation_direction == 1)) { @@ -146,20 +145,20 @@ void motor_run_to_postion(int rotation_direction, double position, int speed_lev } // Parse receive -// motor_drive_buffer_cmd_parse(buffer); + // motor_drive_buffer_cmd_parse(buffer); return; } /** * @brief 注册回调 - * + * * @param onevent 注册的回调函数 */ void motor_reg_event_cb(motor_on_event_t onevent) { return; } /** * @brief 读取编码器 - * + * * @return double 编码器当前位置值返回 */ static double motor_drive_read_encoder() { @@ -189,10 +188,10 @@ static double motor_drive_read_encoder() { /** * @brief 控制电机转多少度 - * + * * @param position 角度 * @param direction 方向 - * @return uint8_t + * @return uint8_t */ static uint8_t motor_drive_set_packages_ctr(double position, int direction) { int position_int = 0; diff --git a/main/port.c b/main/port.c index 66275a2..04b3a32 100644 --- a/main/port.c +++ b/main/port.c @@ -8,4 +8,6 @@ uint32_t port_delay_ms(uint32_t ms) { uint32_t now = port_get_ticket(); while (port_get_ticket() - now < ms) { } + + return 0; }