00001
00034 #ifndef __SILICON_LABS_EM_ACMP_H_
00035 #define __SILICON_LABS_EM_ACMP_H_
00036
00037 #include "em_device.h"
00038 #if defined(ACMP_COUNT) && (ACMP_COUNT > 0)
00039
00040 #include <stdint.h>
00041 #include <stdbool.h>
00042
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046
00047
00052
00057
00058
00059
00060
00063 typedef enum
00064 {
00066 acmpResistor0 = _ACMP_INPUTSEL_CSRESSEL_RES0,
00068 acmpResistor1 = _ACMP_INPUTSEL_CSRESSEL_RES1,
00070 acmpResistor2 = _ACMP_INPUTSEL_CSRESSEL_RES2,
00072 acmpResistor3 = _ACMP_INPUTSEL_CSRESSEL_RES3
00073 } ACMP_CapsenseResistor_TypeDef;
00074
00077 typedef enum
00078 {
00079 acmpHysteresisLevel0 = _ACMP_CTRL_HYSTSEL_HYST0,
00080 acmpHysteresisLevel1 = _ACMP_CTRL_HYSTSEL_HYST1,
00081 acmpHysteresisLevel2 = _ACMP_CTRL_HYSTSEL_HYST2,
00082 acmpHysteresisLevel3 = _ACMP_CTRL_HYSTSEL_HYST3,
00083 acmpHysteresisLevel4 = _ACMP_CTRL_HYSTSEL_HYST4,
00084 acmpHysteresisLevel5 = _ACMP_CTRL_HYSTSEL_HYST5,
00085 acmpHysteresisLevel6 = _ACMP_CTRL_HYSTSEL_HYST6,
00086 acmpHysteresisLevel7 = _ACMP_CTRL_HYSTSEL_HYST7
00087 } ACMP_HysteresisLevel_TypeDef;
00088
00091 typedef enum
00092 {
00094 acmpWarmTime4 = _ACMP_CTRL_WARMTIME_4CYCLES,
00096 acmpWarmTime8 = _ACMP_CTRL_WARMTIME_8CYCLES,
00098 acmpWarmTime16 = _ACMP_CTRL_WARMTIME_16CYCLES,
00100 acmpWarmTime32 = _ACMP_CTRL_WARMTIME_32CYCLES,
00102 acmpWarmTime64 = _ACMP_CTRL_WARMTIME_64CYCLES,
00104 acmpWarmTime128 = _ACMP_CTRL_WARMTIME_128CYCLES,
00106 acmpWarmTime256 = _ACMP_CTRL_WARMTIME_256CYCLES,
00108 acmpWarmTime512 = _ACMP_CTRL_WARMTIME_512CYCLES
00109 } ACMP_WarmTime_TypeDef;
00110
00113 typedef enum
00114 {
00116 acmpChannel0 = _ACMP_INPUTSEL_NEGSEL_CH0,
00118 acmpChannel1 = _ACMP_INPUTSEL_NEGSEL_CH1,
00120 acmpChannel2 = _ACMP_INPUTSEL_NEGSEL_CH2,
00122 acmpChannel3 = _ACMP_INPUTSEL_NEGSEL_CH3,
00124 acmpChannel4 = _ACMP_INPUTSEL_NEGSEL_CH4,
00126 acmpChannel5 = _ACMP_INPUTSEL_NEGSEL_CH5,
00128 acmpChannel6 = _ACMP_INPUTSEL_NEGSEL_CH6,
00130 acmpChannel7 = _ACMP_INPUTSEL_NEGSEL_CH7,
00132 acmpChannel1V25 = _ACMP_INPUTSEL_NEGSEL_1V25,
00134 acmpChannel2V5 = _ACMP_INPUTSEL_NEGSEL_2V5,
00136 acmpChannelVDD = _ACMP_INPUTSEL_NEGSEL_VDD,
00137
00138 #if defined( _ACMP_INPUTSEL_NEGSEL_DAC0CH0 )
00139
00140 acmpChannelDAC0Ch0 = _ACMP_INPUTSEL_NEGSEL_DAC0CH0,
00141 #endif
00142
00143 #if defined( _ACMP_INPUTSEL_NEGSEL_DAC0CH1 )
00144
00145 acmpChannelDAC0Ch1 = _ACMP_INPUTSEL_NEGSEL_DAC0CH1,
00146 #endif
00147
00148 #if defined( _ACMP_INPUTSEL_NEGSEL_CAPSENSE )
00149
00150 acmpChannelCapSense = _ACMP_INPUTSEL_NEGSEL_CAPSENSE,
00151 #endif
00152 } ACMP_Channel_TypeDef;
00153
00154
00155
00156
00157
00159 typedef struct
00160 {
00163 bool fullBias;
00164
00167 bool halfBias;
00168
00171 uint32_t biasProg;
00172
00175 ACMP_WarmTime_TypeDef warmTime;
00176
00178 ACMP_HysteresisLevel_TypeDef hysteresisLevel;
00179
00182 ACMP_CapsenseResistor_TypeDef resistor;
00183
00186 bool lowPowerReferenceEnabled;
00187
00190 uint32_t vddLevel;
00191
00193 bool enable;
00194 } ACMP_CapsenseInit_TypeDef;
00195
00197 #define ACMP_CAPSENSE_INIT_DEFAULT \
00198 { false, \
00199 false, \
00200 0x7, \
00201 acmpWarmTime512, \
00202 acmpHysteresisLevel5, \
00203 acmpResistor3, \
00204 false, \
00205 0x3D, \
00206 true \
00207 }
00208
00210 typedef struct
00211 {
00214 bool fullBias;
00215
00218 bool halfBias;
00219
00222 uint32_t biasProg;
00223
00225 bool interruptOnFallingEdge;
00226
00228 bool interruptOnRisingEdge;
00229
00232 ACMP_WarmTime_TypeDef warmTime;
00233
00235 ACMP_HysteresisLevel_TypeDef hysteresisLevel;
00236
00238 bool inactiveValue;
00239
00242 bool lowPowerReferenceEnabled;
00243
00246 uint32_t vddLevel;
00247
00249 bool enable;
00250 } ACMP_Init_TypeDef;
00251
00253 #define ACMP_INIT_DEFAULT \
00254 { false, \
00255 false, \
00256 0x7, \
00257 false, \
00258 false, \
00259 acmpWarmTime512, \
00260 acmpHysteresisLevel5, \
00261 false, \
00262 false, \
00263 0x3D, \
00264 true \
00265 }
00266
00267
00268
00269
00270
00271
00272 void ACMP_CapsenseInit(ACMP_TypeDef *acmp, const ACMP_CapsenseInit_TypeDef *init);
00273 void ACMP_CapsenseChannelSet(ACMP_TypeDef *acmp, ACMP_Channel_TypeDef channel);
00274 void ACMP_ChannelSet(ACMP_TypeDef *acmp, ACMP_Channel_TypeDef negSel, ACMP_Channel_TypeDef posSel);
00275 void ACMP_Disable(ACMP_TypeDef *acmp);
00276 void ACMP_Enable(ACMP_TypeDef *acmp);
00277 void ACMP_GPIOSetup(ACMP_TypeDef *acmp, uint32_t location, bool enable, bool invert);
00278 void ACMP_Init(ACMP_TypeDef *acmp, const ACMP_Init_TypeDef *init);
00279 void ACMP_Reset(ACMP_TypeDef *acmp);
00280
00281
00292 __STATIC_INLINE void ACMP_IntClear(ACMP_TypeDef *acmp, uint32_t flags)
00293 {
00294 acmp->IFC = flags;
00295 }
00296
00297
00298
00309 __STATIC_INLINE void ACMP_IntDisable(ACMP_TypeDef *acmp, uint32_t flags)
00310 {
00311 acmp->IEN &= ~(flags);
00312 }
00313
00314
00315
00331 __STATIC_INLINE void ACMP_IntEnable(ACMP_TypeDef *acmp, uint32_t flags)
00332 {
00333 acmp->IEN |= flags;
00334 }
00335
00336
00337
00351 __STATIC_INLINE uint32_t ACMP_IntGet(ACMP_TypeDef *acmp)
00352 {
00353 return(acmp->IF);
00354 }
00355
00356
00357
00376 __STATIC_INLINE uint32_t ACMP_IntGetEnabled(ACMP_TypeDef *acmp)
00377 {
00378 uint32_t tmp;
00379
00380
00381
00382 tmp = acmp->IEN;
00383
00384
00385 return acmp->IF & tmp;
00386 }
00387
00388
00389
00400 __STATIC_INLINE void ACMP_IntSet(ACMP_TypeDef *acmp, uint32_t flags)
00401 {
00402 acmp->IFS = flags;
00403 }
00404
00408 #ifdef __cplusplus
00409 }
00410 #endif
00411
00412 #endif
00413 #endif