mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2026-08-28 01:01:34 +00:00
rel_1.6.0 init
This commit is contained in:
commit
27b3e2883d
19359 changed files with 8093121 additions and 0 deletions
80
Living_SDK/include/hal/soc/spi.h
Normal file
80
Living_SDK/include/hal/soc/spi.h
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef HAL_SPI_H
|
||||
#define HAL_SPI_H
|
||||
|
||||
#define HAL_SPI_MODE_MASTER 1 /* spi communication is master mode */
|
||||
#define HAL_SPI_MODE_SLAVE 2 /* spi communication is slave mode */
|
||||
|
||||
typedef struct {
|
||||
uint32_t mode; /* spi communication mode */
|
||||
uint32_t freq; /* communication frequency Hz */
|
||||
} spi_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t port; /* spi port */
|
||||
spi_config_t config; /* spi config */
|
||||
void *priv; /* priv data */
|
||||
} spi_dev_t;
|
||||
|
||||
/**
|
||||
* Initialises the SPI interface for a given SPI device
|
||||
*
|
||||
* @param[in] spi the spi device
|
||||
*
|
||||
* @return 0 : on success, EIO : if the SPI device could not be initialised
|
||||
*/
|
||||
int32_t hal_spi_init(spi_dev_t *spi);
|
||||
|
||||
/**
|
||||
* Spi send
|
||||
*
|
||||
* @param[in] spi the spi device
|
||||
* @param[in] data spi send data
|
||||
* @param[in] size spi send data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if the SPI device could not be initialised
|
||||
*/
|
||||
int32_t hal_spi_send(spi_dev_t *spi, const uint8_t *data, uint16_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* spi_recv
|
||||
*
|
||||
* @param[in] spi the spi device
|
||||
* @param[out] data spi recv data
|
||||
* @param[in] size spi recv data size
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0 : on success, EIO : if the SPI device could not be initialised
|
||||
*/
|
||||
int32_t hal_spi_recv(spi_dev_t *spi, uint8_t *data, uint16_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* spi send data and recv
|
||||
*
|
||||
* @param[in] spi the spi device
|
||||
* @param[in] tx_data spi send data
|
||||
* @param[in] rx_data spi recv data
|
||||
* @param[in] size spi data to be sent and recived
|
||||
* @param[in] timeout timeout in ms
|
||||
*
|
||||
* @return 0, on success; EIO : if the SPI device could not be initialised
|
||||
*/
|
||||
int32_t hal_spi_send_recv(spi_dev_t *spi, uint8_t *tx_data, uint8_t *rx_data,
|
||||
uint16_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* De-initialises a SPI interface
|
||||
*
|
||||
*
|
||||
* @param[in] spi the SPI device to be de-initialised
|
||||
*
|
||||
* @return 0 : on success, EIO : if an error occurred
|
||||
*/
|
||||
int32_t hal_spi_finalize(spi_dev_t *spi);
|
||||
|
||||
#endif /* HAL_SPI_H */
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue