Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
NRF24L01
NRF24L01 创建失败
发布于 2023-11-08 16:30:52 浏览:432
订阅该版
第一次使用rtthread的NRF24L01组件,msh提示 `Failed to create nrf24 instance`。 ,希望帮指点一下! ``` #include
#include
#include "drv_spi.h" #if (PKG_NRF24L01_DEMO_CE_PIN < 0) #error Please specify a valid pin #endif #ifdef PKG_NRF24L01_DEMO_ROLE_PTX #define NRF24_DEMO_ROLE ROLE_PTX #define NRF24_DEMO_SEND_INTERVAL PKG_NRF24L01_DEMO_INTERVAL_SEND #else #define NRF24_DEMO_ROLE ROLE_PRX #endif #define NRF24_DEMO_SPI_DEV_NAME PKG_NRF24L01_DEMO_SPI_DEV_NAME #define NRF24_DEMO_CE_PIN PKG_NRF24L01_DEMO_CE_PIN #define NRF24_DEMO_IRQ_PIN PKG_NRF24L01_DEMO_IRQ_PIN const static char *ROLE_TABLE[] = {"PTX", "PRX"}; static void rx_ind(nrf24_t nrf24, uint8_t *data, uint8_t len, int pipe) { /*! Don't need to care the pipe if the role is ROLE_PTX */ rt_kprintf("(p%d): ", pipe); rt_kprintf((char *)data); } static void tx_done(nrf24_t nrf24, int pipe) { static int cnt = 0; static char tbuf[32]; cnt++; /*! Here just want to tell the user when the role is ROLE_PTX the pipe have no special meaning except indicating (send) FAILED or OK However, it will matter when the role is ROLE_PRX*/ if (nrf24->cfg.role == ROLE_PTX) { if (pipe == NRF24_PIPE_NONE) rt_kprintf("tx_done failed"); else rt_kprintf("tx_done ok"); } else { rt_kprintf("tx_done ok"); } rt_kprintf(" (pipe%d)\n", pipe); rt_sprintf(tbuf, "My role is %s [%dth]\n", ROLE_TABLE[nrf24->cfg.role], cnt); nrf24_send_data(nrf24, (uint8_t *)tbuf, rt_strlen(tbuf), pipe); #ifdef PKG_NRF24L01_DEMO_ROLE_PTX rt_thread_mdelay(NRF24_DEMO_SEND_INTERVAL); #endif } const static struct nrf24_callback _cb = { .rx_ind = rx_ind, .tx_done = tx_done, }; static void thread_entry(void *param) { nrf24_t nrf24; rt_kprintf("[nrf24/demo] Version:%s\n", PKG_NRF24L01_VERSION); nrf24 = nrf24_default_create(NRF24_DEMO_SPI_DEV_NAME, NRF24_DEMO_CE_PIN, NRF24_DEMO_IRQ_PIN, &_cb, NRF24_DEMO_ROLE); if (nrf24 == RT_NULL) { rt_kprintf("\n[nrf24/demo] Failed to create nrf24. stop!\n"); for(;;) rt_thread_mdelay(10000); } else { rt_kprintf("[nrf24/demo] running."); } // nrf24_send_data(nrf24, "Hi\n", 3, NRF24_DEFAULT_PIPE); while (1) { nrf24_run(nrf24); if(!nrf24->flags.using_irq) rt_thread_mdelay(10); } } static int nrf24l01_sample_init(void) { rt_thread_t thread; thread = rt_thread_create("nrfDemo", thread_entry, RT_NULL, 1024, RT_THREAD_PRIORITY_MAX/2, 20); rt_thread_startup(thread); return RT_EOK; } INIT_APP_EXPORT(nrf24l01_sample_init); static int rt_hw_nrf24l01_init(void) { rt_hw_spi_device_attach("spi1", "spi10",GPIOD,GPIO_PIN_0); return RT_EOK; } INIT_COMPONENT_EXPORT(rt_hw_nrf24l01_init); ```
查看更多
0
个回答
默认排序
按发布时间排序
暂无答案,快来添加答案吧
撰写答案
登录
注册新账号
关注者
0
被浏览
432
关于作者
dengdai1399
这家伙很懒,什么也没写!
提问
43
回答
4
被采纳
0
关注TA
发私信
相关问题
1
SPI连接NRF24 报错spi transfer error : 3
2
NRF24L01 Send failed 发送失败
3
NRF24与裸机版本驱动通信
4
智能家居diy的无线传输中的问题
5
使用NRF24l01软件包注册设备失败
6
加入nrf24l01软件包后无反应
7
智能家居DIY的nRF24L01问题
8
请问nrf24l01软件包的nrf24_default_create()有疑问
9
为什么我使用NRF24L01软件包时,接收节点接收几次消息后便卡死了
10
STM32 NRF24L01无法运行的问题
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
RT-Thread动态模块
2
RT-Thread项目助手v0.3 | Ubuntu与MacOS平台的RT-Thread Env
3
【FRA156测评DM-MCX】- 环境配置篇
4
【基于HPM6750+RW007的网页服务器】---SD卡文件系统
5
有关RT_thread studio使用WDT的一点经验
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
rt-smart
RTC
FAL
I2C_IIC
ESP8266
UART
cubemx
WIZnet_W5500
ota在线升级
PWM
BSP
flash
freemodbus
packages_软件包
潘多拉开发板_Pandora
GD32
定时器
ADC
flashDB
编译报错
socket
中断
rt_mq_消息队列_msg_queue
Debug
keil_MDK
SFUD
msh
ulog
C++_cpp
MicroPython
本月问答贡献
lchnu
3
个答案
2
次被采纳
张世争
1
个答案
2
次被采纳
a1012112796
9
个答案
1
次被采纳
三世执戟
8
个答案
1
次被采纳
聚散无由
5
个答案
1
次被采纳
本月文章贡献
jinchanchan
9
篇文章
13
次点赞
ssdd45555
3
篇文章
2
次点赞
聚散无由
1
篇文章
4
次点赞
rvcore
1
篇文章
1
次点赞
lvdongchina
1
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部