使用藍(lán)牙發(fā)送數(shù)據(jù)時(shí),使用?tmos_msg_allocate(5);申請(qǐng)了內(nèi)存
pMsg?=?tmos_msg_allocate(5);//?申請(qǐng)內(nèi)存 if?(pMsg?!=?NULL) { ????pMsg[0]?=?0x01; ????pMsg[1]?=?0x02; ????pMsg[2]?=?0x03; ????pMsg[3]?=?0x04; ????pMsg[4]?=?0x05; ????tmos_msg_send(task_id,?pMsg); }
最終是不是回到回調(diào)函數(shù)
uint16_t?Peripheral_ProcessEvent(uint8_t?task_id,?uint16_t?events) { ????if?(events?&?SYS_EVENT_MSG)? ????{ ????????uint8_t?*pMsg; ????????if?((pMsg?=?tmos_msg_receive(Peripheral_TaskID))?!=?NULL)? ????????{ ????????????Peripheral_ProcessTMOSMsg((tmos_event_hdr_t?*)pMsg);?//?處理消息 ????????????tmos_msg_deallocate(pMsg);???????????????????????????//?釋放內(nèi)存 ????????} ????????return?(events?^?SYS_EVENT_MSG); ????} }
通過tmos_msg_deallocate(pMsg);釋放內(nèi)存空間?
熱門產(chǎn)品 :
CH397: 高集成度、低功耗USB網(wǎng)卡芯片