You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
3.8 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd. 2012-2020. All rights reserved.
* Description: The iapi interfaces of lsadc
* Author: Hisilicon
* Created Date: 2014-02-08
* Updated Date: 2019-11-19
*/
#ifndef __UAPI_LSADC_H__
#define __UAPI_LSADC_H__
#include "td_type.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
/* ************************** Structure Definition *************************** */
/* * \addtogroup LSADC */
/* * @{ */ /* * <!-- [LSADC] */
/* LSADC configure parameters */
typedef struct {
/*
* <channel_mask>: 1 - Enable,0 - Disable.
* 0x1:Channel-0, 0x2:Channel-1, 0x4:Channel-2, 0x8:Channel-3
* System is opening all supportd channel by default.
* Pinmux and io_config should be configured before using a channel
*/
td_u32 channel_mask;
/*
* <active_bit>:Lsadc Conversion Result Aaccuracy.
* Example: 0xFC(0b11111100) Indicates 6 bits valid in LSADC Scan Date.
*/
td_u32 active_bit;
/*
* <data_delta>:LSADC conversion error range
* The two conversion results are identified as the same if they are within the error range.
*/
td_u32 data_delta;
/*
* <deglitch_bypass>:LSADC deglitch function: 1 - bypass, 0 - enable.
*/
td_u32 deglitch_bypass;
td_u32 lsadc_reset;
/*
* <power_down_mod>:1 - Support,0 - Not Support.
*/
td_u32 power_down_mod;
/*
* <model_sel>:0 - anodic scanning; 1 - continuous scanning.
*/
td_u32 model_sel;
/*
* <lsadc_zero>:The lsadc digital value when no analog signal input.
*/
td_u32 lsadc_zero;
/*
* <glitch_sample>:Time Window of deglitch.
* When the conversion of LSADC remains unchanged in the Time Window, it is considered as an valid result.
* The duration of Time Window is (N * time_scan)
*/
td_u32 glitch_sample;
/*
* <time_scan>:Basic Duration between Two Scan (cycle, freq is 3MHz).
* The actually duration between two scan is (glitch_sample + 1) * time_scan
* For example, time_scan = 300, glitch_sample = 9, 1 channal is enabled.
* If you hold button downing, the lsadc digital value will be catched every (9+1)*300 = 3000cycle = 1000us.
*/
td_u32 time_scan;
} uapi_lsadc_config;
/* * @} */ /* * <!-- ==== Structure Definition end ==== */
/* ****************************** API declaration **************************** */
/* * \addtogroup LSADC */
/* * @{ */ /* * <!-- [LSADC] */
/* *
\brief Init lsadc iapi function.
\attention N/A
\param N/A
\retval TD_SUCCESS success.
\retval please refer to the error code of mpi.
\see N/A
*/
td_s32 uapi_lsadc_init(void);
/* *
\brief Deinit lsadc iapi function.
\attention N/A
\param N/A
\retval TD_SUCCESS success.
\retval please refer to the error code of mpi
\see N/A
*/
td_s32 uapi_lsadc_deinit(void);
/* *
\brief Set the configuration of the LSADC device.
\attention N/A
\param[in] config: The pointer of the lsadc configuration's structure.
\retval TD_SUCCESS success
\retval please refer to the error code of mpi.
\see N/A
*/
td_s32 uapi_lsadc_set_config(const uapi_lsadc_config *config);
/* *
\brief Get the configuration of the LSADC device.
\attention N/A
\param[out] config: The pointer of the lsadc configuration's structure.
\retval TD_SUCCESS success.
\retval please refer to the error code of mpi.
\see N/A
*/
td_s32 uapi_lsadc_get_config(uapi_lsadc_config *config);
/* *
\brief Get the value of the appointed channel of the LSADC device.
\attention \n
\param[in] channel: The channel of LSADC device.
\param[out] value: The pointer of the value data.
\retval TD_SUCCESS success.
\retval please refer to the error code of mpi.
\see \n
*/
td_s32 uapi_lsadc_get_value(td_u32 channel, td_u32 *value);
/* ==== API declaration end ==== */
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* __UAPI_LSADC_H__ */