📄 tetsani0.bak
字号:
/*
*******************************************************************************
** COPYRIGHT (C) NEC Electronics Corporation 2008
** NEC ELECTRONICS CONFIDENTIAL AND PROPRIETARY
** All rights reserved by NEC Electronics Corporation.
** Use of copyright notice does not evidence publication.
**
** Filename : ANI0.c
** Abstract : This file implements device driver for
** analog input module.(for analog input channel-0)
**
** Device : uPD78F8024
**
** Compiler : NEC/CC78K0
**
*******************************************************************************
*/
/*
*******************************************************************************
** Include files
*******************************************************************************
*/
#include "testmacrodriver.h"
#include "testANI.h"
#include "testANI_user.h"
/*
**-----------------------------------------------------------------------------
**
** function name:
** ANI0_init
**
** Parameters:
** void
**
** Returns:
** void
**
**-----------------------------------------------------------------------------
*/
void ANI0_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_1 = 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -