Files
kunlun/export/inc/bsp/iot_spi_dma_api.h

71 lines
2.4 KiB
C
Raw Normal View History

2024-09-28 14:24:04 +08:00
/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef _IOT_SPI_DMA_API_H_
#define _IOT_SPI_DMA_API_H_
#include "os_types_api.h"
#include "iot_pkt_api.h"
#include "iot_spi_api.h"
/**
* @brief iot_spi_dma_h - SPI handle.
*/
typedef void* iot_spi_dma_h;
/**
* @brief iot_spi_dma_config_t - SPI configuration.
*/
typedef struct _iot_spi_dma_config_t_ {
uint32_t freq; /* 1000000 -> 1MHZ */
uint32_t role; /* Master or slaver. See SPI_MASTER / SPI_SLAVER. */
iot_spi_gpio_sel_t gpio;
} iot_spi_dma_config_t;
/**
* @brief iot_spi_dma_rcv_func - Function pointer to get received data from SPI.
* @param p_buf: Pointer of a buffer holding data received.
* @param len: Length of buffer.
*/
typedef void (*iot_spi_dma_rcv_func)(uint8_t *p_buf, uint32_t len);
/**
* @brief iot_spi_dma_open - Open a spi device.
* @param dev: Device number. See enum spi_device_list.
* @param p_func: Function pointer to receive data.
* @return SPI handle.
*/
iot_spi_dma_h iot_spi_dma_open(uint32_t dev, iot_spi_dma_rcv_func p_func);
/**
* @brief iot_spi_dma_send - Send data to SPI.
* @param spi_h: SPI handle.
* @param p_pkt: Packet of data to send.
* @return ERR_FAIL -- Operation failed.
* @return ERR_OK -- Operation Successful.
*/
uint32_t iot_spi_dma_send(iot_spi_dma_h spi_h, iot_pkt_t *p_pkt);
/**
* @brief iot_spi_dma_config - Config SPI port.
* @param spi_h: SPI handle.
* @param p_cfg: Configuration.
* @return ERR_FAIL -- Operation failed.
* @return ERR_OK -- Operation Successful.
*/
uint32_t iot_spi_dma_config(iot_spi_dma_h spi_h, iot_spi_dma_config_t *p_cfg);
#endif /* _IOT_SPI_DMA_API_H_ */