luat_soc_sdk_2024 V1.0
luat_spi.h 文件参考
#include "luat_base.h"

浏览该文件的源代码.

结构体

struct  luat_spi
 
struct  luat_spi_device
 
struct  luat_fatfs_spi
 

类型定义

typedef struct luat_spi luat_spi_t
 
typedef struct luat_spi_device luat_spi_device_t
 
typedef struct luat_fatfs_spi luat_fatfs_spi_t
 

函数

int luat_spi_setup (luat_spi_t *spi)
 初始化配置SPI各项参数,并打开SPI luat_spi_t 结构体参数
spiId,–串口id
cs,
0,–CPHA
0,–CPOL
8,–数据宽度
20000000,–最大频率20M
spi.MSB,–高低位顺序 可选,默认高位在前
spi.master,–主模式 可选,默认主
spi.full,–全双工 可选,默认全双工

 
int luat_spi_config_dma (int spi_id, uint32_t tx_channel, uint32_t rx_channel)
 SPI收发数据尝试启动DMA模式
 
int luat_spi_close (int spi_id)
 关闭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_recv (int spi_id, char *recv_buf, size_t length)
 收SPI数据
 
int luat_spi_send (int spi_id, const char *send_buf, size_t length)
 发SPI数据
 
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_get_mode (int spi_id)
 SPI模式获取
 
int luat_spi_set_mode (int spi_id, uint8_t mode)
 SPI模式修改
 
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_device_config (luat_spi_device_t *spi_dev)
 spi设备配置
 
int luat_spi_device_close (luat_spi_device_t *spi_dev)
 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_recv (luat_spi_device_t *spi_dev, char *recv_buf, size_t length)
 spi设备接收数据,返回接收字节数
 
int luat_spi_device_send (luat_spi_device_t *spi_dev, const char *send_buf, size_t length)
 spi设备发送数据,返回接收字节数