我们有一个应用程序,主机MCU每〜6.3秒通过SPI接口向DA14585发送4K页数据。然后DA14585通过通知将该数据继承到无线电。页面之间,我们进入扩展睡眠模式,主MCU使用唤醒定时器唤醒DA14585。通过DMA接收SPI数据,DMA完成的IRQ处理程序将自定义消息发布到内核以启动内核并返回延长睡眠。除了如下所示,所有这些似乎都良好:
It appears that the kernel message is only getting through if the BLE core is active when the DMA IRQ handler (actually callback) executes and the message gets sent. Reading section 7.1.2 of the SW Platform Reference suggests that messages need to be synced with the BLE core. I am inferring that this is the purpose of the on_ble_powered() callback. I modified the code to set a flag in the DMA IRQ handler, then check the flag in an on_ble_powered() callback function. If the flag is set, I send the message to initiate the notifications/characteristic value updates and clear the flag.
但是,通过该代码到位,DA14585无法甚至不再宣传。为什么添加一个on_ble_powered()回调中断代码?当异步事件需要发送消息时,是否有更好的方法“与BLE核心同步”?
以下是相关功能:
DMA完成的回调函数:
静态void epilog_spi_dma_done(void * userdata,uint16_t len)
{
/* Prep data for Bluetooth */
EEG_RT.DATA = RTEEG_BUFFER;
memcpy(&eeg_rt.pageaddr,spi.parmbuf,btspi_parm_len);
/ *重置SPI状态* /
spi_reset_state();
spi_int_bit_clear();
nvic_clearpendingirq(spi_irqn);
spi_enable_irq();
RTPARTEADY = TRUE;
// epilog_spi_send_page_done_msg(&eeg_rt,rteeg_buffer + eeg_page_size);
}
on_ble_powered()回调:
ARCH_MAIN_LOOP_CALLBACK_RET_T SEND_PAGE_ON_BLE_POWERED(void)
{
if(rtpageready){
epilog_spi_send_page_done_msg(&eeg_rt,rteeg_buffer + eeg_page_size);
rtpArteady = false;
}
返回keep_powered;
}
页面发送功能:
静态void epilog_spi_send_page_done_msg(struct eegdata * eeg,uint8_t * evt)
{
struct msg_page_done * msg_param;
msg_param = KE_MSG_ALLOC(APPMSG_PAGE_RECEIVED, TASK_APP, TASK_APP,
msg_page_done);
msg_param-> eeg = eeg;
msg_param-> evt = evt;
KE_MSG_SEND(MSG_PARAM);
}
最后,从user_catch_rest_hndl()函数剪辑以处理appmsg_page_received msg:
案例appmsg_page_received:
{
struct msg_page_done *msg_param = (struct msg_page_done *)param;
uint8_t state = ke_state_get(task_app);
if(state == app_connected){
eegdata_start_notify(msg_param-> eeg);
EEGEVENT_START_NOTIFY(MSG_PARAM-> EEG,MSG_PARAM-> EVT);
}
/ *重新启用睡眠模式* /
app_enable_wakeup();/ *设置wkupct * /
ARCH_SET_EXTENDED_SLEEP(FALSE);
}
休息;
提前感谢您提供的任何建议。
嗨米克伍德,
您对邮件的调度和设备仅在Schage的情况下是正确的,而在BLE核心处于活动状态以及RWIP_SCHEDULE()函数执行时,则执行该设备。消息可以贴花向堆栈发送,但在执行RWIP_Schedule时,它们将同步地服务。我没有看到你发布的代码的任何错误,似乎可以。事实上,你无法宣传的事实应该是别的东西,我的意思是,只要我能从代码中讲述代码即可通过on_ble_powered来告诉代码,标志应该是假的,所以没有额外的代码将在广告程序期间运行。所以我不认为On_ble_Powered()中的代码正在影响广告的功能,还应该进行其他事情。检查设备的内容。检查广告完成回调是否正在调用并检查广告取消的原因,以防广告被取消。此外,只要我能告诉您始终返回Keep_Power,而且不仅有数据可用,这将使您的设备一直处于活动状态,并且不会让它进入睡眠状态。
谢谢mt_dialog.
这在调试器中运行,很明显NMI Handler was tripping, indicating that the watchdog timer had expired. Adding a watchdog_reload() to the beginning of the on_ble_powered() handler restored BLE function. Apparently even a trivially short on_ble_powered() handler is too long for the watchdog.
感谢您澄清邮件可以异步地发送到内核,尽管在BLE核心亮起之前,它们不会被处理。这对我们的应用程序很好 - 所以我毕竟不需要on_ble_powered()处理程序;我可以在DMA完整处理程序的尾端发送消息到内核。我希望文档在这个主题上更清楚 - 它意味着您甚至无法在BLE核心下降时发送消息。
看来我的真实问题是SPI通信处理程序。如果我需要那个答案,我会开始另一个线程。再次感谢。
嗨米克伍德,
很高兴它帮助了。
Best Regards MT_dialog