EFM32 Pearl Gecko Software Documentation  efm32pg1-doc-4.2.1
em_idac.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __SILICON_LABS_EM_IDAC_H__
34 #define __SILICON_LABS_EM_IDAC_H__
35 
36 #include "em_device.h"
37 
38 #if defined(IDAC_COUNT) && (IDAC_COUNT > 0)
39 #include <stdbool.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /***************************************************************************/
50 /***************************************************************************/
58 #define IDAC_REF_VALID(ref) ((ref) == IDAC0)
59 
62 /*******************************************************************************
63  ******************************** ENUMS ************************************
64  ******************************************************************************/
65 
67 typedef enum
68 {
69 #if defined( _IDAC_CTRL_OUTMODE_MASK )
70  idacOutputPin = IDAC_CTRL_OUTMODE_PIN,
71  idacOutputADC = IDAC_CTRL_OUTMODE_ADC
72 #elif ( _IDAC_CTRL_APORTOUTSEL_MASK )
105 #endif
107 
108 
111 typedef enum
112 {
117 #if defined( IDAC_CTRL_PRSSEL_PRSCH4 )
120 #endif
121 #if defined( IDAC_CTRL_PRSSEL_PRSCH6 )
128 #endif
130 
131 
133 typedef enum
134 {
140 
141 /*******************************************************************************
142  ******************************* STRUCTS ***********************************
143  ******************************************************************************/
144 
146 typedef struct
147 {
149  bool enable;
150 
153 
159  bool prsEnable;
160 
166 
169 
171 
173 #if defined( _IDAC_CTRL_OUTMODE_MASK )
174 #define IDAC_INIT_DEFAULT \
175 { \
176  false, \
177  idacOutputPin, \
178  false, \
179  idacPRSSELCh0, \
180  false \
181 }
182 #elif ( _IDAC_CTRL_APORTOUTSEL_MASK )
183 #define IDAC_INIT_DEFAULT \
184 { \
185  false, \
186  idacOutputAPORT1XCH0, \
187  false, \
188  idacPRSSELCh0, \
189  false \
190 }
191 #endif
192 
193 
194 /*******************************************************************************
195  ***************************** PROTOTYPES **********************************
196  ******************************************************************************/
197 
198 /***************************************************************************/
215 void IDAC_Init(IDAC_TypeDef *idac, const IDAC_Init_TypeDef *init);
216 
217 
218 /***************************************************************************/
228 void IDAC_Enable(IDAC_TypeDef *idac, bool enable);
229 
230 
231 /***************************************************************************/
238 void IDAC_Reset(IDAC_TypeDef *idac);
239 
240 
241 /***************************************************************************/
251 void IDAC_MinimalOutputTransitionMode(IDAC_TypeDef *idac, bool enable);
252 
253 
254 /***************************************************************************/
270 void IDAC_RangeSet(IDAC_TypeDef *idac, const IDAC_Range_TypeDef range);
271 
272 
273 /***************************************************************************/
283 void IDAC_StepSet(IDAC_TypeDef *idac, const uint32_t step);
284 
285 
286 /***************************************************************************/
296 void IDAC_OutEnable(IDAC_TypeDef *idac, bool enable);
297 
298 
299 #if defined( _IDAC_IEN_MASK )
300 /***************************************************************************/
311 __STATIC_INLINE void IDAC_IntClear(IDAC_TypeDef *idac, uint32_t flags)
312 {
313  idac->IFC = flags;
314 }
315 
316 
317 /***************************************************************************/
328 __STATIC_INLINE void IDAC_IntDisable(IDAC_TypeDef *idac, uint32_t flags)
329 {
330  idac->IEN &= ~flags;
331 }
332 
333 
334 /***************************************************************************/
350 __STATIC_INLINE void IDAC_IntEnable(IDAC_TypeDef *idac, uint32_t flags)
351 {
352  idac->IEN |= flags;
353 }
354 
355 
356 /***************************************************************************/
370 __STATIC_INLINE uint32_t IDAC_IntGet(IDAC_TypeDef *idac)
371 {
372  return idac->IF;
373 }
374 
375 
376 /***************************************************************************/
395 __STATIC_INLINE uint32_t IDAC_IntGetEnabled(IDAC_TypeDef *idac)
396 {
397  uint32_t ien;
398 
399  /* Store flags in temporary variable in order to define explicit order
400  * of volatile accesses. */
401  ien = idac->IEN;
402 
403  /* Bitwise AND of pending and enabled interrupts */
404  return idac->IF & ien;
405 }
406 
407 
408 /***************************************************************************/
419 __STATIC_INLINE void IDAC_IntSet(IDAC_TypeDef *idac, uint32_t flags)
420 {
421  idac->IFS = flags;
422 }
423 #endif
424 
425 
429 #ifdef __cplusplus
430 }
431 #endif
432 
433 #endif /* defined(IDAC_COUNT) && (IDAC_COUNT > 0) */
434 
435 #endif /* __SILICON_LABS_EM_IDAC_H__ */
__IO uint32_t IFS
#define IDAC_CTRL_PRSSEL_PRSCH5
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH2
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH24
#define IDAC_CTRL_PRSSEL_PRSCH4
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH3
#define IDAC_CTRL_PRSSEL_PRSCH1
__STATIC_INLINE void IDAC_IntDisable(IDAC_TypeDef *idac, uint32_t flags)
Disable one or more IDAC interrupts.
Definition: em_idac.h:328
IDAC_PRSSEL_TypeDef prsSel
Definition: em_idac.h:165
#define IDAC_CTRL_PRSSEL_PRSCH10
#define IDAC_CTRL_PRSSEL_PRSCH6
#define IDAC_CTRL_PRSSEL_PRSCH2
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH27
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH18
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH20
#define IDAC_CURPROG_RANGESEL_RANGE0
IDAC_OutMode_TypeDef
Definition: em_idac.h:67
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH17
__IO uint32_t IFC
#define IDAC_CTRL_PRSSEL_PRSCH7
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH16
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH15
#define IDAC_CURPROG_RANGESEL_RANGE1
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH29
#define IDAC_CTRL_PRSSEL_PRSCH8
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH21
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH4
void IDAC_Enable(IDAC_TypeDef *idac, bool enable)
Enable/disable IDAC.
Definition: em_idac.c:114
__STATIC_INLINE uint32_t IDAC_IntGet(IDAC_TypeDef *idac)
Get pending IDAC interrupt flags.
Definition: em_idac.h:370
__STATIC_INLINE uint32_t IDAC_IntGetEnabled(IDAC_TypeDef *idac)
Get enabled and pending IDAC interrupt flags. Useful for handling more interrupt sources in the same ...
Definition: em_idac.h:395
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH7
#define IDAC_CURPROG_RANGESEL_RANGE2
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH26
void IDAC_MinimalOutputTransitionMode(IDAC_TypeDef *idac, bool enable)
Enable/disable Minimal Output Transition mode.
Definition: em_idac.c:172
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH11
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH22
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH13
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH23
__I uint32_t IF
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH14
#define IDAC_CTRL_PRSSEL_PRSCH9
void IDAC_RangeSet(IDAC_TypeDef *idac, const IDAC_Range_TypeDef range)
Set the current range of the IDAC output.
Definition: em_idac.c:200
IDAC_PRSSEL_TypeDef
Definition: em_idac.h:111
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH8
__STATIC_INLINE void IDAC_IntEnable(IDAC_TypeDef *idac, uint32_t flags)
Enable one or more IDAC interrupts.
Definition: em_idac.h:350
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH31
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH5
void IDAC_Init(IDAC_TypeDef *idac, const IDAC_Init_TypeDef *init)
Initialize IDAC.
Definition: em_idac.c:77
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH12
IDAC_OutMode_TypeDef outMode
Definition: em_idac.h:152
void IDAC_StepSet(IDAC_TypeDef *idac, const uint32_t step)
Set the current step of the IDAC output.
Definition: em_idac.c:333
__STATIC_INLINE void IDAC_IntSet(IDAC_TypeDef *idac, uint32_t flags)
Set one or more pending IDAC interrupts from SW.
Definition: em_idac.h:419
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH6
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH0
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH19
#define IDAC_CTRL_PRSSEL_PRSCH0
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH9
void IDAC_Reset(IDAC_TypeDef *idac)
Reset IDAC to same state as after a HW reset.
Definition: em_idac.c:133
void IDAC_OutEnable(IDAC_TypeDef *idac, bool enable)
Enable/disable the IDAC OUT pin.
Definition: em_idac.c:357
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH28
#define IDAC_CURPROG_RANGESEL_RANGE3
#define IDAC_CTRL_PRSSEL_PRSCH11
__IO uint32_t IEN
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH10
__STATIC_INLINE void IDAC_IntClear(IDAC_TypeDef *idac, uint32_t flags)
Clear one or more pending IDAC interrupts.
Definition: em_idac.h:311
#define IDAC_CTRL_PRSSEL_PRSCH3
IDAC_Range_TypeDef
Definition: em_idac.h:133
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH1
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH30
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH25