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.

67 lines
2.3 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd. 2020-2022. All rights reserved.
* Description: virtualkeypad input lsadc interface
* Author: App-Dev Group
* Create: 2020-06-15
*/
#ifndef ANDROID_LSADCINTERFACE_H
#define ANDROID_LSADCINTERFACE_H
#include <vector>
#include <td_type.h>
#include <log/log.h>
#include <securec.h>
#include "uapi_version.h"
#include "uapi_lsadc.h"
#include "uapi_pdm.h"
#include "uapi_pmoc.h"
#define LSADC_INTERFACE_LOG(...) android_printLog(ANDROID_LOG_DEBUG, "virtualkeypad", __VA_ARGS__)
#if (UAPI_VERSION_CODE == UAPI_VERSION(1, 0))
using LSADC_Config = uapi_lsadc_config;
#define LSADC_CHAN_MASK(config) ((config)->channel_mask)
#endif
namespace android {
class LsadcInterface {
public:
LsadcInterface(){}
~LsadcInterface(){}
struct LsadcConfig {
td_u32 channelMask = 0;
td_u32 activeBit = 0;
td_u32 dataDelta = 0;
td_u32 deglitchBypass = 0;
td_u32 glitchSample = 0;
td_u32 lsadcReset = 0;
td_u32 lsadcZero = 0;
td_u32 modelSel = 0;
td_u32 powerDownMod = 0;
td_u32 timeScan = 0;
};
td_s32 LsadcInit() const;
td_s32 LsadcDeinit() const;
td_s32 LsadcGetValue(td_u32 channel, td_u32& value) const;
td_s32 LsadcGetConfig(LSADC_Config& config) const;
td_s32 LsadcSetConfig(LSADC_Config& config) const;
void LsadcStructConfig(LSADC_Config& config, LsadcConfig& tempConfig) const;
void LsadcPowerKeySet(const std::vector<td_u8> powerKey, const td_u32 length, const td_u32 keyNum,
const td_u32 channelMask);
private:
td_u32 lsadcThresholdCoordinate = 0x10;
td_u32 lsadcMinThreshold = 0x5;
const int powerKeyNum = 32;
const int powerKeySIZE = 2;
const int keypadPowerKeyOffset = 16;
td_u32 LsadcPmocPowerKeySet(const std::vector<td_u8>& powerKey, const td_u32 length, const td_u32 keyNum,
const td_u32 channelMask);
td_u32 LsadcPdmPowerKeySet(const std::vector<td_u8> powerKey, const td_u32 length, const td_u32 keyNum,
const td_u32 channelMask);
};
}
#endif // android_LsadcInterface_H