1 /*
2  * Copyright (C) 2017-2019 Alibaba Group Holding Limited
3  */
4 
5 /******************************************************************************
6  * @file     drv_spu.h
7  * @brief    header file for spu driver
8  * @version  V1.0
9  * @date     02. June 2017
10  * @model    spu
11  ******************************************************************************/
12 
13 #ifndef _CSI_spu_H_
14 #define _CSI_spu_H_
15 
16 
17 #include <drv/common.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 /// definition for spu handle.
23 typedef void *spu_handle_t;
24 
25 /****** spu specific error codes *****/
26 typedef enum {
27     EDRV_SPU_INST_OVERFLOW  = (DRV_ERROR_SPECIFIC + 1), ///< INST_RAM size not enough
28     EDRV_SPU_PROG_OVERFLOW,  ///<PROG_RAM size not enough
29 } drv_spu_error_e;
30 
31 /**
32 \brief spu Driver Capabilities.
33 */
34 typedef struct  {
35     uint32_t spu_usart        : 1; ///< supports usart device
36     uint32_t spu_spi          : 1; ///< spuports spi device
37     uint32_t spu_iic          : 1; ///< supports iic device
38     uint32_t spu_can          : 1; ///< supports can device
39     uint32_t spu_i2s          : 1; ///< supports i2s device
40 } spu_capabilities_t;
41 
42 /**
43   \brief       Get driver capabilities.
44   \param[in]   handle  spu handle to operate.
45   \return      \ref spu_capabilities_t
46 */
47 spu_capabilities_t drv_spu_get_capabilities(spu_handle_t handle);
48 
49 /**
50   \brief       Initialize spu Interface. Initializes the resources needed for the spu interface
51   \param[in]   idx spu index
52   \param[in]   num spu pin number, a maximum of 32
53   \return      return spu handle if success
54 */
55 spu_handle_t drv_spu_initialize(int32_t idx);
56 
57 /**
58   \brief       De-initialize spu Interface. stops operation and releases the software resources used by the interface
59   \param[in]   handle  spu handle to operate.
60   \return      error code
61 */
62 int32_t drv_spu_uninitialize(spu_handle_t handle);
63 
64 /**
65   \brief       config spu mode.
66   \param[in]   handle  spu handle to operate.
67   \param[in]   capabilities type of device that SPU supports(uart/spi/i2c/can)
68   \return      error code
69 */
70 int32_t drv_spu_config(spu_handle_t handle, spu_capabilities_t capabilities);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* _CSI_spu_H_ */
77