1 /*
2  * Copyright (C) 2017-2019 Alibaba Group Holding Limited
3  */
4 
5 /******************************************************************************
6  * @file     drv_etb.h
7  * @brief    header file for event trigger driver
8  * @version  V1.0
9  * @date     27. octorber 2017
10  * @model    etb
11  ******************************************************************************/
12 
13 #ifndef _DRV_ETB_H_
14 #define _DRV_ETB_H_
15 
16 #include <drv/common.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 typedef enum {
23     ETB_HARDWARE_TRIG  = 0,           ///< etb channel inout is hardware trigger.
24     ETB_SOFTWARE_TRIG                 ///< etb channel inout is software trigger.
25 } csi_etb_trig_mode_t;
26 
27 typedef enum {
28     ETB_CH_ONE_TRIGGER_ONE  = 0,      ///< one device trig one deivce
29     ETB_CH_ONE_TRIGGER_MORE,          ///< one device trig two for more device
30     ETB_CH_MORE_TRIGGER_ONE           ///< two or more device trig one deivce
31 } csi_etb_ch_type_t;
32 
33 typedef struct {
34     uint8_t               src_ip;     ///< a specific number represent a location in an source trigger location map to trigger other ip(s).
35     uint8_t               dst_ip;     ///< a specific number represent an location in an dest trigger map to wait signal(s) from source ip(s) or location(s).
36     csi_etb_trig_mode_t   trig_mode;  ///< the input source is hardware trigger or software trigger.
37     csi_etb_ch_type_t     ch_type;    ///< channel type
38 } csi_etb_config_t;
39 
40 /**
41   \brief       Init the etb device
42   \return      error code
43 */
44 csi_error_t csi_etb_init(void);
45 
46 /**
47   \brief       Uninit the etb device
48   \return      none
49 */
50 void csi_etb_uninit(void);
51 
52 /**
53   \brief       alloc an etb channel
54   \param[in]   ch_mode    etb channel work mode
55   \return      channel id or CSI_ERROR
56 */
57 int32_t csi_etb_ch_alloc(csi_etb_ch_type_t ch_type);
58 
59 /**
60   \brief       free an etb channel
61   \param[in]   ch_id      etb channel work mode
62   \return      none
63 */
64 void csi_etb_ch_free(int32_t ch_id);
65 
66 /**
67   \brief       config etb channel
68   \param[in]   ch_id      etb channel id
69   \param[in]   config     the config structure for etb channel
70   \return      csi error code
71 */
72 csi_error_t csi_etb_ch_config(int32_t ch_id, csi_etb_config_t *config);
73 
74 /**
75   \brief       start an etb channel
76   \param[in]   ch_id      etb channel id
77   \return      none
78 */
79 void csi_etb_ch_start(int32_t ch_id);
80 
81 /**
82   \brief       stop an etb channel
83   \param[in]   etb        etb channel id
84   \return      none
85 */
86 void csi_etb_ch_stop(int32_t ch_id);
87 
88 #endif /* _CSI_ETB_H_ */
89