📄 readtempsensor.c
字号:
/*****************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** *
* *** + 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -