嵌入式技术论坛
直播中

李明

7年用户 1299经验值
私信 关注
[经验]

在RTT中使用W5500模块的过程记录如下

过程
使用menuconfig按RTT之WIZnet软件包的说明文档进行设置 ;
自行在rtconfig.h添加#define BSP_USING_SPIX,X为1.2.3根据需要选择 ;
增加了 STM32f4xx_hal_msp.c中找到HAL_SPI_MspInit函数,将SPIX中的引脚初始化成需要的引脚,因为同样的spi可以由不同引脚定义 ;
全新的 在winz.c中找到int wiz_init(void)函数,函数里会让添加一个功能函数 ;
    if (wiz_init_ok == RT_TRUE)
    {
        LOG_I("RT-Thread WIZnet package is already initialized.");
        return RT_EOK;
    }
        /* initialize reset pin */
    rt_pin_mode(WIZ_RST_PIN, PIN_MODE_OUTPUT);
    /* I think you can attach w5500 into spi bus at here. You can use this function to realize.*/
    /* extern rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, GPIO_TypeDef *cs_gpiox, uint16_t cs_gpio_pin); */
rt_hw_spi_device_attach("spi1", "spi10", GPIOD, GPIO_PIN_2);//此处为添加的功能函数
    /* WIZnet SPI device and pin initialize */
    result = wiz_device_init(WIZ_SPI_DEVICE);
    if (result != RT_EOK)
    {
        goto __exit;
    }
添加后会报错,在winz.c添加下列代码 ;
#include
#include
//h此处为添加内容
#ifdef __cplusplus
extern "C"{
#endif
#include "drv_spi.h"
#ifdef __cplusplus
}
#endif
//添加内容结束
#include
#ifdef WIZ_USING_DHCP
#include
#endif
编译运行下载即可。

原作者:seumarkoi

更多回帖

发帖
×
20
完善资料,
赚取积分