完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
|
相关推荐
7个回答
|
|
相关代码 [C] 纯文本查看 复制代码 int main(void){ _Init(); while (1) { static u32 i = 0; u8 lTxBuffer[33]; i++; sprintf((char *)lTxBuffer, "%032d", i); oDebug("RF1 => [%s]rn", lTxBuffer); WIRELESS_SendPacket(WIRELESS1, lTxBuffer); LED1 = !LED1; Wait_s(2); }}
[C] 纯文本查看 复制代码 static bool WIRELESS1_IsIrqHandled;static bool WIRELESS2_IsIrqHandled;...void WIRELESS_IrqHandled(u8 aWhichWireless){ switch(aWhichWireless) { case WIRELESS1: WIRELESS1_IsIrqHandled = TRUE; break; case WIRELESS2: WIRELESS2_IsIrqHandled = TRUE; break; }}void WIRELESS_SendPacket(u8 aWhichWireless, u8 *aBuffer){ switch(aWhichWireless) { case WIRELESS1: WIRELESS1_CE = 0; WIRELESS1_IsIrqHandled = FALSE; break; case WIRELESS2: WIRELESS2_CE = 0; WIRELESS2_IsIrqHandled = FALSE; break; } WIRELESS_WriteBuffer(aWhichWireless, NFR_WRITE_TX_PAYLOAD, aBuffer, WIRELESS_TX_PAYLOAD_WIDTH); switch(aWhichWireless) { case WIRELESS1: WIRELESS1_CE = 1; do { Wait_us(10);} while(WIRELESS1_IsIrqHandled == FALSE); break; case WIRELESS2: WIRELESS2_CE = 1; do { Wait_us(10);} while(WIRELESS2_IsIrqHandled == FALSE); break; } return; }
[C] 纯文本查看 复制代码 void EXTI9_5_IRQHandler(void){ // WIRELESS1 触发的中断 if(EXTI_GetITStatus(EXTI_Line8) == SET) { u8 lStatus = WIRELESS_ReadReg(WIRELESS1, NRF_READ_REG + NFR_STATUS); // 读取状态寄存器的值 oDebug("RF1 => "); if(lStatus & NFR_MAX_TX) // 达到最大重发次数 { WIRELESS_WriteReg(WIRELESS1, NFR_FLUSH_TX, 0xFF); // 清除TX FIFO寄存器 oDebug("MAX_TXrn"); } if(lStatus & NFR_TX_OK) // 发送完成 { oDebug("TX_OKrn"); } if(lStatus & NFR_RX_OK) // 接收完成 { oDebug("RX_OKrn"); } // 清除 RX_DS,TX_DS 或 MAX_RT 中断标志 WIRELESS_WriteReg(WIRELESS1, NRF_WRITE_REG + NFR_STATUS, lStatus); WIRELESS_IrqHandled(WIRELESS1); EXTI_ClearITPendingBit(EXTI_Line8); } if(EXTI_GetITStatus(EXTI_Line9) == SET) { u8 lStatus = WIRELESS_ReadReg(WIRELESS2, NRF_READ_REG + NFR_STATUS); // 读取状态寄存器的值 oDebug("RF2 => "); if(lStatus & NFR_MAX_TX) // 达到最大重发次数 { WIRELESS_WriteReg(WIRELESS2, NFR_FLUSH_TX, 0xFF); // 清除TX FIFO寄存器 oDebug("MAX_TXrn"); } if(lStatus & NFR_TX_OK) // 发送完成 { oDebug("TX_OKrn"); } if(lStatus & NFR_RX_OK) // 接收完成 { u8 lRxBuffer[33]; oDebug("RX_OK"); WIRELESS_ReadBuffer(WIRELESS2, NFR_READ_RX_PAYLOAD, lRxBuffer, WIRELESS_RX_PAYLOAD_WIDTH); // 读取数据 WIRELESS_WriteReg(WIRELESS2, NFR_FLUSH_RX, 0xFF); // 清除RX FIFO寄存器 lRxBuffer[32] = 0; oDebug("[%s]rn", lRxBuffer); } // 清除 RX_DS,TX_DS 或 MAX_RT 中断标志 WIRELESS_WriteReg(WIRELESS2, NRF_WRITE_REG + NFR_STATUS, lStatus); WIRELESS_IrqHandled(WIRELESS2); EXTI_ClearITPendingBit(EXTI_Line9); }}
|
|
|
|
|
|
|
|
赞一个,我是弄了双板,4个NRF24L01才可以双向通信,不过这样太占引脚了。如果只用2个NRF,就只能单向。(个人编程能力有限)
|
|
|
|
|
|
|
|
调试了好多次了,中间卡住死机了多次,我的思路和你是一样的。真不好调。网上有种是用ACK With payload 模式实现双向数据通信,不用手动切换收发状态,NRF24L01自动完成收发切换。但是我并不会用,有时间再探讨吧 |
|
|
|
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
如何使用STM32+nrf24l01架构把有线USB设备无线化?
2568 浏览 7 评论
请问能利用51单片机和nRF24L01模块实现实时语音无线传输吗?
2361 浏览 5 评论
3208 浏览 3 评论
2836 浏览 8 评论
为什么ucosii上移植lwip后系统进入了HardFault_Handler?
2787 浏览 4 评论
请教各位大咖:有没有接收频率32M左右的芯片推荐的?先感谢啦!
662浏览 1评论
899浏览 0评论
1021浏览 0评论
665浏览 0评论
495浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-20 23:51 , Processed in 1.188638 second(s), Total 90, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号