em_idac.h

Go to the documentation of this file.
00001 /***************************************************************************/
00034 #ifndef __EM_IDAC_H
00035 #define __EM_IDAC_H
00036 
00037 #include "em_device.h"
00038 
00039 #if defined(IDAC_COUNT) && (IDAC_COUNT > 0)
00040 #include <stdbool.h>
00041 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 /***************************************************************************/
00051 /***************************************************************************/
00059 #define IDAC_REF_VALID(ref)    ((ref) == IDAC0)
00060 
00063 /*******************************************************************************
00064  ********************************   ENUMS   ************************************
00065  ******************************************************************************/
00066 
00068 typedef enum
00069 {
00070   idacOutputPin     = IDAC_CTRL_OUTMODE_PIN,     
00071   idacOutputADC     = IDAC_CTRL_OUTMODE_ADC      
00072 } IDAC_OutMode_TypeDef;
00073 
00074 
00077 typedef enum
00078 {
00079   idacPRSSELCh0 = IDAC_CTRL_PRSSEL_PRSCH0, 
00080   idacPRSSELCh1 = IDAC_CTRL_PRSSEL_PRSCH1, 
00081   idacPRSSELCh2 = IDAC_CTRL_PRSSEL_PRSCH2, 
00082   idacPRSSELCh3 = IDAC_CTRL_PRSSEL_PRSCH3,  
00083 #if  defined (IDAC_CTRL_PRSSEL_PRSCH11)
00084   idacPRSSELCh4 = IDAC_CTRL_PRSSEL_PRSCH4, 
00085   idacPRSSELCh5 = IDAC_CTRL_PRSSEL_PRSCH5, 
00086   idacPRSSELCh6 = IDAC_CTRL_PRSSEL_PRSCH6, 
00087   idacPRSSELCh7 = IDAC_CTRL_PRSSEL_PRSCH7, 
00088   idacPRSSELCh8 = IDAC_CTRL_PRSSEL_PRSCH8, 
00089   idacPRSSELCh9 = IDAC_CTRL_PRSSEL_PRSCH9, 
00090   idacPRSSELCh10 = IDAC_CTRL_PRSSEL_PRSCH10, 
00091   idacPRSSELCh11 = IDAC_CTRL_PRSSEL_PRSCH11,  
00092 #endif
00093 } IDAC_PRSSEL_TypeDef;
00094 
00095 
00097 typedef enum
00098 {
00099   idacCurrentRange0 = IDAC_CURPROG_RANGESEL_RANGE0, 
00100   idacCurrentRange1 = IDAC_CURPROG_RANGESEL_RANGE1, 
00101   idacCurrentRange2 = IDAC_CURPROG_RANGESEL_RANGE2, 
00102   idacCurrentRange3 = IDAC_CURPROG_RANGESEL_RANGE3, 
00103 } IDAC_Range_TypeDef;
00104 
00105 /*******************************************************************************
00106  *******************************   STRUCTS   ***********************************
00107  ******************************************************************************/
00108 
00110 typedef struct
00111 {
00113   bool                  enable;
00114 
00116   IDAC_OutMode_TypeDef  outMode;
00117 
00123   bool                  prsEnable;
00124 
00129   IDAC_PRSSEL_TypeDef   prsSel;
00130 
00132   bool                  sinkEnable;
00133 
00134 } IDAC_Init_TypeDef;
00135 
00137 #define IDAC_INIT_DEFAULT                                             \
00138   { false,          /* Leave IDAC disabled when init done. */         \
00139     idacOutputPin,   /* Output to IDAC OUT pin. */                     \
00140     false,          /* Disable PRS triggering. */                     \
00141     idacPRSSELCh0,  /* Select PRS ch0 (if PRS triggering enabled). */ \
00142     false           /* Disable current sink mode. */                  \
00143   }
00144   
00145 
00146 /*******************************************************************************
00147  *****************************   PROTOTYPES   **********************************
00148  ******************************************************************************/
00149 
00150 /***************************************************************************/
00167 void IDAC_Init(IDAC_TypeDef *idac, const IDAC_Init_TypeDef *init);
00168 
00169 
00170 /***************************************************************************/
00180 void IDAC_Enable(IDAC_TypeDef *idac, bool enable);
00181 
00182 
00183 /***************************************************************************/
00190 void IDAC_Reset(IDAC_TypeDef *idac);
00191 
00192 
00193 /***************************************************************************/
00203 void IDAC_MinimalOutputTransitionMode(IDAC_TypeDef *idac, bool enable);
00204 
00205 
00206 /***************************************************************************/
00222 void IDAC_RangeSet(IDAC_TypeDef *idac, const IDAC_Range_TypeDef range);
00223 
00224 
00225 /***************************************************************************/
00235 void IDAC_StepSet(IDAC_TypeDef *idac, const uint32_t step);
00236 
00237 
00238 /***************************************************************************/
00248 void IDAC_OutEnable(IDAC_TypeDef *idac, bool enable);
00249 
00250 
00254 #ifdef __cplusplus
00255 }
00256 #endif
00257 
00258 #endif /* defined(IDAC_COUNT) && (IDAC_COUNT > 0) */
00259 
00260 #endif /* __EM_IDAC_H */