luat_soc_sdk_2024 V1.0
luat_spi.h
浏览该文件的文档.
1
2#ifndef LUAT_SPI_H
3#define LUAT_SPI_H
4#include "luat_base.h"
9typedef struct luat_spi
10{
11 int id;
12 int CPHA;
13 int CPOL;
14 int dataw;
16 int master;
17 int mode;
19 int cs;
21
28
29typedef struct luat_fatfs_spi
30{
31 uint8_t type;
32 uint8_t spi_id;
33 uint8_t spi_cs;
34 uint8_t nop;
35 uint32_t fast_speed;
36 uint8_t transfer_buf[7];
39
64int luat_spi_config_dma(int spi_id, uint32_t tx_channel, uint32_t rx_channel);
71int luat_spi_close(int spi_id);
82int luat_spi_transfer(int spi_id, const char* send_buf, size_t send_length, char* recv_buf, size_t recv_length);
91int luat_spi_recv(int spi_id, char* recv_buf, size_t length);
100int luat_spi_send(int spi_id, const char* send_buf, size_t length);
108int luat_spi_change_speed(int spi_id, uint32_t speed);
120int luat_spi_no_block_transfer(int spi_id, uint8_t *tx_buff, uint8_t *rx_buff, size_t len, void *CB, void *pParam);
127int luat_spi_get_mode(int spi_id);
135int luat_spi_set_mode(int spi_id, uint8_t mode);
136
175int luat_spi_device_transfer(luat_spi_device_t* spi_dev, const char* send_buf, size_t send_length, char* recv_buf, size_t recv_length);
184int luat_spi_device_recv(luat_spi_device_t* spi_dev, char* recv_buf, size_t length);
193int luat_spi_device_send(luat_spi_device_t* spi_dev, const char* send_buf, size_t length);
194
196#endif
int luat_spi_bus_setup(luat_spi_device_t *spi_dev)
spi总线初始化
int luat_spi_device_setup(luat_spi_device_t *spi_dev)
spi设备初始化
int luat_spi_recv(int spi_id, char *recv_buf, size_t length)
收SPI数据
int luat_spi_device_transfer(luat_spi_device_t *spi_dev, const char *send_buf, size_t send_length, char *recv_buf, size_t recv_length)
spi设备收发数据,返回接收字节数
int luat_spi_device_send(luat_spi_device_t *spi_dev, const char *send_buf, size_t length)
spi设备发送数据,返回接收字节数
struct luat_fatfs_spi luat_fatfs_spi_t
int luat_spi_close(int spi_id)
关闭SPI
int luat_spi_device_recv(luat_spi_device_t *spi_dev, char *recv_buf, size_t length)
spi设备接收数据,返回接收字节数
int luat_spi_device_config(luat_spi_device_t *spi_dev)
spi设备配置
struct luat_spi luat_spi_t
int luat_spi_get_mode(int spi_id)
SPI模式获取
int luat_spi_config_dma(int spi_id, uint32_t tx_channel, uint32_t rx_channel)
SPI收发数据尝试启动DMA模式
int luat_spi_change_speed(int spi_id, uint32_t speed)
SPI速率修改
int luat_spi_no_block_transfer(int spi_id, uint8_t *tx_buff, uint8_t *rx_buff, size_t len, void *CB, void *pParam)
SPI收发数据(异步)
int luat_spi_setup(luat_spi_t *spi)
初始化配置SPI各项参数,并打开SPI luat_spi_t 结构体参数 spiId,–串口id cs, 0,–CPHA 0,–CPOL 8,–数据宽度 20000000,...
struct luat_spi_device luat_spi_device_t
int luat_spi_device_close(luat_spi_device_t *spi_dev)
spi设备关闭
int luat_spi_set_mode(int spi_id, uint8_t mode)
SPI模式修改
int luat_spi_transfer(int spi_id, const char *send_buf, size_t send_length, char *recv_buf, size_t recv_length)
收发SPI数据
int luat_spi_send(int spi_id, const char *send_buf, size_t length)
发SPI数据
uint8_t transfer_buf[7]
luat_spi_device_t * spi_device
uint32_t fast_speed
luat_spi_t spi_config