1 /* 2 * Copyright (C) 2017-2024 Alibaba Group Holding Limited 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /****************************************************************************** 20 * @file drv_etb.h 21 * @brief header file for event trigger driver 22 * @version V1.0 23 * @date 27. octorber 2017 24 * @model etb 25 ******************************************************************************/ 26 27 #ifndef _DRV_ETB_H_ 28 #define _DRV_ETB_H_ 29 30 #include <drv/common.h> 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 typedef enum { 37 ETB_HARDWARE_TRIG = 0, ///< etb channel inout is hardware trigger. 38 ETB_SOFTWARE_TRIG ///< etb channel inout is software trigger. 39 } csi_etb_trig_mode_t; 40 41 typedef enum { 42 ETB_CH_ONE_TRIGGER_ONE = 0, ///< one device trig one deivce 43 ETB_CH_ONE_TRIGGER_MORE, ///< one device trig two for more device 44 ETB_CH_MORE_TRIGGER_ONE ///< two or more device trig one deivce 45 } csi_etb_ch_type_t; 46 47 typedef struct { 48 uint8_t src_ip; ///< a specific number represent a location in an source trigger location map to trigger other ip(s). 49 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). 50 csi_etb_trig_mode_t trig_mode; ///< the input source is hardware trigger or software trigger. 51 csi_etb_ch_type_t ch_type; ///< channel type 52 } csi_etb_config_t; 53 54 /** 55 \brief Init the etb device 56 \return error code 57 */ 58 csi_error_t csi_etb_init(void); 59 60 /** 61 \brief Uninit the etb device 62 \return none 63 */ 64 void csi_etb_uninit(void); 65 66 /** 67 \brief alloc an etb channel 68 \param[in] ch_mode etb channel work mode 69 \return channel id or CSI_ERROR 70 */ 71 int32_t csi_etb_ch_alloc(csi_etb_ch_type_t ch_type); 72 73 /** 74 \brief free an etb channel 75 \param[in] ch_id etb channel work mode 76 \return none 77 */ 78 void csi_etb_ch_free(int32_t ch_id); 79 80 /** 81 \brief config etb channel 82 \param[in] ch_id etb channel id 83 \param[in] config the config structure for etb channel 84 \return csi error code 85 */ 86 csi_error_t csi_etb_ch_config(int32_t ch_id, csi_etb_config_t *config); 87 88 /** 89 \brief start an etb channel 90 \param[in] ch_id etb channel id 91 \return none 92 */ 93 void csi_etb_ch_start(int32_t ch_id); 94 95 /** 96 \brief stop an etb channel 97 \param[in] etb etb channel id 98 \return none 99 */ 100 void csi_etb_ch_stop(int32_t ch_id); 101 102 #endif /* _CSI_ETB_H_ */ 103