EFR32 Mighty Gecko 13 Software Documentation  efr32mg13-doc-5.1.2
em_vdac.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef EM_VDAC_H
34 #define EM_VDAC_H
35 
36 #include "em_device.h"
37 
38 #if defined(VDAC_COUNT) && (VDAC_COUNT > 0)
39 
40 #include "em_assert.h"
41 #include <stdbool.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 
48 /***************************************************************************/
53 /***************************************************************************/
97 #define VDAC_REF_VALID(ref) ((ref) == VDAC0)
98 
101 /*******************************************************************************
102  ******************************** ENUMS ************************************
103  ******************************************************************************/
104 
106 typedef enum
107 {
113 
115 typedef enum
116 {
124 
126 typedef enum
127 {
141 
143 typedef enum
144 {
152 
153 /*******************************************************************************
154  ******************************* STRUCTS ***********************************
155  ******************************************************************************/
156 
158 typedef struct
159 {
162 
166 
169 
172 
174  uint32_t prescaler;
175 
178 
181 
184 
187 
189  bool diff;
191 
193 #define VDAC_INIT_DEFAULT \
194 { \
195  true, /* Use main output path calibration values. */ \
196  false, /* Use synchronous clock mode. */ \
197  false, /* Turn off between sample off conversions.*/ \
198  vdacRefresh8, /* Refresh every 8th cycle. */ \
199  0, /* No prescaling. */ \
200  vdacRef1V25Ln, /* 1.25V internal low noise reference. */ \
201  false, /* Do not reset prescaler on CH 0 start. */ \
202  false, /* VDAC output enable always on. */ \
203  false, /* Disable sine mode. */ \
204  false /* Single ended mode. */ \
205 }
206 
208 typedef struct
209 {
211  bool enable;
212 
217 
219  bool prsAsync;
220 
223 
228 
230 #define VDAC_INITCHANNEL_DEFAULT \
231 { \
232  false, /* Leave channel disabled when init done. */ \
233  vdacPrsSelCh0, /* PRS CH 0 triggers conversion. */ \
234  false, /* Treat PRS channel as a synchronous signal. */ \
235  vdacTrigModeSw, /* Conversion trigged by CH0DATA or COMBDATA write. */ \
236  false, /* Channel conversion set to continous. */ \
237 }
238 
239 /*******************************************************************************
240  ***************************** PROTOTYPES **********************************
241  ******************************************************************************/
242 
244  unsigned int channel,
245  uint32_t value);
246 void VDAC_Enable(VDAC_TypeDef *vdac, unsigned int ch, bool enable);
247 void VDAC_Init(VDAC_TypeDef *vdac, const VDAC_Init_TypeDef *init);
248 void VDAC_InitChannel(VDAC_TypeDef *vdac,
249  const VDAC_InitChannel_TypeDef *init,
250  unsigned int ch);
251 
252 /***************************************************************************/
266 __STATIC_INLINE void VDAC_Channel0OutputSet(VDAC_TypeDef *vdac,
267  uint32_t value)
268 {
269  EFM_ASSERT(value<=_VDAC_CH0DATA_MASK);
270  vdac->CH0DATA = value;
271 }
272 
273 /***************************************************************************/
287 __STATIC_INLINE void VDAC_Channel1OutputSet(VDAC_TypeDef *vdac,
288  uint32_t value)
289 {
290  EFM_ASSERT(value<=_VDAC_CH1DATA_MASK);
291  vdac->CH1DATA = value;
292 }
293 
294 /***************************************************************************/
305 __STATIC_INLINE void VDAC_IntClear(VDAC_TypeDef *vdac, uint32_t flags)
306 {
307  vdac->IFC = flags;
308 }
309 
310 /***************************************************************************/
321 __STATIC_INLINE void VDAC_IntDisable(VDAC_TypeDef *vdac, uint32_t flags)
322 {
323  vdac->IEN &= ~flags;
324 }
325 
326 /***************************************************************************/
342 __STATIC_INLINE void VDAC_IntEnable(VDAC_TypeDef *vdac, uint32_t flags)
343 {
344  vdac->IEN |= flags;
345 }
346 
347 /***************************************************************************/
361 __STATIC_INLINE uint32_t VDAC_IntGet(VDAC_TypeDef *vdac)
362 {
363  return vdac->IF;
364 }
365 
366 /***************************************************************************/
385 __STATIC_INLINE uint32_t VDAC_IntGetEnabled(VDAC_TypeDef *vdac)
386 {
387  uint32_t ien = vdac->IEN;
388 
389  /* Bitwise AND of pending and enabled interrupts */
390  return vdac->IF & ien;
391 }
392 
393 /***************************************************************************/
404 __STATIC_INLINE void VDAC_IntSet(VDAC_TypeDef *vdac, uint32_t flags)
405 {
406  vdac->IFS = flags;
407 }
408 
409 uint32_t VDAC_PrescaleCalc(uint32_t vdacFreq, bool syncMode, uint32_t hfperFreq);
410 void VDAC_Reset(VDAC_TypeDef *vdac);
411 
415 #ifdef __cplusplus
416 }
417 #endif
418 
419 #endif /* defined(VDAC_COUNT) && (VDAC_COUNT > 0) */
420 #endif /* EM_VDAC_H */
#define _VDAC_CTRL_REFRESHPERIOD_8CYCLES
#define _VDAC_CH0CTRL_PRSSEL_PRSCH9
#define _VDAC_CH1DATA_MASK
bool mainCalibration
Definition: em_vdac.h:161
Emlib peripheral API "assert" implementation.
__IOM uint32_t IFC
__IOM uint32_t IEN
#define _VDAC_CTRL_REFSEL_1V25
uint32_t prescaler
Definition: em_vdac.h:174
#define _VDAC_CH0DATA_MASK
#define _VDAC_CTRL_REFSEL_VDD
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
void VDAC_Init(VDAC_TypeDef *vdac, const VDAC_Init_TypeDef *init)
Initialize VDAC.
Definition: em_vdac.c:132
__STATIC_INLINE void VDAC_IntDisable(VDAC_TypeDef *vdac, uint32_t flags)
Disable one or more VDAC interrupts.
Definition: em_vdac.h:321
VDAC_Refresh_TypeDef
Definition: em_vdac.h:106
VDAC_Ref_TypeDef
Definition: em_vdac.h:115
VDAC_Ref_TypeDef reference
Definition: em_vdac.h:177
__IOM uint32_t IFS
#define _VDAC_CH0CTRL_PRSSEL_PRSCH2
VDAC_PrsSel_TypeDef prsSel
Definition: em_vdac.h:216
__STATIC_INLINE void VDAC_IntClear(VDAC_TypeDef *vdac, uint32_t flags)
Clear one or more pending VDAC interrupts.
Definition: em_vdac.h:305
bool asyncClockMode
Definition: em_vdac.h:165
void VDAC_InitChannel(VDAC_TypeDef *vdac, const VDAC_InitChannel_TypeDef *init, unsigned int ch)
Initialize a VDAC channel.
Definition: em_vdac.c:240
void VDAC_ChannelOutputSet(VDAC_TypeDef *vdac, unsigned int channel, uint32_t value)
Set the output signal of a VDAC channel to a given value.
Definition: em_vdac.c:316
__STATIC_INLINE uint32_t VDAC_IntGet(VDAC_TypeDef *vdac)
Get pending VDAC interrupt flags.
Definition: em_vdac.h:361
#define _VDAC_CH0CTRL_TRIGMODE_REFRESH
#define _VDAC_CTRL_REFRESHPERIOD_64CYCLES
__IM uint32_t IF
#define _VDAC_CH0CTRL_TRIGMODE_SWREFRESH
#define _VDAC_CH0CTRL_TRIGMODE_SWPRS
#define _VDAC_CTRL_REFSEL_1V25LN
#define _VDAC_CH0CTRL_PRSSEL_PRSCH3
#define _VDAC_CH0CTRL_TRIGMODE_LESENSE
#define _VDAC_CTRL_REFSEL_2V5LN
#define _VDAC_CH0CTRL_PRSSEL_PRSCH11
#define _VDAC_CH0CTRL_PRSSEL_PRSCH5
void VDAC_Reset(VDAC_TypeDef *vdac)
Reset VDAC to same state as after a HW reset.
Definition: em_vdac.c:420
uint32_t VDAC_PrescaleCalc(uint32_t vdacFreq, bool syncMode, uint32_t hfperFreq)
Calculate prescaler value used to determine VDAC clock.
Definition: em_vdac.c:366
VDAC_TrigMode_TypeDef
Definition: em_vdac.h:143
__STATIC_INLINE void VDAC_Channel0OutputSet(VDAC_TypeDef *vdac, uint32_t value)
Set the output signal of VDAC channel 0 to a given value.
Definition: em_vdac.h:266
#define _VDAC_CH0CTRL_PRSSEL_PRSCH4
__STATIC_INLINE void VDAC_IntSet(VDAC_TypeDef *vdac, uint32_t flags)
Set one or more pending VDAC interrupts from SW.
Definition: em_vdac.h:404
void VDAC_Enable(VDAC_TypeDef *vdac, unsigned int ch, bool enable)
Enable/disable VDAC channel.
Definition: em_vdac.c:81
#define _VDAC_CH0CTRL_TRIGMODE_SW
VDAC_PrsSel_TypeDef
Definition: em_vdac.h:126
__STATIC_INLINE void VDAC_Channel1OutputSet(VDAC_TypeDef *vdac, uint32_t value)
Set the output signal of VDAC channel 1 to a given value.
Definition: em_vdac.h:287
#define _VDAC_CH0CTRL_PRSSEL_PRSCH10
#define _VDAC_CH0CTRL_PRSSEL_PRSCH6
__IOM uint32_t CH0DATA
__STATIC_INLINE uint32_t VDAC_IntGetEnabled(VDAC_TypeDef *vdac)
Get enabled and pending VDAC interrupt flags. Useful for handling more interrupt sources in the same ...
Definition: em_vdac.h:385
#define _VDAC_CTRL_REFRESHPERIOD_32CYCLES
#define _VDAC_CH0CTRL_PRSSEL_PRSCH7
VDAC_Refresh_TypeDef refresh
Definition: em_vdac.h:171
#define _VDAC_CH0CTRL_TRIGMODE_PRS
#define _VDAC_CH0CTRL_PRSSEL_PRSCH0
VDAC_TrigMode_TypeDef trigMode
Definition: em_vdac.h:222
#define _VDAC_CTRL_REFRESHPERIOD_16CYCLES
__STATIC_INLINE void VDAC_IntEnable(VDAC_TypeDef *vdac, uint32_t flags)
Enable one or more VDAC interrupts.
Definition: em_vdac.h:342
#define _VDAC_CTRL_REFSEL_2V5
#define _VDAC_CH0CTRL_PRSSEL_PRSCH1
__IOM uint32_t CH1DATA
#define _VDAC_CH0CTRL_PRSSEL_PRSCH8
#define _VDAC_CTRL_REFSEL_EXT