csl_sar.h
Go to the documentation of this file.
00001 /*  ============================================================================
00002  *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2008
00003  *
00004  *   Use of this software is controlled by the terms and conditions found in the
00005  *   license agreement under which this software has been supplied.
00006  *  ============================================================================
00007  */
00008 
00016 /* ============================================================================
00017  * Revision History
00018  * ================
00019  * 22-Sept-2008 Added a new API function - SAR_getStatus()
00020  * ============================================================================
00021  */
00022 
00035 #ifndef _CSL_SAR_H_
00036 #define _CSL_SAR_H_
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 /* Header Files */
00043 #include <cslr.h>
00044 #include <soc.h>
00045 #include <csl_error.h>
00046 #include <csl_types.h>
00047 #include <csl_general.h>
00048 
00049 
00071 /*****************************************************************************\
00072           SAR global macro declarations
00073 \*****************************************************************************/
00074 
00076 #define CSL_SAR_MAX_CLKDIV 127
00077 
00079 #define CSL_SAR_NUM_CHANNEL 6
00080 
00082 #define CSL_SAR_NUM_GPAIN   4
00083 
00085 # define CSL_SAR_ADC_BUSY  1
00086 
00088 # define CSL_SAR_DATA_AVAILABLE  0
00089 
00091 # define CSL_SAR_ADC_START  1
00092 
00094 #define CSL_SAR_OPEN  1
00095 
00097 #define CSL_SAR_CLOSE  0
00098 
00099 
00103 /**************************************************************************\
00104 * SAR global typedef declarations                                         *
00105 \**************************************************************************/
00106 
00111 typedef enum {
00113     CSL_SAR_CHAN_0   = 0,
00115     CSL_SAR_CHAN_1  =  1,
00117     CSL_SAR_CHAN_2  =  2,
00119     CSL_SAR_CHAN_3  =  3,
00121     CSL_SAR_CHAN_4  =  4,
00123     CSL_SAR_CHAN_5  =  5,
00125     CSL_SAR_NO_CHAN =  6
00126    } CSL_SarChanSel;
00127 
00128 
00129 
00132 typedef enum {
00134     CSL_SAR_POLLING   = 0,
00136     CSL_SAR_INTERRUPT = 1,
00138      CSL_SAR_DMA      = 2
00139    } CSL_SarOpMode;
00140 
00141 
00145 typedef enum {
00147     CSL_SAR_CONTINUOUS_CONVERSION = 0,
00149      CSL_SAR_SINGLE_CONVERSION    = 1
00150    } CSL_SarChanCyc;
00151 
00155 typedef enum {
00157      CSL_SAR_NO_DISCHARGE   = 0,
00159     CSL_SAR_DISCHARGE_ARRAY = 1
00160 } CSL_SarMultiCh;
00161 
00162 
00165 typedef enum {
00167     CSL_SAR_REF_0_8v = 0,
00169     CSL_SAR_REF_1v   = 1 ,
00171     CSL_SAR_REF_VIN  = 2
00172 } CSL_RefVoltage;
00173 
00174 
00177 typedef enum {
00179     CSL_SAR_GPO_0 = 0,
00181     CSL_SAR_GPO_1 = 1,
00183     CSL_SAR_GPO_2 = 2,
00185     CSL_SAR_GPO_3 = 3
00186 } CSL_SarGPOPinSel;
00187 
00188 
00191 typedef enum {
00193  CSL_SAR_GPO_IN  = 0,
00195  CSL_SAR_GPO_OUT = 1
00196 } CSL_SarGPODir;
00197 
00200 typedef enum
00201 {
00203  CSL_KEYPAD_MEAS        = 0,
00205  CSL_BATTRY_MEAS        = 1,
00207  CSL_INT_VOLT_MEAS      = 2,
00209  CSL_VOLUME_CTRL        = 3,
00211  CSL_TOUCH_SCREEN_XAXIS = 4,
00213  CSL_TOUCH_SCREEN_YAXIS = 5,
00215  CSL_PEN_PRESS_DOWN     = 6
00216 }CSL_SARMeasParam;
00217 
00218 
00229 typedef struct {
00231     Uint16 SysClkDiv;
00234     CSL_SarOpMode OpMode;
00237     CSL_SarMultiCh MultiCh;
00239     CSL_RefVoltage RefVoltage;
00240  } CSL_SarChSetup;
00241 
00245 typedef struct{
00247     CSL_SarRegsOvly baseAddr;
00249     Uint16 chanNo;
00251     Uint16 status;
00252 }CSL_SarHandleObj;
00253 
00255 typedef CSL_SarHandleObj*  SAR_Handle;
00256 
00260 typedef struct{
00262     volatile Uint16 SARCTRL;
00264     volatile Uint16 SARCLKCTRL;
00266     volatile Uint16 SARPINCTRL;
00268     volatile Uint16 SARGPOCTRL;
00269 }CSL_SarChConfig;
00270 
00274 /*******************************************************************************
00275  * SAR function declarations
00276  ******************************************************************************/
00277 
00307 CSL_Status SAR_init(
00308     void
00309 );
00310 
00311 
00337 CSL_Status SAR_deInit (
00338    void
00339 );
00340 
00341 
00385 CSL_Status SAR_chanOpen (
00386 CSL_SarHandleObj* Sarobj,
00387 CSL_SarChanSel   chanSel
00388     );
00389 
00390 
00431 CSL_Status SAR_chanClose (
00432     CSL_SarHandleObj        *hsar
00433 );
00434 
00435 
00436 
00480 CSL_Status  SAR_chanInit(
00481 SAR_Handle      hSar
00482  );
00483 
00528 CSL_Status SAR_chanConfig (
00529     CSL_SarHandleObj            *pSarHandle,
00530     CSL_SarChConfig             *pConfigParam
00531 );
00532 
00573 CSL_Status SAR_getConfig (
00574     CSL_SarHandleObj            *pSarHandle,
00575     CSL_SarChConfig             *pConfigParam
00576 );
00577 
00618 CSL_Status SAR_chanSetup(
00619     CSL_SarHandleObj            *pSarHandle,
00620     CSL_SarChSetup              *pSarParam
00621 );
00622 
00623 
00624 
00669 CSL_Status SAR_chanCycSet (
00670     CSL_SarHandleObj          *hSar,
00671     CSL_SarChanCyc            cycSelect
00672 );
00673 
00709 CSL_Status SAR_startConversion (
00710     CSL_SarHandleObj        *hSar
00711     );
00712 
00747 CSL_Status SAR_stopConversion (
00748     CSL_SarHandleObj    *hSar
00749    );
00750 
00793 CSL_Status SAR_A2DMeasParamSet (
00794     CSL_SarHandleObj            *hSar,
00795     CSL_SARMeasParam            param,
00796     CSL_SarChanSel*             chanNo
00797 );
00798 
00843 CSL_Status SAR_readData (
00844     CSL_SarHandleObj    *hSar,
00845     Uint16              *buffer
00846 );
00847 
00848 
00889 CSL_Status SAR_GPODirSet (
00890     CSL_SarHandleObj            *hSar,
00891     CSL_SarGPOPinSel             Index,
00892     CSL_SarGPODir                dir
00893   );
00894 
00895 
00896 
00897 
00945 Bool SAR_getStatus(
00946     CSL_SarHandleObj            *hSar,
00947     CSL_Status                  *status
00948    );
00949 
00950 
00954 #ifdef __cplusplus
00955 }
00956 #endif
00957 
00958 #endif /* _CSL_SAR_H_ */
00959