基於Apollo3-Blue-MCU的智慧手錶方案原始碼解析
阿新 • • 發佈:2022-05-19
一 方案簡介
1.簡介
Apollo3 Blue Wireless SoC是一款超低功耗無線mcu晶片,它的執行功耗降至6μA/ MHz以下。該器件採用ARM Cortex M4F核心,執行頻率高達96 MHz,集成了藍芽低功耗(BLE5),並提供一些更新的外設,附加記憶體和高階DMA引擎。憑藉著出色的超低功耗效能,該晶片在智慧手錶上應用十分廣泛。
2.特性
- 通過ble和手機同步資訊
- 支援按鍵操作
- 支援ble的特性
void WatchStart(void) { /* Register for stack callbacks */ DmRegister(watchDmCback); DmConnRegister(DM_CLIENT_ID_APP, watchDmCback); AttRegister(watchAttCback); AttConnRegister(AppServerConnCback); AttsCccRegister(WATCH_NUM_CCC_IDX, (attsCccSet_t*) watchCccSet, watchCccCback); /* Register for app framework button callbacks */ AppUiBtnRegister(watchBtnCback); /* Register for app framework discovery callbacks */ AppDiscRegister(watchDiscCback); /* Initialize attribute server database */ SvcCoreAddGroup(); /* Reset the device */ DmDevReset(); }
2. 處理手錶的無線業務資訊
void WatchHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) { if (pMsg != NULL) { APP_TRACE_INFO1("Watch got evt %d", pMsg->event); /* process ATT messages */ if (pMsg->event <= ATT_CBACK_END) { /* process discovery-related ATT messages */ AppDiscProcAttMsg((attEvt_t*) pMsg); /* process server-related ATT messages */ AppServerProcAttMsg(pMsg); } /* process DM messages */ else if (pMsg->event <= DM_CBACK_END) { if (pMsg->param == DM_CONN_ID_NONE || DmConnRole((dmConnId_t) pMsg->param) == DM_ROLE_MASTER) { /* process advertising and connection-related messages */ AppMasterProcDmMsg((dmEvt_t *) pMsg); /* process security-related messages */ AppMasterSecProcDmMsg((dmEvt_t *) pMsg); } if (pMsg->param == DM_CONN_ID_NONE || DmConnRole((dmConnId_t) pMsg->param) == DM_ROLE_SLAVE) { /* process advertising and connection-related messages */ AppSlaveProcDmMsg((dmEvt_t *) pMsg); /* process security-related messages */ AppSlaveSecProcDmMsg((dmEvt_t *) pMsg); } /* process discovery-related messages */ AppDiscProcDmMsg((dmEvt_t *) pMsg); } /* perform profile and user interface-related operations */ watchProcMsg((dmEvt_t *) pMsg); } }
3.更新手錶的業務資訊
static void watchMasterValueUpdate(attEvt_t *pMsg) { if (pMsg->hdr.status == ATT_SUCCESS) { /* determine which profile the handle belongs to; start with most likely */ /* heart rate */ if (HrpcHrsValueUpdate(pWatchHrsHdlList, pMsg) == ATT_SUCCESS) { return; } /* device information */ if (DisValueUpdate(pWatchDisHdlList, pMsg) == ATT_SUCCESS) { return; } /* GATT */ if (GattValueUpdate(pWatchMstGattHdlList, pMsg) == ATT_SUCCESS) { return; } } }三 總結備忘 1.還需要進一步的分析顯示屏和協議部分。 2.ble的各種狀態資訊值得深入分析