基于RT-Thread测试RW007(SPI接口)的无线网络功能

接口/总线/驱动

1123人已加入

描述

本文主要基于 PSoC™ 62 with CAPSENSE™ evaluation kit开发板 X RT-Thread,测试RW007(SPI接口)的无线网络功能。

一、硬件介绍

PSoC™ 62 with CAPSENSE™ evaluation kit开发板基于CY8C624ALQI_S2D42 ,芯片集成 2MB 内部 Flash 和 1MB SRAM。具有单周期乘法的150-MHz Arm Cortex-M4F CPU (浮点和存储器保护单元),100-MHz Cortex M0+ CPU,带单周期乘法和 MPU,可以充分发挥 PSoC6 双核芯片性能。

RW007 是由上海睿赛德电子科技有限公司开发的高速 WiFi 模块,模块基于 Realtek RTL8710BN(Ameba Z 系列) WIFI SOC,使用 SPI/UART 与主机通信 ,支持 IEEE 802.11b/g/n 网络、 WEP/WPA/WPA2 加密方式和 STA 和 AP 模式。

二、项目创建

目前RT-Thread Studio已经支持PSoC™ 62 with CAPSENSE™ evaluation kit开发板BSP,可以很方便的一路NEXT创建好工程并顺利把灯点起来。本章主要介绍配置RW007 SPI模式。

首先,需要打开SPI接口,根据开发板的原理图,选择SPI0对接RW007网卡,使能SPI0 BUS。

Flash单片机

其二,配置RW007对接的接口,包括CS、INT、RESET等针脚。

Flash单片机

第三、添加RW007软件包,得益于RT-Thread软件包,我们可以灵活的选择各类模块。

Flash单片机

最后,在组件中,使能SPI总线驱动。

Flash单片机

点击工程的保存,然后编译程序。很奇怪为什么文件居然大于1M。点击下载到开发板。

Flash单片机

三、网络测试

固件下载完成后,reset系统,熟悉的log:

| /

RT - Thread Operating System
/ | 4.1.1 build May 7 2023 19:07:36
2006 - 2022 Copyright by RT-Thread team
lwIP-2.0.3 initialized!
[I/sal.skt] Socket Abstraction Layer initialize success.
msh >[spi0] Freq:[25000000]HZ
[31m[E/[RW007]] The wifi Stage 1 status 0 0 0 1
[0m
[I/WLAN.dev] wlan init success
[I/WLAN.lwip] eth device init ok name:w0
[I/WLAN.dev] wlan init success
[I/WLAN.lwip] eth device init ok name:w1
list_device后可以网路已经起来:

list_device
device type ref count

w1 Network Interface 1
w0 Network Interface 1
wlan0 Network Interface 1
wlan1 Network Interface 1
wspi SPI Device 0
spi0 SPI Bus 0
uart6 Character Device 2
pin Pin Device 0
msh >
msh >help
RT-Thread shell commands:
ifconfig - list the information of all network interfaces
ping - ping network host
dns - list and set the information of dns
netstat - list the information of TCP / IP
clear - clear the terminal screen
version - show RT-Thread version information
list_thread - list thread
list_sem - list semaphore in system
list_event - list event in system
list_mutex - list mutex in system
list_mailbox - list mail box in system
list_msgqueue - list message queue in system
list_mempool - list memory pool in system
list_timer - list timer in system
list_device - list device in system
list - list objects
help - RT-Thread shell help.
ps - List threads in the system.
free - Show the memory usage in the system.
wifi - wifi command
pin - pin [option]
reboot - Reboot System
wifi scan后再join:

msh >wifi scan
SSID MAC security rssi chn Mbps


STAR 2.4G a3:36:bc:6a:b7:c8 WPA2_AES_PSK -88 4 0
xWi-Fi5 d7:bb:e6:50:dd:a1 WPA2_AES_PSK -91 1 0
x d7:bb:e6:7b:dd:9c WPA2_AES_PSK -93 1 0
msh >
msh >wifi join SSID PWD
[I/WLAN.mgnt] wifi connect success ssid:SSID
msh >
msh >[I/WLAN.lwip] Got IP address : 192.168.99.216
来个ping,可见RW007工作正常。

msh >ping 192.168.99.1
60 bytes from 192.168.99.1 icmp_seq=0 ttl=64 time=2 ms
60 bytes from 192.168.99.1 icmp_seq=1 ttl=64 time=45 ms
60 bytes from 192.168.99.1 icmp_seq=2 ttl=64 time=2 ms
60 bytes from 192.168.99.1 icmp_seq=3 ttl=64 time=50 ms

四、测试中发现的问题

SPI接口的频率问题,之前一直默认30M HZ,这次也正常的配置成30M,结果reset后系统就出错。

o[spi0] Freq:[30000000]HZ
(result != CYHAL_SPI_RSLT_CLOCK_ERROR) assertion failed at function:ifx_spi_init, line number:93
后来跟群内大佬讨论了下,MCU最大支持25M HZ,于是在配置SPI的时候选择25M HZ,这下正常了。

SPI Mode: The SPI mode supports full Motorola SPI, TI Secure
Simple Pairing (SSP) (essentially adds a start pulse that is used
to synchronize SPI Codecs), and National Microwire (half-duplex
form of SPI). The SPI block supports an EZSPI mode in which
the data interchange is reduced to reading and writing an array
in memory. The SPI interface operates with a 25-MHz clock.

五、相关代码

不需要放github,因为全程基于RT-Thread Studio拖拽实现,直接生成代码,有需要可以动动小手打开RT-Thread Studio生成一份。

六、一些感想

RT-Thread Studio真心赞,硬件平台&基础软件的功能实现统统可以通过拖拽的方式实现,常见的硬件驱动和底层协议之类的基础软件以软件包的形式提供,极大的方便了嵌入式开发者,后续开发者只需要做好2件事:平台移植+业务实现即可,甚至平台移植都可以由厂家实现,譬如本次 PSoC™ 62 with CAPSENSE™ evaluation kit开发板的BSP。

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分