RTEMS 6.1-rc6
Loading...
Searching...
No Matches
fsl_dac12.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
3 * Copyright 2016-2021 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_DAC12_H_
10#define _FSL_DAC12_H_
11
12#include "fsl_common.h"
13
21/*******************************************************************************
22 * Definitions
23 ******************************************************************************/
24
28#define FSL_DAC12_DRIVER_VERSION (MAKE_VERSION(2, 1, 0))
32#define DAC12_CR_W1C_FLAGS_MASK (DAC_CR_OVFF_MASK | DAC_CR_UDFF_MASK)
34#define DAC12_CR_ALL_FLAGS_MASK (DAC12_CR_W1C_FLAGS_MASK | DAC_CR_WMF_MASK | DAC_CR_NEMPTF_MASK | DAC_CR_FULLF_MASK)
35
40{
41 kDAC12_OverflowFlag = DAC_CR_OVFF_MASK,
43 kDAC12_UnderflowFlag = DAC_CR_UDFF_MASK,
45 kDAC12_WatermarkFlag = DAC_CR_WMF_MASK,
47 kDAC12_NearlyEmptyFlag = DAC_CR_NEMPTF_MASK,
49 kDAC12_FullFlag = DAC_CR_FULLF_MASK
51};
52
57{
59 kDAC12_WatermarkInterruptEnable = DAC_CR_WTMIE_MASK,
60 kDAC12_NearlyEmptyInterruptEnable = DAC_CR_EMPTIE_MASK,
61 kDAC12_FullInterruptEnable = DAC_CR_FULLIE_MASK
62};
63
68{
78
83{
92
97{
101
106{
110
120{
128
133{
138
143{
146
152typedef struct
153{
157 dac12_fifo_trigger_mode_t fifoTriggerMode;
159 /* Analog part configuration. */
163#if !(defined(FSL_FEATURE_DAC12_HAS_NO_ITRM_REGISTER) && FSL_FEATURE_DAC12_HAS_NO_ITRM_REGISTER)
165#endif /* FSL_FEATURE_DAC12_HAS_NO_ITRM_REGISTER */
167
168/*******************************************************************************
169 * API
170 ******************************************************************************/
171#if defined(__cplusplus)
172extern "C" {
173#endif
174
187
194void DAC12_Init(DAC_Type *base, const dac12_config_t *config);
195
213
219void DAC12_Deinit(DAC_Type *base);
220
227static inline void DAC12_Enable(DAC_Type *base, bool enable)
228{
229 if (enable)
230 {
231 base->CR = (base->CR & ~DAC12_CR_W1C_FLAGS_MASK) | DAC_CR_DACEN_MASK;
232 }
233 else
234 {
235 base->CR &= ~DAC_CR_DACEN_MASK;
236 }
237}
238
244static inline void DAC12_ResetConfig(DAC_Type *base)
245{
246 base->CR = DAC_CR_SWRST_MASK;
247}
248
257static inline void DAC12_ResetFIFO(DAC_Type *base)
258{
259 /* FIFO pointers should only be reset when the module is disabled. */
260 base->CR = (base->CR & ~DAC12_CR_W1C_FLAGS_MASK) | DAC_CR_FIFORST_MASK;
261}
262
263/* @} */
264
276static inline uint32_t DAC12_GetStatusFlags(DAC_Type *base)
277{
278 return (DAC12_CR_ALL_FLAGS_MASK & base->CR);
279}
280
290static inline void DAC12_ClearStatusFlags(DAC_Type *base, uint32_t flags)
291{
292 base->CR |= (flags & DAC12_CR_W1C_FLAGS_MASK);
293}
294
295/* @} */
296
308static inline void DAC12_EnableInterrupts(DAC_Type *base, uint32_t mask)
309{
310 base->CR = (base->CR & ~DAC12_CR_W1C_FLAGS_MASK) | mask;
311}
312
319static inline void DAC12_DisableInterrupts(DAC_Type *base, uint32_t mask)
320{
321 base->CR &= ~mask;
322}
323
324/* @} */
325
337static inline void DAC12_EnableDMA(DAC_Type *base, bool enable)
338{
339 if (enable)
340 {
341 base->CR = (base->CR & ~DAC12_CR_W1C_FLAGS_MASK) | DAC_CR_DMAEN_MASK;
342 }
343 else
344 {
345 base->CR &= ~DAC_CR_DMAEN_MASK;
346 }
347}
348
349/* @} */
350
368static inline void DAC12_SetData(DAC_Type *base, uint32_t value)
369{
370 /* The module is connected internally to a 32-bit interface.
371 * For the 8-bit or 16-bit, the write might be ignored. */
372 base->DATA = DAC_DATA_DATA0(value);
373}
374
383static inline void DAC12_DoSoftwareTrigger(DAC_Type *base)
384{
385 base->CR = (base->CR & ~DAC12_CR_W1C_FLAGS_MASK) | DAC_CR_SWTRG_MASK;
386}
387
394static inline uint32_t DAC12_GetFIFOReadPointer(DAC_Type *base)
395{
396 return (DAC_PTR_DACRFP_MASK & base->PTR) >> DAC_PTR_DACRFP_SHIFT;
397}
398
405static inline uint32_t DAC12_GetFIFOWritePointer(DAC_Type *base)
406{
407 return (DAC_PTR_DACWFP_MASK & base->PTR) >> DAC_PTR_DACWFP_SHIFT;
408}
409
410/* @} */
411
412#if defined(__cplusplus)
413}
414#endif
418#endif /* _FSL_DAC12_H_ */
#define DAC_DATA_DATA0(x)
Definition: MIMXRT1166_cm4.h:27963
enum _dac12_fifo_work_mode dac12_fifo_work_mode_t
DAC12 FIFO work mode.
_dac12_reference_voltage_source
DAC12 reference voltage source.
Definition: fsl_dac12.h:97
struct _dac12_hardware_info dac12_hardware_info_t
DAC12 hardware information.
enum _dac12_speed_mode dac12_speed_mode_t
DAC analog buffer speed mode for conversion.
#define DAC12_CR_W1C_FLAGS_MASK
Define "write 1 to clear" flags.
Definition: fsl_dac12.h:32
enum _dac12_fifo_trigger_mode dac12_fifo_trigger_mode_t
DAC12 FIFO trigger mode.
_dac12_interrupt_enable
DAC12 interrupts.
Definition: fsl_dac12.h:57
enum _dac12_reference_voltage_source dac12_reference_voltage_source_t
DAC12 reference voltage source.
void DAC12_Deinit(DAC_Type *base)
De-initialize the DAC12 module.
Definition: fsl_dac12.c:159
_dac12_fifo_size_info
DAC12 FIFO size information provided by hardware.
Definition: fsl_dac12.h:68
enum _dac12_reference_current_source dac12_reference_current_source_t
DAC internal reference current source.
dac12_reference_current_source_t referenceCurrentSource
Definition: fsl_dac12.h:160
_dac12_fifo_work_mode
DAC12 FIFO work mode.
Definition: fsl_dac12.h:83
dac12_reference_voltage_source_t referenceVoltageSource
Definition: fsl_dac12.h:156
_dac12_reference_current_source
DAC internal reference current source.
Definition: fsl_dac12.h:120
_dac12_speed_mode
DAC analog buffer speed mode for conversion.
Definition: fsl_dac12.h:133
void DAC12_Init(DAC_Type *base, const dac12_config_t *config)
Initialize the DAC12 module.
Definition: fsl_dac12.c:78
void DAC12_GetDefaultConfig(dac12_config_t *config)
Initializes the DAC12 user configuration structure.
Definition: fsl_dac12.c:183
_dac12_fifo_trigger_mode
DAC12 FIFO trigger mode.
Definition: fsl_dac12.h:106
dac12_fifo_size_info_t fifoSizeInfo
Definition: fsl_dac12.h:144
#define DAC12_CR_ALL_FLAGS_MASK
Define all the flag bits in DACx_CR register.
Definition: fsl_dac12.h:34
void DAC12_GetHardwareInfo(DAC_Type *base, dac12_hardware_info_t *info)
Get hardware information about this module.
Definition: fsl_dac12.c:64
enum _dac12_fifo_size_info dac12_fifo_size_info_t
DAC12 FIFO size information provided by hardware.
dac12_speed_mode_t speedMode
Definition: fsl_dac12.h:161
uint32_t currentReferenceInternalTrimValue
Definition: fsl_dac12.h:164
bool enableAnalogBuffer
Definition: fsl_dac12.h:162
dac12_fifo_work_mode_t fifoWorkMode
Definition: fsl_dac12.h:155
uint32_t fifoWatermarkLevel
Definition: fsl_dac12.h:154
_dac12_status_flags
DAC12 flags.
Definition: fsl_dac12.h:40
@ kDAC12_ReferenceVoltageSourceAlt1
Definition: fsl_dac12.h:98
@ kDAC12_ReferenceVoltageSourceAlt2
Definition: fsl_dac12.h:99
@ kDAC12_FullInterruptEnable
Definition: fsl_dac12.h:61
@ kDAC12_NearlyEmptyInterruptEnable
Definition: fsl_dac12.h:60
@ kDAC12_WatermarkInterruptEnable
Definition: fsl_dac12.h:59
@ kDAC12_UnderOrOverflowInterruptEnable
Definition: fsl_dac12.h:58
@ kDAC12_FIFOSize32
Definition: fsl_dac12.h:73
@ kDAC12_FIFOSize64
Definition: fsl_dac12.h:74
@ kDAC12_FIFOSize2
Definition: fsl_dac12.h:69
@ kDAC12_FIFOSize256
Definition: fsl_dac12.h:76
@ kDAC12_FIFOSize4
Definition: fsl_dac12.h:70
@ kDAC12_FIFOSize128
Definition: fsl_dac12.h:75
@ kDAC12_FIFOSize16
Definition: fsl_dac12.h:72
@ kDAC12_FIFOSize8
Definition: fsl_dac12.h:71
@ kDAC12_FIFOWorkAsNormalMode
Definition: fsl_dac12.h:86
@ kDAC12_FIFOWorkAsSwingMode
Definition: fsl_dac12.h:87
@ kDAC12_FIFODisabled
Definition: fsl_dac12.h:84
@ kDAC12_ReferenceCurrentSourceAlt2
Definition: fsl_dac12.h:125
@ kDAC12_ReferenceCurrentSourceAlt0
Definition: fsl_dac12.h:122
@ kDAC12_ReferenceCurrentSourceDisabled
Definition: fsl_dac12.h:121
@ kDAC12_ReferenceCurrentSourceAlt1
Definition: fsl_dac12.h:123
@ kDAC12_SpeedHighMode
Definition: fsl_dac12.h:136
@ kDAC12_SpeedMiddleMode
Definition: fsl_dac12.h:135
@ kDAC12_SpeedLowMode
Definition: fsl_dac12.h:134
@ kDAC12_FIFOTriggerBySoftwareMode
Definition: fsl_dac12.h:108
@ kDAC12_FIFOTriggerByHardwareMode
Definition: fsl_dac12.h:107
@ kDAC12_NearlyEmptyFlag
Definition: fsl_dac12.h:47
@ kDAC12_WatermarkFlag
Definition: fsl_dac12.h:45
@ kDAC12_OverflowFlag
Definition: fsl_dac12.h:41
@ kDAC12_UnderflowFlag
Definition: fsl_dac12.h:43
@ kDAC12_FullFlag
Definition: fsl_dac12.h:49
Definition: MIMXRT1166_cm4.h:27894
DAC12 hardware information.
Definition: fsl_dac12.h:143
Definition: deflate.c:114
DAC12 module configuration.
Definition: fsl_dac12.h:153