readtempsensor.c
来自「ti-Chipcon CC1010 1G以下Soc源码库。包括rf,powerm」· C语言 代码 · 共 62 行
C
62 行
/*****************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + CHIPCON CC1010 *
* *** + + *** HAL - ReadTempSensor *
* *** +++ *** *
* *** *** *
* *********** *
* ********* *
* *
*****************************************************************************
* Reads the temperature sensor on CC1010EM. *
*****************************************************************************
* Author: TOS *
*****************************************************************************
* Revision history: *
* *
* $Log: ReadTempSensor.c,v $
* Revision 1.1 2004/01/08 19:15:32 tos
* Initial version in CVS.
*
*
* *
****************************************************************************/
#include <chipcon/hal.h>
#include <chipcon/cc1010eb.h>
//----------------------------------------------------------------------------
// word halReadTempSensor(...)
//
// Description:
// This function reads the CC1010EM temperature sensor from AD1 pin.
// Arguments:
// void
// Return value:
// word
// 10 bit sample from AD1
//----------------------------------------------------------------------------
word halReadTempSensor(void) {
word val;
// Configure ADC for temperature reading
halConfigADC(ADC_MODE_SINGLE | ADC_REFERENCE_INTERNAL_1_25, CC1010EB_CLKFREQ, 0);
ADC_POWER(TRUE);
// Wait until ADC stabilized
halWait(1, CC1010EB_CLKFREQ);
// Select temperature input and read sample
ADC_SELECT_INPUT(ADC_INPUT_AD1);
ADC_SAMPLE_SINGLE();
val = ADC_GET_SAMPLE_10BIT();
return val;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?