1 /* 2 * Copyright (C) 2017-2019 Alibaba Group Holding Limited 3 */ 4 5 6 /****************************************************************************** 7 * @file drv_acmp.h 8 * @brief Header File for acmp Driver 9 * @version V1.0 10 * @date 02. June 2017 11 * @model acmp 12 ******************************************************************************/ 13 #ifndef _CSI_ACMP_H_ 14 #define _CSI_ACMP_H_ 15 16 17 #include <stdint.h> 18 #include <drv/errno.h> 19 #include <drv/common.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /****** acmp specific error codes *****/ 26 #define ACMP_ERROR_MODE (DRV_ERROR_SPECIFIC + 1) ///< Specified Mode not supported 27 28 /// definition for acmp handle. 29 typedef void *acmp_handle_t; 30 31 /*----- acmp Control Codes: Mode -----*/ 32 typedef enum { 33 ACMP_MODE_FAST = 0, ///< fast mode 34 ACMP_MODE_SLOW, ///< slow mode 35 } acmp_mode_e; 36 37 /** 38 \brief acmp Status 39 */ 40 typedef struct { 41 uint32_t output_state : 1; ///< Analog comparator outputs 0 or 1 42 } acmp_status_t; 43 44 /** 45 \brief acmp Device Driver Capabilities. 46 */ 47 typedef struct { 48 uint32_t fast_mode : 1; ///< supports fast mode 49 uint32_t slow_mode : 1; ///< supports slow mode 50 uint32_t hysteresis_fun : 1; ///< supports Programming Hysteresis 51 } acmp_capabilities_t; 52 53 54 /** 55 \brief Initialize acmp Interface. 1. Initializes the resources needed for the acmp interface 2.registers event callback function 56 \param[in] idx device id 57 \param[in] cb_event event callback function \ref acmp_event_cb_t 58 \return return acmp handle if success 59 */ 60 acmp_handle_t drv_acmp_initialize(int32_t idx); 61 62 /** 63 \brief De-initialize acmp Interface. stops operation and releases the software resources used by the interface 64 \param[in] handle acmp handle to operate. 65 */ 66 void drv_acmp_uninitialize(acmp_handle_t handle); 67 68 /** 69 \brief control acmp power. 70 \param[in] handle acmp handle to operate. 71 \param[in] state power state.\ref drv_power_stat_e. 72 \return error code 73 */ 74 int32_t drv_acmp_power_control(acmp_handle_t handle, csi_power_stat_e state); 75 76 /** 77 \brief Get driver capabilities. 78 \param[in] idx device id 79 \return \ref acmp_capabilities_t 80 */ 81 acmp_capabilities_t drv_acmp_get_capabilities(int32_t idx); 82 83 /** 84 \brief config acmp mode. 85 \param[in] handle acmp handle to operate. 86 \param[in] mode \ref acmp_mode_e 87 \param[in] standard \ref acmp_standard_acmp_e 88 \return error code 89 */ 90 int32_t drv_acmp_config(acmp_handle_t handle, acmp_mode_e mode); 91 92 /** 93 \brief start comparison 94 \param[in] handle acmp handle to operate. 95 */ 96 void drv_acmp_comp_start(acmp_handle_t handle); 97 98 /** 99 \brief stop comparison. 100 \param[in] handle acmp handle to operate. 101 */ 102 void drv_acmp_comp_stop(acmp_handle_t handle); 103 104 /** 105 \brief Get acmp status. 106 \param[in] handle acmp handle to operate. 107 \return acmp status \ref acmp_status_t 108 */ 109 acmp_status_t drv_acmp_get_status(acmp_handle_t handle); 110 111 #ifdef __cplusplus 112 } 113 #endif 114 115 #endif /* _CSI_acmp_H_ */ 116 117