EFR32 Blue Gecko 1 Software Documentation  efr32bg1-doc-5.1.2
em_idac.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef EM_IDAC_H
34 #define 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 /***************************************************************************/
84 #define IDAC_REF_VALID(ref) ((ref) == IDAC0)
85 
88 /*******************************************************************************
89  ******************************** ENUMS ************************************
90  ******************************************************************************/
91 
93 typedef enum
94 {
95 #if defined( _IDAC_CTRL_OUTMODE_MASK )
96  idacOutputPin = IDAC_CTRL_OUTMODE_PIN,
97  idacOutputADC = IDAC_CTRL_OUTMODE_ADC
98 #elif ( _IDAC_CTRL_APORTOUTSEL_MASK )
131 #endif
133 
134 
137 typedef enum
138 {
143 #if defined( IDAC_CTRL_PRSSEL_PRSCH4 )
146 #endif
147 #if defined( IDAC_CTRL_PRSSEL_PRSCH6 )
154 #endif
156 
157 
159 typedef enum
160 {
166 
167 /*******************************************************************************
168  ******************************* STRUCTS ***********************************
169  ******************************************************************************/
170 
172 typedef struct
173 {
175  bool enable;
176 
179 
185  bool prsEnable;
186 
192 
195 
197 
199 #if defined( _IDAC_CTRL_OUTMODE_MASK )
200 #define IDAC_INIT_DEFAULT \
201 { \
202  false, \
203  idacOutputPin, \
204  false, \
205  idacPRSSELCh0, \
206  false \
207 }
208 #elif ( _IDAC_CTRL_APORTOUTSEL_MASK )
209 #define IDAC_INIT_DEFAULT \
210 { \
211  false, \
212  idacOutputAPORT1XCH0, \
213  false, \
214  idacPRSSELCh0, \
215  false \
216 }
217 #endif
218 
219 
220 /*******************************************************************************
221  ***************************** PROTOTYPES **********************************
222  ******************************************************************************/
223 
224 
225 void IDAC_Init(IDAC_TypeDef *idac, const IDAC_Init_TypeDef *init);
226 void IDAC_Enable(IDAC_TypeDef *idac, bool enable);
227 void IDAC_Reset(IDAC_TypeDef *idac);
228 void IDAC_MinimalOutputTransitionMode(IDAC_TypeDef *idac, bool enable);
229 void IDAC_RangeSet(IDAC_TypeDef *idac, const IDAC_Range_TypeDef range);
230 void IDAC_StepSet(IDAC_TypeDef *idac, const uint32_t step);
231 void IDAC_OutEnable(IDAC_TypeDef *idac, bool enable);
232 
233 
234 #if defined( _IDAC_IEN_MASK )
235 /***************************************************************************/
246 __STATIC_INLINE void IDAC_IntClear(IDAC_TypeDef *idac, uint32_t flags)
247 {
248  idac->IFC = flags;
249 }
250 
251 
252 /***************************************************************************/
263 __STATIC_INLINE void IDAC_IntDisable(IDAC_TypeDef *idac, uint32_t flags)
264 {
265  idac->IEN &= ~flags;
266 }
267 
268 
269 /***************************************************************************/
285 __STATIC_INLINE void IDAC_IntEnable(IDAC_TypeDef *idac, uint32_t flags)
286 {
287  idac->IEN |= flags;
288 }
289 
290 
291 /***************************************************************************/
305 __STATIC_INLINE uint32_t IDAC_IntGet(IDAC_TypeDef *idac)
306 {
307  return idac->IF;
308 }
309 
310 
311 /***************************************************************************/
330 __STATIC_INLINE uint32_t IDAC_IntGetEnabled(IDAC_TypeDef *idac)
331 {
332  uint32_t ien;
333 
334  /* Store flags in temporary variable in order to define explicit order
335  * of volatile accesses. */
336  ien = idac->IEN;
337 
338  /* Bitwise AND of pending and enabled interrupts */
339  return idac->IF & ien;
340 }
341 
342 
343 /***************************************************************************/
354 __STATIC_INLINE void IDAC_IntSet(IDAC_TypeDef *idac, uint32_t flags)
355 {
356  idac->IFS = flags;
357 }
358 #endif
359 
360 
364 #ifdef __cplusplus
365 }
366 #endif
367 
368 #endif /* defined(IDAC_COUNT) && (IDAC_COUNT > 0) */
369 
370 #endif /* EM_IDAC_H */
#define IDAC_CURPROG_RANGESEL_RANGE3
#define IDAC_CTRL_PRSSEL_PRSCH10
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH22
__STATIC_INLINE void IDAC_IntDisable(IDAC_TypeDef *idac, uint32_t flags)
Disable one or more IDAC interrupts.
Definition: em_idac.h:263
__IOM uint32_t IFC
IDAC_PRSSEL_TypeDef prsSel
Definition: em_idac.h:191
#define IDAC_CTRL_PRSSEL_PRSCH11
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH14
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH30
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH8
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH13
#define IDAC_CTRL_PRSSEL_PRSCH7
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH15
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH25
#define IDAC_CTRL_PRSSEL_PRSCH5
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH2
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH24
IDAC_OutMode_TypeDef
Definition: em_idac.h:93
#define IDAC_CURPROG_RANGESEL_RANGE1
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH3
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH4
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH20
#define IDAC_CTRL_PRSSEL_PRSCH6
#define IDAC_CURPROG_RANGESEL_RANGE0
#define IDAC_CTRL_PRSSEL_PRSCH4
void IDAC_Enable(IDAC_TypeDef *idac, bool enable)
Enable/disable IDAC.
Definition: em_idac.c:120
__STATIC_INLINE uint32_t IDAC_IntGet(IDAC_TypeDef *idac)
Get pending IDAC interrupt flags.
Definition: em_idac.h:305
__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:330
#define IDAC_CTRL_PRSSEL_PRSCH2
void IDAC_MinimalOutputTransitionMode(IDAC_TypeDef *idac, bool enable)
Enable/disable Minimal Output Transition mode.
Definition: em_idac.c:173
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH18
__IOM uint32_t IFS
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH31
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH11
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH5
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH26
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH23
#define IDAC_CTRL_PRSSEL_PRSCH8
void IDAC_RangeSet(IDAC_TypeDef *idac, const IDAC_Range_TypeDef range)
Set the current range of the IDAC output.
Definition: em_idac.c:196
IDAC_PRSSEL_TypeDef
Definition: em_idac.h:137
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH16
__STATIC_INLINE void IDAC_IntEnable(IDAC_TypeDef *idac, uint32_t flags)
Enable one or more IDAC interrupts.
Definition: em_idac.h:285
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH7
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH0
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH29
void IDAC_Init(IDAC_TypeDef *idac, const IDAC_Init_TypeDef *init)
Initialize IDAC.
Definition: em_idac.c:79
IDAC_OutMode_TypeDef outMode
Definition: em_idac.h:178
void IDAC_StepSet(IDAC_TypeDef *idac, const uint32_t step)
Set the current step of the IDAC output.
Definition: em_idac.c:323
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH27
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH12
__STATIC_INLINE void IDAC_IntSet(IDAC_TypeDef *idac, uint32_t flags)
Set one or more pending IDAC interrupts from SW.
Definition: em_idac.h:354
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH21
#define IDAC_CURPROG_RANGESEL_RANGE2
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH28
void IDAC_Reset(IDAC_TypeDef *idac)
Reset IDAC to same state as after a HW reset.
Definition: em_idac.c:134
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH10
void IDAC_OutEnable(IDAC_TypeDef *idac, bool enable)
Enable/disable the IDAC OUT pin.
Definition: em_idac.c:347
__IM uint32_t IF
__STATIC_INLINE void IDAC_IntClear(IDAC_TypeDef *idac, uint32_t flags)
Clear one or more pending IDAC interrupts.
Definition: em_idac.h:246
IDAC_Range_TypeDef
Definition: em_idac.h:159
__IOM uint32_t IEN
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH1
#define IDAC_CTRL_PRSSEL_PRSCH1
#define IDAC_CTRL_PRSSEL_PRSCH9
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH17
#define IDAC_CTRL_PRSSEL_PRSCH0
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH19
#define IDAC_CTRL_APORTOUTSEL_APORT1YCH9
#define IDAC_CTRL_PRSSEL_PRSCH3
#define IDAC_CTRL_APORTOUTSEL_APORT1XCH6