完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
本文摘录于本人博客:http://blog.csdn.net/chengdong1314/article/details/51378938
1.在KEILL仿真设置里找不到烧录固件,就是在下图中找不到nrf51xxx 问题的原因是没有安装好keill的补丁,重装补丁可以解决,如果不行在安装选项中选择好调用的文件,在安装SDK的时候应该按照下图进行: 2.关于BLEevents和system(SOC) events的区别 在51822这个芯片的协议栈初始化函数ble_stack_init里的ble_evt_dispatch和sys_evt_dispatch这两个函数注册了这两个事件的回调函数,代码如下: /**@brief Function for initializing the BLE stack. * * @Details Initializes the SoftDevice and the BLE event interrupt. */ static void ble_stack_init(void) { uint32_t err_code; // Initialize the SoftDevice handler module. SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false); // Register with the SoftDevice handler module for BLE events. err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch); APP_ERROR_CHECK(err_code); // Register with the SoftDevice handler module for BLE events. err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch); APP_ERROR_CHECK(err_code); } 先看softdevice_sys_evt_handler_set系统回调函数: uint32_t softdevice_sys_evt_handler_set(sys_evt_handler_t sys_evt_handler) { if (sys_evt_handler == NULL) { return NRF_ERROR_NULL; } m_sys_evt_handler = sys_evt_handler; return NRF_SUCCESS; } 这里就是初始化m_sys_evt_handler变量,该变量在intern_softdevice_events_execute这个函数使用,代码如下: void intern_softdevice_events_execute(void) { if (!m_softdevice_enabled) { // SoftDevice not enabled. This can be possible if the SoftDevice was enabled by the // application without using this module's API (i.e softdevice_handler_init) return; } bool no_more_soc_evts = (m_sys_evt_handler == NULL); #ifdef BLE_STACK_SUPPORT_REQD bool no_more_ble_evts = (m_ble_evt_handler == NULL); #endif #ifdef ANT_STACK_SUPPORT_REQD bool no_more_ant_evts = (m_ant_evt_handler == NULL); #endif for (;;) { uint32_t err_code; if (!no_more_soc_evts) { uint32_t evt_id; // Pull event from SOC. err_code = sd_evt_get(&evt_id); if (err_code == NRF_ERROR_NOT_FOUND) { no_more_soc_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's SOC event handler. m_sys_evt_handler(evt_id); } } #ifdef BLE_STACK_SUPPORT_REQD // Fetch BLE Events. if (!no_more_ble_evts) { // Pull event from stack uint16_t evt_len = m_ble_evt_buffer_size; err_code = sd_ble_evt_get(m_evt_buffer, &evt_len); if (err_code == NRF_ERROR_NOT_FOUND) { no_more_ble_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's BLE stack event handler. m_ble_evt_handler((ble_evt_t *)m_evt_buffer); } } #endif #ifdef ANT_STACK_SUPPORT_REQD // Fetch ANT Events. if (!no_more_ant_evts) { // Pull event from stack err_code = sd_ant_event_get(&((ant_evt_t *)m_evt_buffer)->channel, &((ant_evt_t *)m_evt_buffer)->event, ((ant_evt_t *)m_evt_buffer)->evt_buffer); if (err_code == NRF_ERROR_NOT_FOUND) { no_more_ant_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's ANT stack event handler. m_ant_evt_handler((ant_evt_t *)m_evt_buffer); } } #endif if (no_more_soc_evts) { // There are no remaining System (SOC) events to be fetched from the SoftDevice. #if defined(ANT_STACK_SUPPORT_REQD) && defined(BLE_STACK_SUPPORT_REQD) // Check if there are any remaining BLE and ANT events. if (no_more_ble_evts && no_more_ant_evts) { break; } #elif defined(BLE_STACK_SUPPORT_REQD) // Check if there are any remaining BLE events. if (no_more_ble_evts) { break; } #elif defined(ANT_STACK_SUPPORT_REQD) // Check if there are any remaining ANT events. if (no_more_ant_evts) { break; } #else // No need to check for BLE or ANT events since there is no support for BLE and ANT // required. break; #endif } } } 对于系统时间的关键代码是这样的: if (!no_more_soc_evts) { uint32_t evt_id; // Pull event from SOC. err_code = sd_evt_get(&evt_id); if (err_code == NRF_ERROR_NOT_FOUND) { no_more_soc_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's SOC event handler. m_sys_evt_handler(evt_id); } 类似的对于BLE时间的关键代码如下: if (!no_more_ble_evts) { // Pull event from stack uint16_t evt_len = m_ble_evt_buffer_size; err_code = sd_ble_evt_get(m_evt_buffer, &evt_len); if (err_code == NRF_ERROR_NOT_FOUND) { no_more_ble_evts = true; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } else { // Call application's BLE stack event handler. m_ble_evt_handler((ble_evt_t *)m_evt_buffer); } } 那么他们的不同就在于sd_evt_get和sd_ble_evt_get,在手册中对sd_evt_get解释如下:
Gets any pending events generated by the SoC API. The application should keep calling this function to get events, until NRF_ERROR_NOT_FOUND is returned. Parameters
有这个提示再看看SoC API: FunctionsSoC Library API
从这里就可以看出系统事件就是那些和BLE没有关系的是关于芯片中断的时间,比如NVIC和电源之类,BLE事件就是协议栈相关的事件,比如蓝牙发现等等 |
|||||
|
|||||
只有小组成员才能发言,加入小组>>
物联网工程师必备:怎么选择不同的无线连接技术,本指南帮你忙!
2917 浏览 1 评论
【DFRobot TinkerNode NB-IoT 物联网开发板试用连载】WIFI功能测试
3589 浏览 0 评论
【DFRobot TinkerNode NB-IoT 物联网开发板试用连载】Arduino的替代SublimeText3+STino
3118 浏览 0 评论
使用端口扩展器轻松高效地向IIoT端点添加具有成本效益的子节点
3611 浏览 1 评论
19989 浏览 11 评论
2605浏览 1评论
237浏览 1评论
Banana Pi BPI-Centi-S3 是一个板载1.9英寸彩屏的小尺寸ESP32-S3开发板
1044浏览 0评论
8015浏览 0评论
8089浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-4-24 08:32 , Processed in 0.791210 second(s), Total 38, Slave 31 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号