82 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			82 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /****************************************************************************
 | |
| 
 | |
| 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 _SPI_H_
 | |
| #define _SPI_H_
 | |
| #include "gpio_mtx.h"
 | |
| #include "iot_spi_api.h"
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| #ifndef OK
 | |
| #define OK     (0)
 | |
| #define ERROR   (-1)
 | |
| typedef int     STATUS;
 | |
| #endif
 | |
| 
 | |
| #ifndef BIT
 | |
| #define BIT(b)  (1<<(b))
 | |
| #endif
 | |
| 
 | |
| /* Interrupts masks */
 | |
| #define SPI_RXFIFO_FULL     INT_RXFIFO_FULL
 | |
| #define SPI_RXFIFO_OVFL     INT_RXFIFO_OVERFLOW
 | |
| #define SPI_RXFIFO_UDFL     INT_RXFIFO_UNDERFLOW
 | |
| #define SPI_TXFIFO_EMPTY    INT_TXFIFO_EMPTY
 | |
| #define SPI_TXFIFO_OVFL     INT_TXFIFO_OVERFLOW
 | |
| 
 | |
| #define SPI_DEFAULT_FRAM_SIZE   SPI_DFRAME_SIZE_8
 | |
| #define SPI_DEFAULT_FRQ         DEVICE_SPI_DEFAULT_FREQUENCY
 | |
| #define SPI_DEFAULT_RX_THR      DEVICE_SPI_DEFAULT_RX_THRESHOULD
 | |
| #define SPI_DEFAULT_TX_THR      DEVICE_SPI_DEFAULT_TX_THRESHOULD
 | |
| #define SPI_DEFAULT_CS_EN       DEVICE_SPI_DEFAULT_CS_EN
 | |
| 
 | |
| #define SPI_INT_MASK            (0x3FF)
 | |
| typedef struct spi_opr_entity
 | |
| {
 | |
|     int dev_cnt;
 | |
|     STATUS (*config)(int, spi_cfg*, tm_cfg*, sdma_cfg*);
 | |
|     STATUS (*reset)(int);
 | |
|     int (*get)(int);
 | |
|     STATUS (*put)(int, int);
 | |
|     STATUS (*set_int_enable)(int, int);
 | |
|     STATUS (*set_int_disable)(int, int);
 | |
|     STATUS (*clear_int)(int, int);
 | |
|     int (*get_int_status)(int);
 | |
|     int (*get_int_raw_status)(int);
 | |
|     int (*rx_fifo_empty)(int);
 | |
|     int (*rx_fifo_frame_rcvd_num)(int);
 | |
|     int (*tx_fifo_full)(int);
 | |
|     int (*tx_fifo_frame_rest_num)(int);
 | |
|     int (*tx_fifo_empty)(int);
 | |
|     STATUS (*get_sig_info)(int, gpio_sig_info_t *);
 | |
|     STATUS (*get_dev_by_vec_num)(unsigned int vec_num, int *dev);
 | |
|     STATUS (*get_vec_num_by_dev)(int dev, unsigned int *vec_num);
 | |
|     /* return value is invalidity */
 | |
|     int (*check_dev_invalidity)(int);
 | |
| }spi_opr;
 | |
| 
 | |
| #ifdef INCLUDE_DW_APB_SSI
 | |
| extern const spi_opr dw_ssi_ctrl;
 | |
| #define SPI_OPR_ENTRY   (&dw_ssi_ctrl)
 | |
| #endif
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| 
 | |
| #endif
 |