testbianhua

来自「这是一个基于nec78f8024的led驱动程序」· 代码 · 共 74 行

TXT
74
字号
#include "testmacrodriver.h"
#include "testANI.h"
#include "testANI_user.h"

/*
**-----------------------------------------------------------------------------
**
**  function name:
**  	ANI0_init
**
**  Parameters:
**  	void
**
**  Returns:
**  	void
**
**-----------------------------------------------------------------------------
*/ 
void testbian_init(void) 
{
	/* case comparator operation disabled */
	if (ADCE == BIT_CLR) {
		/* stops conversion operation */
		ADCS = BIT_CLR;
		/* ADM set initialize value */
		ADM = ADM_INIT_VALUE;
		/* between P20 to P23 are used as analog input port */
		ADPC = ADPC_INIT_VALUE;
	}

	/* port mode of analog input channel 0 is set to the input port */
	PORT_MODE_ANALOG_0 = INPUT;
}

/*
**-----------------------------------------------------------------------------
**
**  function name:
**  	ANI0_getValue
**
**  Parameters:
**  	void
**
**  Returns:
**  	short
**
**-----------------------------------------------------------------------------
*/
short ANI0_getValue(void)
{
	short shRetValue;
	
	/* the analog input channel specified for 0 */
	AD_CONVERT_CHANNEL = 0;
	/* enables conversion operation */
	ADCS = BIT_SET;

	/* wait for the A/D conversion completion */
	while (ADIF == BIT_CLR);

	/* take out the conversion value */
	shRetValue = ADCRH;

	/* disables conversion operation */
	ADCS = BIT_CLR;
	/* clear the A/D conversion interrupt request flag */
	ADIF = BIT_CLR;

	/* return the conversion value */
	return shRetValue;
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?