Browse Source

update

master
zhaohe 1 year ago
parent
commit
817961a6ee
  1. 22
      src/zble_module.c
  2. 26
      src/znordic.c

22
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;

26
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;
}

Loading…
Cancel
Save