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

📄 readpotsensor.c

📁 ti-Chipcon CC1010 1G以下Soc源码库。包括rf,powermodes,clockmodes,flashRW,interrupts,timer,pwm,uart...所有底层驱动源码
💻 C
字号:
/*****************************************************************************
 *                                                                           *
 *        **********                                                         *
 *       ************                                                        *
 *      ***        ***                                                       *
 *      ***   +++   ***                                                      *
 *      ***   + +   ***                                                      *
 *      ***   +                            CHIPCON CC1010                    *
 *      ***   + +   ***                 HAL - ReadPotSensor                  *
 *      ***   +++   ***                                                      *
 *      ***       ***                                                        *
 *       ***********                                                         *
 *        *********                                                          *
 *                                                                           *
 *****************************************************************************
 * Reads the CC1010EB potentiometer sensor.                                  *
 *****************************************************************************
 * Author:              TOS                                                  *
 *****************************************************************************
 * Revision history:                                                         *
 *                                                                           *
 * $Log: ReadPotSensor.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 halReadPotSensor(...)
//
//  Description:
//      This function reads the CC1010EB potentiometer sensor from AD0 pin.
//  Arguments:
//      void
//  Return value:
//      word
//          10 bit sample from AD0
//----------------------------------------------------------------------------
word halReadPotSensor(void) {
    word val;

    // Configure ADC for potentiometer reading
    halConfigADC(ADC_MODE_SINGLE | ADC_REFERENCE_VDD, CC1010EB_CLKFREQ, 0);
    ADC_POWER(TRUE);

    // Wait for ADC to stabilize
    halWait(1, CC1010EB_CLKFREQ);

    // Select potentiometer input and read sample
    ADC_SELECT_INPUT(ADC_INPUT_AD0);
    ADC_SAMPLE_SINGLE();
    val = ADC_GET_SAMPLE_10BIT();

    return val;
}    

⌨️ 快捷键说明

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