⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readtempsensor.c

📁 ti-Chipcon CC1010 1G以下Soc源码库。包括rf,powermodes,clockmodes,flashRW,interrupts,timer,pwm,uart...所有底层驱动源码
💻 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 + -