From 86ba3defd22cd77a6127b6fdbf452ae319886394 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Thu, 31 Oct 2024 17:32:37 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E9=A9=AC=E8=BE=BE=E9=9C=87?= =?utf8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../drivers/peripheral/vibrator/vibrator.c | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/code/sdk/drivers/peripheral/vibrator/vibrator.c b/code/sdk/drivers/peripheral/vibrator/vibrator.c index 80b9f6605..17d05d3c6 100644 --- a/code/sdk/drivers/peripheral/vibrator/vibrator.c +++ b/code/sdk/drivers/peripheral/vibrator/vibrator.c @@ -135,10 +135,10 @@ static int pwm_stop(void) errcode_t ret = uapi_pwm_close(channel); // PRINT("uapi_pwm_close %d\n",ret); - // LOS_Msleep((uint32_t)TEST_TCXO_DELAY_1000MS); - LOS_Msleep(delay_ms); + // LOS_Mdelay((uint32_t)TEST_TCXO_DELAY_1000MS); + LOS_Mdelay(delay_ms); uapi_pwm_deinit(); - LOS_Msleep(delay_ms); + LOS_Mdelay(delay_ms); uapi_pin_set_mode(VIBRATOR_GPIOPPIN, (pin_mode_t)HAL_PIO_FUNC_GPIO); uapi_gpio_set_dir(VIBRATOR_GPIOPPIN,GPIO_DIRECTION_OUTPUT); uapi_gpio_set_val(VIBRATOR_GPIOPPIN,GPIO_LEVEL_LOW); @@ -154,7 +154,7 @@ static uint8_t switch_flag = 1; void g_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_time_ms) { - + errcode_t ret; if( duty>100 || duty ==0 ||cycle_time_ms == 0 || duration_time_ms == 0) { PRINT("Not Supported param duty %u cycle_time_ms %u duration_time_ms %u !\r\n",duty,cycle_time_ms,duration_time_ms ); @@ -173,11 +173,16 @@ void g_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_tim pwm_start(duty,cycle_time_ms); - // LOS_Msleep(duration_time_ms); + // LOS_Mdelay(duration_time_ms); LOS_Mdelay(duration_time_ms); + ret = pwm_stop(); + + if(ret != 0) + { + pwm_stop(); + } pwm_stop(); - vibrating = 0; } } @@ -221,9 +226,9 @@ void g_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_tim while(duration_time_ms) { uapi_gpio_set_val(VIBRATOR_GPIOPPIN,GPIO_LEVEL_HIGH); - LOS_Msleep(delaytime_ms_high); + LOS_Mdelay(delaytime_ms_high); uapi_gpio_set_val(VIBRATOR_GPIOPPIN,GPIO_LEVEL_LOW); - LOS_Msleep(delaytime_ms_low); + LOS_Mdelay(delaytime_ms_low); duration_time_ms-=delaytime_ms_high; duration_time_ms-=delaytime_ms_low; -- 2.17.1