?? adc.h
字號:
#ifdef CC1110
#include "ioCC1110.h"
#endif
#ifdef CC2510
#include "ioCC2510.h"
#endif
#include "config.h"
/******************************************************************************
******************* ADC macros/functions *******************
*******************************************************************************
These functions/macros simplifies usage of the ADC.
******************************************************************************/
#define CLKSPD (CLKCON & 0x07)
// Macro for setting up a single conversion. If ADCCON1.STSEL = 11, using this
// macro will also start the conversion.
#define ADC_SINGLE_CONVERSION(settings) \
do{ ADCCON3 = (settings); }while(0)
// Macro for setting up a single conversion
#define ADC_SEQUENCE_SETUP(settings) \
do{ ADCCON2 = (settings); }while(0)
// Where _settings_ are the following:
// Reference voltage:
#define ADC_REF_1_25_V 0x00 // Internal 1.25V reference
#define ADC_REF_P0_7 0x40 // External reference on AIN7 pin
#define ADC_REF_AVDD 0x80 // AVDD_SOC pin
#define ADC_REF_P0_6_P0_7 0xC0 // External reference on AIN6-AIN7 differential input
// Resolution (decimation rate):
#define ADC_8_BIT 0x00 // 64 decimation rate
#define ADC_10_BIT 0x10 // 128 decimation rate
#define ADC_12_BIT 0x20 // 256 decimation rate
#define ADC_14_BIT 0x30 // 512 decimation rate
// Input channel:
#define ADC_AIN0 0x00 // single ended P0_0
#define ADC_AIN1 0x01 // single ended P0_1
#define ADC_AIN2 0x02 // single ended P0_2
#define ADC_AIN3 0x03 // single ended P0_3
#define ADC_AIN4 0x04 // single ended P0_4
#define ADC_AIN5 0x05 // single ended P0_5
#define ADC_AIN6 0x06 // single ended P0_6
#define ADC_AIN7 0x07 // single ended P0_7
#define ADC_GND 0x0C // Ground
#define ADC_TEMP_SENS 0x0E // on-chip temperature sensor
#define ADC_VDD_3 0x0F // (vdd/3)
//-----------------------------------------------------------------------------
// Macro for starting the ADC in continuous conversion mode
#define ADC_SAMPLE_CONTINUOUS() do { ADCCON1 &= ~0x30; ADCCON1 |= 0x10; } while (0)
// Macro for stopping the ADC in continuous mode (and setting the ADC to be
// started manually by ADC_SAMPLE_SINGLE() )
#define ADC_STOP() do { ADCCON1 |= 0x30; } while (0)
// Macro for initiating a single sample in single-conversion mode (ADCCON1.STSEL = 11).
#define ADC_SAMPLE_SINGLE() do { ADC_STOP(); ADCCON1 |= 0x40; } while (0)
// Macro for configuring the ADC to be started from T1 channel 0. (T1 ch 0 must be in compare mode!!)
#define ADC_TRIGGER_FROM_TIMER1() do { ADC_STOP(); ADCCON1 &= ~0x10; } while (0)
// Expression indicating whether a conversion is finished or not.
#define ADC_SAMPLE_READY() (ADCCON1 & 0x80)
// Macro for setting/clearing a channel as input of the ADC
#define ADC_ENABLE_CHANNEL(ch) ADCCFG |= (0x01<<ch)
#define ADC_DISABLE_CHANNEL(ch) ADCCFG &= ~(0x01<<ch)
/******************************************************************************
* @fn halAdcSampleSingle
*
* @brief
* This function makes the adc sample the given channel at the given
* resolution with the given reference.
*
* Parameters:
*
* @param BYTE reference
* The reference to compare the channel to be sampled.
* BYTE resolution
* The resolution to use during the sample (8, 10, 12 or 14 bit)
* BYTE input
* The channel to be sampled.
*
* @return INT16
* The conversion result
*
******************************************************************************/
INT16 halAdcSampleSingle(BYTE reference, BYTE resolution, UINT8 input);
void halWait(BYTE wait);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -