通过SPI设备读取 w25q 的 ID 数据
更多...
通过SPI设备读取 w25q 的 ID 数据
源码
#include <rtthread.h>
#include <rtdevice.h>
#define W25Q_SPI_DEVICE_NAME "qspi10"
static void spi_w25q_sample(int argc, char *argv[])
{
char name[RT_NAME_MAX];
if (argc == 2)
{
}
else
{
rt_strncpy(name, W25Q_SPI_DEVICE_NAME, RT_NAME_MAX);
}
if (!spi_dev_w25q)
{
rt_kprintf(
"spi sample run failed! can't find %s device!\n", name);
}
else
{
rt_kprintf(
"use rt_spi_send_then_recv() read w25q ID is:%x%x\n",
id[3],
id[4]);
msg1.length = 1;
msg1.cs_take = 1;
msg1.cs_release = 0;
msg1.next = &msg2;
msg2.recv_buf = id;
msg2.length = 5;
msg2.cs_take = 0;
msg2.cs_release = 1;
rt_kprintf(
"use rt_spi_transfer_message() read w25q ID is:%x%x\n",
id[3],
id[4]);
}
}