📄 drvsar.c
字号:
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006-2007 MStar Semiconductor, Inc.
// All rights reserved.
//
// Unless otherwise stipulated in writing, any and all information contained
// herein regardless in any format shall remain the sole proprietary of
// MStar Semiconductor Inc. and be kept in strict confidence
// (¨MStar Confidential Information〃) by the recipient.
// Any unauthorized act including without limitation unauthorized disclosure,
// copying, use, reproduction, sale, distribution, modification, disassembling,
// reverse engineering and compiling of the contents of MStar Confidential
// Information is unlawful and strictly prohibited. MStar hereby reserves the
// rights to any and all damages, losses, costs and expenses resulting therefrom.
//
// Description: SAR setting Module
//
///////////////////////////////////////////////////////////////////////////////
#define DRVSAR_C
#include <intrins.h>
#include <string.h>
#include "R8051XC.h"
#include "datatype.h"
#include "hwreg.h"
#include "Board.h"
#include "sysinfo.h"
#include "drvserflash_db.h"
#include "drvsys.h"
#include "Bin_ID.h"
#include "drvmiu.h"
#include "drvSAR.h"
#include "drvGlobal.h"
#include "panel.h"
#define SAR_DEBUGINFO(x) x
void drvInitialSAR(void)
{
//SAR clock Divder
XBYTE[0x3A13] = 0xF1;
XBYTE[0x3A12] = 0x00;
//test select, not used.
XBYTE[0x3A11] = 0xF2;
XBYTE[0x3A10] = 0x00;
//SAR config. start/reset.
XBYTE[REG_SAR_CTRL0] = 0xA0;
XBYTE[REG_SAR_CTRL1] = 0x02;
XBYTE[REG_SAR_CTRL2] = 0x05;
XBYTE[REG_SAR_CTRL3] = 0x00;
//Select PIN_SAR as SAR input, Enable SAR Function
XBYTE[REG_SAR_CTRL20] = 0xFF;
XBYTE[REG_SAR_CTRL21] = 0x80;
//change PIN_SAR3 as SAR3 input
XBYTE[0x1EAF] |= 0x01;
// Enable SAR4
XBYTE[0x1EA4] |= 0x01;
}
/******************************************************************************/
///Keypad get ADC Channel value
///@param pkey \b IN ADC Channel
///@param pflag \b IN Pointer to the ADC Channel value
/******************************************************************************/
BOOLEAN drvSAR_Get_ADC_Channel(BYTE Channel, WORD *pvalue)
{
U8 u8Status = 0;
WORD i = 0;
switch(Channel)
{
#if (SAR_REOLUTION_SEL == RESOLUTION_IT_10BIT)
case SAR_ADC_CHANNEL_1:
i = (XBYTE[REG_SAR_ADCOUT1] * 4) + (XBYTE[REG_SAR_ADCOUT1+1] & 0x03);
*pvalue = i;
break;
case SAR_ADC_CHANNEL_2:
i = (XBYTE[REG_SAR_ADCOUT2] * 4) + (XBYTE[REG_SAR_ADCOUT2+1] & 0x03);
*pvalue = i;
break;
case SAR_ADC_CHANNEL_3:
i = (XBYTE[REG_SAR_ADCOUT3] * 4) + (XBYTE[REG_SAR_ADCOUT3+1] & 0x03);
*pvalue = i;
break;
case SAR_ADC_CHANNEL_4:
i = (XBYTE[REG_SAR_ADCOUT4] * 4) + (XBYTE[REG_SAR_ADCOUT4+1] & 0x03);
*pvalue = i;
break;
case SAR_ADC_CHANNEL_5:
i = (XBYTE[REG_SAR_ADCOUT5] * 4) + (XBYTE[REG_SAR_ADCOUT5+1] & 0x03);
*pvalue = i;
break;
default:
u8Status = 1;
*pvalue = 0x03FF;
break;
#else
case SAR_ADC_CHANNEL_1:
*pvalue = XBYTE[REG_SAR_ADCOUT1];
break;
case SAR_ADC_CHANNEL_2:
*pvalue = XBYTE[REG_SAR_ADCOUT2];
break;
case SAR_ADC_CHANNEL_3:
*pvalue = XBYTE[REG_SAR_ADCOUT3];
break;
case SAR_ADC_CHANNEL_4:
*pvalue = XBYTE[REG_SAR_ADCOUT4];
break;
case SAR_ADC_CHANNEL_5:
*pvalue = XBYTE[REG_SAR_ADCOUT5];
break;
default:
u8Status = 1;
*pvalue = 0xFF;
break;
#endif
}
return u8Status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -