From: penglei <1624952103@qq.com> Date: Thu, 31 Oct 2024 09:32:37 +0000 (+0800) Subject: 优化马达震动 X-Git-Tag: fd230_release_V1.3.102~150^2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1305%2Fhead;p=mirrors%2FFD230.git 优化马达震动 --- 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;