124 lines
3.8 KiB
C
124 lines
3.8 KiB
C
/*================================================================
|
|
Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
|
|
Quectel Wireless Solutions Proprietary and Confidential.
|
|
=================================================================*/
|
|
|
|
#ifndef _QL_SPI_H_
|
|
#define _QL_SPI_H_
|
|
#include "quec_spi.h"
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
* Function: ql_spi_init
|
|
* Description: SPI_INIT
|
|
*
|
|
* Parameters:
|
|
* port [in] SPI引脚选择SS0\SS2。
|
|
* spimode [in] 控制器模式:QL_SPI_MODE0,QL_SPI_MODE1,QL_SPI_MODE2,QL_SPI_MODE3,
|
|
* spiclk [in] 传输时钟
|
|
* Return:
|
|
* 0 成功。
|
|
* -1 失败。
|
|
*****************************************************************/
|
|
int ql_spi_init(SPI_PORT_E port, SPI_MODE_E spimode, SPI_CLK_E spiclk);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_spi_write
|
|
* Description:SPI写数据
|
|
*
|
|
* Parameters:
|
|
* port [in] SPI引脚选择SS0\SS2。
|
|
* buf [in] 存放写入的数据
|
|
* len [in] 写数据的长度
|
|
* Return:
|
|
* 0 成功。
|
|
* -1 失败。
|
|
*****************************************************************/
|
|
int ql_spi_write(SPI_PORT_E port, unsigned char *buf, unsigned int len);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_spi_read
|
|
* Description:SPI读数据
|
|
*
|
|
* Parameters:
|
|
* port [in] SPI引脚选择SS0\SS2。
|
|
* buf [in] 存放读取的数据
|
|
* len [in] 读取数据的长度
|
|
* Return:
|
|
* 0 成功。
|
|
* -1 失败。
|
|
*****************************************************************/
|
|
int ql_spi_read(SPI_PORT_E port, unsigned char *buf, unsigned int len);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_spi_write_read
|
|
* Description:SPI数据读写
|
|
*
|
|
* Parameters:
|
|
* port [in] SPI引脚选择SS0\SS2。
|
|
* inbuf [in] 存放写入的数据
|
|
* outbuf [in] 存放读出的数据
|
|
* len [in] 读写数据的长度
|
|
* Return:
|
|
* 0 成功。
|
|
* -1 失败。
|
|
*****************************************************************/
|
|
int ql_spi_write_read(SPI_PORT_E port, unsigned char *inbuf, unsigned char *outbuf, unsigned int len);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_spi_pio_width_write
|
|
* Description:SPI写数据,带位宽参数
|
|
*
|
|
* Parameters:
|
|
* port [in] SPI引脚选择SS0\SS2。
|
|
* buf [in] 存放写入的数据
|
|
* len [in] 写数据的长度
|
|
* bit_width [in] 位宽配置,如8bit/9bit
|
|
* Return:
|
|
* 0 成功。
|
|
* -1 失败。
|
|
*****************************************************************/
|
|
int ql_spi_pio_width_write(SPI_PORT_E port, unsigned int *buf, unsigned int len, int bit_width);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_spi_pio_width_read
|
|
* Description:SPI读数据
|
|
*
|
|
* Parameters:
|
|
* port [in] SPI引脚选择SS0\SS2。
|
|
* buf [in] 存放读取的数据
|
|
* len [in] 读取数据的长度
|
|
* bit_width [in] 位宽配置,如8bit/9bit
|
|
* Return:
|
|
* 0 成功。
|
|
* -1 失败。
|
|
*****************************************************************/
|
|
int ql_spi_pio_width_read(SPI_PORT_E port, unsigned int *buf, unsigned int len, int bit_width);
|
|
|
|
/*****************************************************************
|
|
* Function: ql_spi_pio_width_write_read
|
|
* Description:SPI数据读写
|
|
*
|
|
* Parameters:
|
|
* port [in] SPI引脚选择SS0\SS2。
|
|
* inbuf [in] 存放写入的数据
|
|
* outbuf [in] 存放读出的数据
|
|
* len [in] 读写数据的长度
|
|
* bit_width [in] 位宽配置,如8bit/9bit
|
|
* Return:
|
|
* 0 成功。
|
|
* -1 失败。
|
|
*****************************************************************/
|
|
int ql_spi_pio_width_write_read(SPI_PORT_E port, unsigned int *inbuf, unsigned int *outbuf, unsigned int len, int bit_width);
|
|
|
|
#ifdef __cplusplus
|
|
} /*"C" */
|
|
#endif
|
|
|
|
#endif /* _QL_UART_H_ */
|
|
|