From 9031aaeaf2fc1e5973fcaebdd847f3ebbee440da Mon Sep 17 00:00:00 2001 From: "snickersun@163.com" Date: Wed, 19 Jun 2024 12:45:43 +0000 Subject: [PATCH] Merge #327 into sdk602patch0521 from refs/changes/327/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from snickersun@163.com * refs/changes/327/head: (2 commits squashed) - 存储马达震动模式,开机马达震动不停问题 - Merge branch 'sdk602patch0521' of codeup.aliyun.com:64191456b9581d62e8f81ac0/FD230 into sdk602patch0521 Signed-off-by: snickersun@163.com Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/327 --- .../brandy_evb/board_config/board_evb.h | 8 +-- .../peripheral/config/include/ConfigModelC.h | 4 +- .../peripheral/config/src/ConfigModel.cpp | 10 +++- .../drivers/peripheral/utils/custom_runtime.c | 14 +++++- .../drivers/peripheral/utils/custom_runtime.h | 4 ++ .../vibrator/service/vibrator_service.cpp | 7 ++- .../drivers/peripheral/vibrator/vibrator.c | 49 ++++++++++++------- 7 files changed, 69 insertions(+), 27 deletions(-) diff --git a/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h b/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h index 622ec8c52..756a5a949 100755 --- a/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h +++ b/code/sdk/drivers/boards/brandy_evb/board_config/board_evb.h @@ -195,12 +195,12 @@ const hal_pio_config_t g_pio_function_config[PIN_MAX_NUMBER] = { { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_DISABLE }, // S_AGPIO_R0 PRG_LED_POWER ON 心率等电源控制脚 { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_DISABLE }, // S_AGPIO_R1 SE_REST 安全芯片复位唤醒脚 - #if VIB_USE_PWM +// #if VIB_USE_PWM // { HAL_PIO_FUNC_PWMP1_M2, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_AGPIO_R2 VIBR_PWM 马达控制脚 兼容预留马达驱动复位脚 - { HAL_PIO_FUNC_PWMN1_M3, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_AGPIO_R2 VIBR_PWM 马达控制脚 兼容预留马达驱动复位脚 - #else + // { HAL_PIO_FUNC_PWMN1_M3, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_AGPIO_R2 VIBR_PWM 马达控制脚 兼容预留马达驱动复位脚 +// #else { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_AGPIO_R2 VIBR_PWM 马达控制脚 兼容预留马达驱动复位脚 - #endif +// #endif { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_DOWN, HAL_PIO_IE_DISABLE }, // S_AGPIO_R3 NC { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_UP, HAL_PIO_IE_DISABLE }, // S_AGPIO_R4 tp reset { HAL_PIO_FUNC_GPIO, HAL_PIO_DRIVE_MAX, HAL_PIO_PULL_MAX, HAL_PIO_IE_ENBALE }, // S_AGPIO_R5 touch int diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h index d059c4ba1..b80c4275e 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-04-17 09:32:03 * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-06-05 23:20:27 + * @LastEditTime: 2024-06-19 20:23:10 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h */ #ifndef _CONFIG_MODEL_C_H_ @@ -90,6 +90,8 @@ int16_t get_timezone_quarters(void); uint8_t get_hour_show_model(void); void set_hour_show_model(uint8_t showtype); +uint8_t get_vibmod(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 7cc9da892..0a3a0a664 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -773,6 +773,7 @@ namespace OHOS */ void ConfigModel::SetVibrationReminder(int state) { + uapi_dev_runtime_set_vibmod(state); set_condigData_Int(CONFIGMODEL_ITEM_VIBRATOR_SWITCH,state); } @@ -985,6 +986,8 @@ void installize_dev_runtime(void) //更新24小时显示模式 uint8_t showtype=get_hour_show_model(); uapi_dev_runtime_set_time_hour_show_model(showtype); + uint8_t vibmod=get_vibmod(); + uapi_dev_runtime_set_vibmod(vibmod); } uint32_t ConfigModelInit(void) @@ -1123,7 +1126,12 @@ uint8_t get_hour_show_model(void) showtype = OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_24HOUR); return showtype; } - +uint8_t get_vibmod(void) +{ + uint8_t vibmod = 0; + vibmod = OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_VIBRATOR_SWITCH); + return vibmod; +} void set_hour_show_model(uint8_t showtype) { OHOS::ConfigModel::GetInstance()->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_24HOUR,showtype); diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.c b/code/sdk/drivers/peripheral/utils/custom_runtime.c index 9cce81bef..bce2ecb63 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.c +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.c @@ -64,7 +64,7 @@ typedef struct uint8_t in_silent_mode; uint8_t in_lowpower_mode; uint8_t stepcount; - + uint8_t vibmod; bt_runtime_status_t bt_runtime; cat1_runtime_status_t cat1_runtime; char current_dial_name[32]; @@ -269,4 +269,14 @@ void uapi_dev_runtime_set_ancs_clientid(uint16_t clientid) uint16_t uapi_dev_runtime_get_ancs_clientid(void) { return g_runtime.bt_runtime.ble_ancs_client_id; -} \ No newline at end of file +} + + +void uapi_dev_runtime_set_vibmod(uint8_t vibmod) +{ + g_runtime.vibmod=vibmod; +} +uint8_t uapi_dev_runtime_get_vibmod(void) +{ + return g_runtime.vibmod; +} diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.h b/code/sdk/drivers/peripheral/utils/custom_runtime.h index 53fd241d4..ae905a276 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.h +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.h @@ -42,6 +42,10 @@ void uapi_dev_runtime_set_dialname(char* dialname); */ char* uapi_dev_runtime_get_dialname(void); + +void uapi_dev_runtime_set_vibmod(uint8_t vibmod); + +uint8_t uapi_dev_runtime_get_vibmod(void); /***************************************cat1 runtime 变量设置获取函数**************************************************/ diff --git a/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp b/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp index 1b3d9ad14..1d9236ce2 100644 --- a/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp +++ b/code/sdk/drivers/peripheral/vibrator/service/vibrator_service.cpp @@ -48,11 +48,15 @@ static bool g_batter_service_initialled = false; #include "vibrator_hal.h" #include "vibrator.h" #include "custom_utils.h" +#include "custom_runtime.h" void custom_VibratorFunc_int(int vibratorType) { + + //忽略系统调用参数,只按照configmodel里保存的值来震动 + uint8_t vibmod=uapi_dev_runtime_get_vibmod(); vibrator_cmd_t mail = {0}; - switch (vibratorType) + switch (vibmod) { case 3: mail.cycle_time_ms = 235; @@ -72,7 +76,6 @@ void custom_VibratorFunc_int(int vibratorType) default: break; } - do_vibrator_cmd(mail); } diff --git a/code/sdk/drivers/peripheral/vibrator/vibrator.c b/code/sdk/drivers/peripheral/vibrator/vibrator.c index 89ef5dc5c..23767827c 100644 --- a/code/sdk/drivers/peripheral/vibrator/vibrator.c +++ b/code/sdk/drivers/peripheral/vibrator/vibrator.c @@ -22,6 +22,8 @@ #include "pinctrl.h" #include "vibrator.h" +// #define VIB_DEBUG + #ifdef VIB_USE_PWM #define VIBRATOR_GPIOPPIN S_AGPIO_R2 // #define VIBRATORPIN_MODE HAL_PIO_FUNC_PWMP1_M2 @@ -76,8 +78,9 @@ static int pwm_start(uint16_t duty , uint16_t freq) pwm_started = 1; uapi_pwm_init(); uapi_pin_set_mode(pin, mode); - // PRINT("+++++++ pwm init success +++++++ \r\n"); - +#ifdef VIB_DEBUG + PRINT("+++++++ pwm init success +++++++ \r\n"); +#endif /* test for repeat, interrupt only be call when stop or close */ uint32_t clk_freq = uapi_pwm_get_frequency(channel); uint32_t div_num = (clk_freq + freq / IOT_PWM_FREQ_PART) / freq; @@ -100,15 +103,18 @@ static int pwm_start(uint16_t duty , uint16_t freq) .cycles = IOT_PWM_CFG_REPEAT_CYCLE, .repeat = IOT_PWM_CFG_REPEAT_STATE }; - // PRINT("+++++++ Start pwm clk_freq %u , cycles %u , high_time %u , low_time %u\r\n", - // clk_freq, - // cfg.cycles, - // cfg.high_time, - // cfg.low_time - // ); - +#ifdef VIB_DEBUG + PRINT("+++++++ Start pwm clk_freq %u , cycles %u , high_time %u , low_time %u\r\n", + clk_freq, + cfg.cycles, + cfg.high_time, + cfg.low_time + ); +#endif ret = uapi_pwm_open(channel, &cfg); - // PRINT("uapi_pwm_open %d\n",ret); +#ifdef VIB_DEBUG + PRINT("uapi_pwm_open %d\n",ret); +#endif uapi_pwm_unregister_interrupt(channel); uapi_pwm_register_interrupt(channel, pwm_test_callback); @@ -117,8 +123,9 @@ static int pwm_start(uint16_t duty , uint16_t freq) uapi_pwm_start(0); #else ret = uapi_pwm_start(channel); - // PRINT("uapi_pwm_start %d\n",ret); - +#ifdef VIB_DEBUG + PRINT("uapi_pwm_start %d\n",ret); +#endif #endif return 0; @@ -132,9 +139,14 @@ static int pwm_stop(void) // LOS_Msleep((uint32_t)TEST_TCXO_DELAY_1000MS); LOS_Msleep(delay_ms); uapi_pwm_deinit(); - + LOS_Msleep(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); pwm_started = 0; - // PRINT("+++++++ pwm stoped +++++++ \r\n"); +#ifdef VIB_DEBUG + PRINT("+++++++ pwm stoped +++++++ \r\n"); +#endif return 0; } @@ -148,11 +160,14 @@ void g_VibratorFunc(uint16_t duty , uint16_t cycle_time_ms,uint16_t duration_tim { PRINT("Not Supported param duty %u cycle_time_ms %u duration_time_ms %u !\r\n",duty,cycle_time_ms,duration_time_ms ); }else{ - // PRINT("g_VibratorFunc duration_time_ms %u , duty %u , cycle_time_ms %u\r\n",duration_time_ms ,duty, cycle_time_ms); - +#ifdef VIB_DEBUG + PRINT("g_VibratorFunc duration_time_ms %u , duty %u , cycle_time_ms %u\r\n",duration_time_ms ,duty, cycle_time_ms); +#endif if (vibrating == 1) { - PRINT("vibrating skip\r\n"); +#ifdef VIB_DEBUG + PRINT("vibrating skip\r\n"); +#endif return ; } vibrating = 1; -- 2.17.1