From 817961a6ee6a75c2eb9ae6e02a166df822de0f45 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Tue, 2 Jul 2024 09:48:09 +0800 Subject: [PATCH] update --- src/zble_module.c | 22 +++++++++++----------- src/znordic.c | 26 +++++++++++++------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/zble_module.c b/src/zble_module.c index 4d93cca..72ab40d 100644 --- a/src/zble_module.c +++ b/src/zble_module.c @@ -13,7 +13,7 @@ #include "nrf_bootloader_info.h" #endif /******************************************************************************* - * 广播包配?? * + * 骞挎挱鍖呴厤?? * *******************************************************************************/ #define MIN_CONN_INTERVAL MSEC_TO_UNITS(20, UNIT_1_25_MS) /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */ #define MAX_CONN_INTERVAL MSEC_TO_UNITS(75, UNIT_1_25_MS) /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */ @@ -24,12 +24,12 @@ BLE_ADVERTISING_DEF(m_advertising); /**< Advertising module instance. */ /******************************************************************************* - * GATT配置 * + * GATT閰嶇疆 * *******************************************************************************/ NRF_BLE_GATT_DEF(m_gatt); /**< GATT module instance. */ /******************************************************************************* - * 连接参数配置 * + * 杩炴帴鍙傛暟閰嶇疆 * *******************************************************************************/ #define FIRST_CONN_PARAMS_UPDATE_DELAY \ APP_TIMER_TICKS(5000) /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). \ @@ -41,7 +41,7 @@ NRF_BLE_GATT_DEF(m_gatt); /**< GATT module instance. */ * CODE * *******************************************************************************/ -static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /**< 当前连接句柄 */ +static uint16_t m_conn_handle = BLE_CONN_HANDLE_INVALID; /**< 褰撳墠杩炴帴鍙ユ焺 */ static uint16_t m_mtu_size = BLE_GATT_ATT_MTU_DEFAULT - 3; static zble_event_listener_t m_event_listener; static uint32_t m_last_disconnected_tp; @@ -104,7 +104,7 @@ static void ble_evt_handler(ble_evt_t const *p_ble_evt, void *p_context) { } static void gatt_evt_handler(nrf_ble_gatt_t *p_gatt, nrf_ble_gatt_evt_t const *p_evt) { /******************************************************************************* - * MTU SIZE 更新 * + * MTU SIZE 鏇存柊 * *******************************************************************************/ if ((m_conn_handle == p_evt->conn_handle) && (p_evt->evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED)) { m_mtu_size = p_evt->params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH; @@ -306,11 +306,11 @@ static uint8_t p_company_identifier_data[COMPANY_IDENTIFIER_DATA_LEGTH] = { void zble_module_init(zble_module_cfg_t *cfg) { /** * @brief - * 初始化蓝牙协议栈,并注册蓝牙事件处理函数,固定代码,勿修?? + * 鍒濆鍖栬摑鐗欏崗璁爤锛屽苟娉ㄥ唽钃濈墮浜嬩欢澶勭悊鍑芥暟锛屽浐瀹氫唬鐮侊紝鍕夸慨?? */ { NRF_SDH_BLE_OBSERVER(m_ble_observer, 3, ble_evt_handler, NULL); } /******************************************************************************* - * GAP初始?? * + * GAP鍒濆?? * *******************************************************************************/ { uint32_t err_code; @@ -334,7 +334,7 @@ void zble_module_init(zble_module_cfg_t *cfg) { } /******************************************************************************* - * GATT 初始?? * + * GATT 鍒濆?? * *******************************************************************************/ { ret_code_t err_code; @@ -347,7 +347,7 @@ void zble_module_init(zble_module_cfg_t *cfg) { } /******************************************************************************* - * 广播初始?? * + * 骞挎挱鍒濆?? * *******************************************************************************/ { uint32_t err_code; @@ -391,7 +391,7 @@ void zble_module_init(zble_module_cfg_t *cfg) { } /******************************************************************************* - * 蓝牙服务初始?? * + * 钃濈墮鏈嶅姟鍒濆?? * *******************************************************************************/ #if BLE_DFU_ENABLED { @@ -404,7 +404,7 @@ void zble_module_init(zble_module_cfg_t *cfg) { #endif /******************************************************************************* - * 连接参数初始?? * + * 杩炴帴鍙傛暟鍒濆?? * *******************************************************************************/ { uint32_t err_code; diff --git a/src/znordic.c b/src/znordic.c index c582a0a..a1d60ce 100644 --- a/src/znordic.c +++ b/src/znordic.c @@ -22,7 +22,7 @@ nrf_drv_wdt_channel_id m_channel_id; static bool m_wd_is_enable = false; void wd_init() { - // WDT_CONFIG_RELOAD_VALUE 修改这个数值修改喂狗周期,单位ms + // WDT_CONFIG_RELOAD_VALUE 淇敼杩欎釜鏁板间慨鏀瑰杺鐙楀懆鏈,鍗曚綅ms nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG; config.reload_value = WDT_CONFIG_RELOAD_VALUE; ret_code_t err_code = nrf_drv_wdt_init(&config, NULL); @@ -48,7 +48,7 @@ static void rtcCallbackFunc(nrf_drv_rtc_int_type_t interruptType) void znordic_init_without_wd() { { /******************************************************************************* - * 日志系统初始?? * + * 鏃ュ織绯荤粺鍒濆?? * *******************************************************************************/ ret_code_t err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); @@ -64,7 +64,7 @@ void znordic_init_without_wd() { { /******************************************************************************* - * 定时器初始化 * + * 瀹氭椂鍣ㄥ垵濮嬪寲 * *******************************************************************************/ ret_code_t err_code = app_timer_init(); APP_ERROR_CHECK(err_code); @@ -72,7 +72,7 @@ void znordic_init_without_wd() { { /******************************************************************************* - * 电源管理初始 * + * 鐢垫簮绠$悊鍒濆 * *******************************************************************************/ ret_code_t err_code; err_code = nrf_pwr_mgmt_init(); @@ -80,7 +80,7 @@ void znordic_init_without_wd() { } { /******************************************************************************* - * 蓝牙协议栈使 * + * 钃濈墮鍗忚鏍堜娇 * *******************************************************************************/ ret_code_t err_code; err_code = nrf_sdh_enable_request(); @@ -96,7 +96,7 @@ void znordic_init_without_wd() { ret_code_t errCode; nrf_drv_rtc_config_t rtcConfig = NRF_DRV_RTC_DEFAULT_CONFIG; // Initialize RTC instance - rtcConfig.prescaler = 4095; // 如实??8HZ的频率,则PRESCALER寄存器应该设??32768/8-1 = 4095 + rtcConfig.prescaler = 4095; // 濡傚疄??8HZ鐨勯鐜囷紝鍒橮RESCALER瀵勫瓨鍣ㄥ簲璇ヨ??32768/8-1 = 4095 errCode = nrf_drv_rtc_init(&s_rtcHandle, &rtcConfig, rtcCallbackFunc); APP_ERROR_CHECK(errCode); @@ -201,7 +201,7 @@ void znordic_rtc_gettime(ztm_t* now) { } static void rtcCallbackFunc(nrf_drv_rtc_int_type_t interruptType) { - if (interruptType == NRF_DRV_RTC_INT_TICK) // 中断类型:滴答中?? + if (interruptType == NRF_DRV_RTC_INT_TICK) // 涓柇绫诲瀷锛氭淮绛斾腑?? { g_timestamp++; // if (s_timeCount1second >= 7) // 125ms * 8 = 1s @@ -238,12 +238,12 @@ const char* hex2str(const uint8_t* data, uint16_t len) { static DWORD get_fattime_0(uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t min, uint32_t sec) { // return ((DWORD)(year - 1980) << 25 | (DWORD)month << 21 | (DWORD)day << 16); DWORD fattime = 0; - fattime |= ((DWORD)(year - 1980) << 25); // 年份从1980年开始 - fattime |= ((DWORD)(month + 1) << 21); // 月份范围是1-12 - fattime |= ((DWORD)day << 16); // 日 - fattime |= ((DWORD)hour << 11); // 时 - fattime |= ((DWORD)min << 5); // 分 - fattime |= ((DWORD)sec / 2); // 秒,以2秒为单位 + fattime |= ((DWORD)(year - 1980) << 25); // 骞翠唤浠1980骞村紑濮 + fattime |= ((DWORD)(month + 1) << 21); // 鏈堜唤鑼冨洿鏄1-12 + fattime |= ((DWORD)day << 16); // 鏃 + fattime |= ((DWORD)hour << 11); // 鏃 + fattime |= ((DWORD)min << 5); // 鍒 + fattime |= ((DWORD)sec / 2); // 绉掞紝浠2绉掍负鍗曚綅 return fattime; }