The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_USENSE/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/drivers/fsl_dac.h@145:64910690c574
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 145:64910690c574 1 /*
AnnaBridge 145:64910690c574 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
AnnaBridge 145:64910690c574 3 * All rights reserved.
AnnaBridge 145:64910690c574 4 *
AnnaBridge 145:64910690c574 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 145:64910690c574 6 * are permitted provided that the following conditions are met:
AnnaBridge 145:64910690c574 7 *
AnnaBridge 145:64910690c574 8 * o Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 145:64910690c574 9 * of conditions and the following disclaimer.
AnnaBridge 145:64910690c574 10 *
AnnaBridge 145:64910690c574 11 * o Redistributions in binary form must reproduce the above copyright notice, this
AnnaBridge 145:64910690c574 12 * list of conditions and the following disclaimer in the documentation and/or
AnnaBridge 145:64910690c574 13 * other materials provided with the distribution.
AnnaBridge 145:64910690c574 14 *
AnnaBridge 145:64910690c574 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
AnnaBridge 145:64910690c574 16 * contributors may be used to endorse or promote products derived from this
AnnaBridge 145:64910690c574 17 * software without specific prior written permission.
AnnaBridge 145:64910690c574 18 *
AnnaBridge 145:64910690c574 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 145:64910690c574 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 145:64910690c574 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 145:64910690c574 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 145:64910690c574 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 145:64910690c574 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 145:64910690c574 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 145:64910690c574 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 145:64910690c574 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 145:64910690c574 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 145:64910690c574 29 */
AnnaBridge 145:64910690c574 30
AnnaBridge 145:64910690c574 31 #ifndef _FSL_DAC_H_
AnnaBridge 145:64910690c574 32 #define _FSL_DAC_H_
AnnaBridge 145:64910690c574 33
AnnaBridge 145:64910690c574 34 #include "fsl_common.h"
AnnaBridge 145:64910690c574 35
AnnaBridge 145:64910690c574 36 /*!
AnnaBridge 145:64910690c574 37 * @addtogroup dac
AnnaBridge 145:64910690c574 38 * @{
AnnaBridge 145:64910690c574 39 */
AnnaBridge 145:64910690c574 40
AnnaBridge 145:64910690c574 41
AnnaBridge 145:64910690c574 42 /*******************************************************************************
AnnaBridge 145:64910690c574 43 * Definitions
AnnaBridge 145:64910690c574 44 ******************************************************************************/
AnnaBridge 145:64910690c574 45
AnnaBridge 145:64910690c574 46 /*! @name Driver version */
AnnaBridge 145:64910690c574 47 /*@{*/
AnnaBridge 145:64910690c574 48 /*! @brief DAC driver version 2.0.1. */
AnnaBridge 145:64910690c574 49 #define FSL_DAC_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
AnnaBridge 145:64910690c574 50 /*@}*/
AnnaBridge 145:64910690c574 51
AnnaBridge 145:64910690c574 52 /*!
AnnaBridge 145:64910690c574 53 * @brief DAC buffer flags.
AnnaBridge 145:64910690c574 54 */
AnnaBridge 145:64910690c574 55 enum _dac_buffer_status_flags
AnnaBridge 145:64910690c574 56 {
AnnaBridge 145:64910690c574 57 #if defined(FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION
AnnaBridge 145:64910690c574 58 kDAC_BufferWatermarkFlag = DAC_SR_DACBFWMF_MASK, /*!< DAC Buffer Watermark Flag. */
AnnaBridge 145:64910690c574 59 #endif /* FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION */
AnnaBridge 145:64910690c574 60 kDAC_BufferReadPointerTopPositionFlag = DAC_SR_DACBFRPTF_MASK, /*!< DAC Buffer Read Pointer Top Position Flag. */
AnnaBridge 145:64910690c574 61 kDAC_BufferReadPointerBottomPositionFlag = DAC_SR_DACBFRPBF_MASK, /*!< DAC Buffer Read Pointer Bottom Position
AnnaBridge 145:64910690c574 62 Flag. */
AnnaBridge 145:64910690c574 63 };
AnnaBridge 145:64910690c574 64
AnnaBridge 145:64910690c574 65 /*!
AnnaBridge 145:64910690c574 66 * @brief DAC buffer interrupts.
AnnaBridge 145:64910690c574 67 */
AnnaBridge 145:64910690c574 68 enum _dac_buffer_interrupt_enable
AnnaBridge 145:64910690c574 69 {
AnnaBridge 145:64910690c574 70 #if defined(FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION
AnnaBridge 145:64910690c574 71 kDAC_BufferWatermarkInterruptEnable = DAC_C0_DACBWIEN_MASK, /*!< DAC Buffer Watermark Interrupt Enable. */
AnnaBridge 145:64910690c574 72 #endif /* FSL_FEATURE_DAC_HAS_WATERMARK_DETECTION */
AnnaBridge 145:64910690c574 73 kDAC_BufferReadPointerTopInterruptEnable = DAC_C0_DACBTIEN_MASK, /*!< DAC Buffer Read Pointer Top Flag Interrupt
AnnaBridge 145:64910690c574 74 Enable. */
AnnaBridge 145:64910690c574 75 kDAC_BufferReadPointerBottomInterruptEnable = DAC_C0_DACBBIEN_MASK, /*!< DAC Buffer Read Pointer Bottom Flag
AnnaBridge 145:64910690c574 76 Interrupt Enable */
AnnaBridge 145:64910690c574 77 };
AnnaBridge 145:64910690c574 78
AnnaBridge 145:64910690c574 79 /*!
AnnaBridge 145:64910690c574 80 * @brief DAC reference voltage source.
AnnaBridge 145:64910690c574 81 */
AnnaBridge 145:64910690c574 82 typedef enum _dac_reference_voltage_source
AnnaBridge 145:64910690c574 83 {
AnnaBridge 145:64910690c574 84 kDAC_ReferenceVoltageSourceVref1 = 0U, /*!< The DAC selects DACREF_1 as the reference voltage. */
AnnaBridge 145:64910690c574 85 kDAC_ReferenceVoltageSourceVref2 = 1U, /*!< The DAC selects DACREF_2 as the reference voltage. */
AnnaBridge 145:64910690c574 86 } dac_reference_voltage_source_t;
AnnaBridge 145:64910690c574 87
AnnaBridge 145:64910690c574 88 /*!
AnnaBridge 145:64910690c574 89 * @brief DAC buffer trigger mode.
AnnaBridge 145:64910690c574 90 */
AnnaBridge 145:64910690c574 91 typedef enum _dac_buffer_trigger_mode
AnnaBridge 145:64910690c574 92 {
AnnaBridge 145:64910690c574 93 kDAC_BufferTriggerByHardwareMode = 0U, /*!< The DAC hardware trigger is selected. */
AnnaBridge 145:64910690c574 94 kDAC_BufferTriggerBySoftwareMode = 1U, /*!< The DAC software trigger is selected. */
AnnaBridge 145:64910690c574 95 } dac_buffer_trigger_mode_t;
AnnaBridge 145:64910690c574 96
AnnaBridge 145:64910690c574 97 #if defined(FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION
AnnaBridge 145:64910690c574 98 /*!
AnnaBridge 145:64910690c574 99 * @brief DAC buffer watermark.
AnnaBridge 145:64910690c574 100 */
AnnaBridge 145:64910690c574 101 typedef enum _dac_buffer_watermark
AnnaBridge 145:64910690c574 102 {
AnnaBridge 145:64910690c574 103 #if defined(FSL_FEATURE_DAC_HAS_WATERMARK_1_WORD) && FSL_FEATURE_DAC_HAS_WATERMARK_1_WORD
AnnaBridge 145:64910690c574 104 kDAC_BufferWatermark1Word = 0U, /*!< 1 word away from the upper limit. */
AnnaBridge 145:64910690c574 105 #endif /* FSL_FEATURE_DAC_HAS_WATERMARK_1_WORD */
AnnaBridge 145:64910690c574 106 #if defined(FSL_FEATURE_DAC_HAS_WATERMARK_2_WORDS) && FSL_FEATURE_DAC_HAS_WATERMARK_2_WORDS
AnnaBridge 145:64910690c574 107 kDAC_BufferWatermark2Word = 1U, /*!< 2 words away from the upper limit. */
AnnaBridge 145:64910690c574 108 #endif /* FSL_FEATURE_DAC_HAS_WATERMARK_2_WORDS */
AnnaBridge 145:64910690c574 109 #if defined(FSL_FEATURE_DAC_HAS_WATERMARK_3_WORDS) && FSL_FEATURE_DAC_HAS_WATERMARK_3_WORDS
AnnaBridge 145:64910690c574 110 kDAC_BufferWatermark3Word = 2U, /*!< 3 words away from the upper limit. */
AnnaBridge 145:64910690c574 111 #endif /* FSL_FEATURE_DAC_HAS_WATERMARK_3_WORDS */
AnnaBridge 145:64910690c574 112 #if defined(FSL_FEATURE_DAC_HAS_WATERMARK_4_WORDS) && FSL_FEATURE_DAC_HAS_WATERMARK_4_WORDS
AnnaBridge 145:64910690c574 113 kDAC_BufferWatermark4Word = 3U, /*!< 4 words away from the upper limit. */
AnnaBridge 145:64910690c574 114 #endif /* FSL_FEATURE_DAC_HAS_WATERMARK_4_WORDS */
AnnaBridge 145:64910690c574 115 } dac_buffer_watermark_t;
AnnaBridge 145:64910690c574 116 #endif /* FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION */
AnnaBridge 145:64910690c574 117
AnnaBridge 145:64910690c574 118 /*!
AnnaBridge 145:64910690c574 119 * @brief DAC buffer work mode.
AnnaBridge 145:64910690c574 120 */
AnnaBridge 145:64910690c574 121 typedef enum _dac_buffer_work_mode
AnnaBridge 145:64910690c574 122 {
AnnaBridge 145:64910690c574 123 kDAC_BufferWorkAsNormalMode = 0U, /*!< Normal mode. */
AnnaBridge 145:64910690c574 124 #if defined(FSL_FEATURE_DAC_HAS_BUFFER_SWING_MODE) && FSL_FEATURE_DAC_HAS_BUFFER_SWING_MODE
AnnaBridge 145:64910690c574 125 kDAC_BufferWorkAsSwingMode, /*!< Swing mode. */
AnnaBridge 145:64910690c574 126 #endif /* FSL_FEATURE_DAC_HAS_BUFFER_SWING_MODE */
AnnaBridge 145:64910690c574 127 kDAC_BufferWorkAsOneTimeScanMode, /*!< One-Time Scan mode. */
AnnaBridge 145:64910690c574 128 #if defined(FSL_FEATURE_DAC_HAS_BUFFER_FIFO_MODE) && FSL_FEATURE_DAC_HAS_BUFFER_FIFO_MODE
AnnaBridge 145:64910690c574 129 kDAC_BufferWorkAsFIFOMode, /*!< FIFO mode. */
AnnaBridge 145:64910690c574 130 #endif /* FSL_FEATURE_DAC_HAS_BUFFER_FIFO_MODE */
AnnaBridge 145:64910690c574 131 } dac_buffer_work_mode_t;
AnnaBridge 145:64910690c574 132
AnnaBridge 145:64910690c574 133 /*!
AnnaBridge 145:64910690c574 134 * @brief DAC module configuration.
AnnaBridge 145:64910690c574 135 */
AnnaBridge 145:64910690c574 136 typedef struct _dac_config
AnnaBridge 145:64910690c574 137 {
AnnaBridge 145:64910690c574 138 dac_reference_voltage_source_t referenceVoltageSource; /*!< Select the DAC reference voltage source. */
AnnaBridge 145:64910690c574 139 bool enableLowPowerMode; /*!< Enable the low-power mode. */
AnnaBridge 145:64910690c574 140 } dac_config_t;
AnnaBridge 145:64910690c574 141
AnnaBridge 145:64910690c574 142 /*!
AnnaBridge 145:64910690c574 143 * @brief DAC buffer configuration.
AnnaBridge 145:64910690c574 144 */
AnnaBridge 145:64910690c574 145 typedef struct _dac_buffer_config
AnnaBridge 145:64910690c574 146 {
AnnaBridge 145:64910690c574 147 dac_buffer_trigger_mode_t triggerMode; /*!< Select the buffer's trigger mode. */
AnnaBridge 145:64910690c574 148 #if defined(FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION) && FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION
AnnaBridge 145:64910690c574 149 dac_buffer_watermark_t watermark; /*!< Select the buffer's watermark. */
AnnaBridge 145:64910690c574 150 #endif /* FSL_FEATURE_DAC_HAS_WATERMARK_SELECTION */
AnnaBridge 145:64910690c574 151 dac_buffer_work_mode_t workMode; /*!< Select the buffer's work mode. */
AnnaBridge 145:64910690c574 152 uint8_t upperLimit; /*!< Set the upper limit for buffer index.
AnnaBridge 145:64910690c574 153 Normally, 0-15 is available for buffer with 16 item. */
AnnaBridge 145:64910690c574 154 } dac_buffer_config_t;
AnnaBridge 145:64910690c574 155
AnnaBridge 145:64910690c574 156 /*******************************************************************************
AnnaBridge 145:64910690c574 157 * API
AnnaBridge 145:64910690c574 158 ******************************************************************************/
AnnaBridge 145:64910690c574 159 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 160 extern "C" {
AnnaBridge 145:64910690c574 161 #endif
AnnaBridge 145:64910690c574 162
AnnaBridge 145:64910690c574 163 /*!
AnnaBridge 145:64910690c574 164 * @name Initialization
AnnaBridge 145:64910690c574 165 * @{
AnnaBridge 145:64910690c574 166 */
AnnaBridge 145:64910690c574 167
AnnaBridge 145:64910690c574 168 /*!
AnnaBridge 145:64910690c574 169 * @brief Initializes the DAC module.
AnnaBridge 145:64910690c574 170 *
AnnaBridge 145:64910690c574 171 * This function initializes the DAC module, including:
AnnaBridge 145:64910690c574 172 * - Enabling the clock for DAC module.
AnnaBridge 145:64910690c574 173 * - Configuring the DAC converter with a user configuration.
AnnaBridge 145:64910690c574 174 * - Enabling the DAC module.
AnnaBridge 145:64910690c574 175 *
AnnaBridge 145:64910690c574 176 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 177 * @param config Pointer to the configuration structure. See "dac_config_t".
AnnaBridge 145:64910690c574 178 */
AnnaBridge 145:64910690c574 179 void DAC_Init(DAC_Type *base, const dac_config_t *config);
AnnaBridge 145:64910690c574 180
AnnaBridge 145:64910690c574 181 /*!
AnnaBridge 145:64910690c574 182 * @brief De-initializes the DAC module.
AnnaBridge 145:64910690c574 183 *
AnnaBridge 145:64910690c574 184 * This function de-initializes the DAC module, including:
AnnaBridge 145:64910690c574 185 * - Disabling the DAC module.
AnnaBridge 145:64910690c574 186 * - Disabling the clock for the DAC module.
AnnaBridge 145:64910690c574 187 *
AnnaBridge 145:64910690c574 188 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 189 */
AnnaBridge 145:64910690c574 190 void DAC_Deinit(DAC_Type *base);
AnnaBridge 145:64910690c574 191
AnnaBridge 145:64910690c574 192 /*!
AnnaBridge 145:64910690c574 193 * @brief Initializes the DAC user configuration structure.
AnnaBridge 145:64910690c574 194 *
AnnaBridge 145:64910690c574 195 * This function initializes the user configuration structure to a default value. The default values are:
AnnaBridge 145:64910690c574 196 * @code
AnnaBridge 145:64910690c574 197 * config->referenceVoltageSource = kDAC_ReferenceVoltageSourceVref2;
AnnaBridge 145:64910690c574 198 * config->enableLowPowerMode = false;
AnnaBridge 145:64910690c574 199 * @endcode
AnnaBridge 145:64910690c574 200 * @param config Pointer to the configuration structure. See "dac_config_t".
AnnaBridge 145:64910690c574 201 */
AnnaBridge 145:64910690c574 202 void DAC_GetDefaultConfig(dac_config_t *config);
AnnaBridge 145:64910690c574 203
AnnaBridge 145:64910690c574 204 /*!
AnnaBridge 145:64910690c574 205 * @brief Enables the DAC module.
AnnaBridge 145:64910690c574 206 *
AnnaBridge 145:64910690c574 207 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 208 * @param enable Enables/disables the feature.
AnnaBridge 145:64910690c574 209 */
AnnaBridge 145:64910690c574 210 static inline void DAC_Enable(DAC_Type *base, bool enable)
AnnaBridge 145:64910690c574 211 {
AnnaBridge 145:64910690c574 212 if (enable)
AnnaBridge 145:64910690c574 213 {
AnnaBridge 145:64910690c574 214 base->C0 |= DAC_C0_DACEN_MASK;
AnnaBridge 145:64910690c574 215 }
AnnaBridge 145:64910690c574 216 else
AnnaBridge 145:64910690c574 217 {
AnnaBridge 145:64910690c574 218 base->C0 &= ~DAC_C0_DACEN_MASK;
AnnaBridge 145:64910690c574 219 }
AnnaBridge 145:64910690c574 220 }
AnnaBridge 145:64910690c574 221
AnnaBridge 145:64910690c574 222 /* @} */
AnnaBridge 145:64910690c574 223
AnnaBridge 145:64910690c574 224 /*!
AnnaBridge 145:64910690c574 225 * @name Buffer
AnnaBridge 145:64910690c574 226 * @{
AnnaBridge 145:64910690c574 227 */
AnnaBridge 145:64910690c574 228
AnnaBridge 145:64910690c574 229 /*!
AnnaBridge 145:64910690c574 230 * @brief Enables the DAC buffer.
AnnaBridge 145:64910690c574 231 *
AnnaBridge 145:64910690c574 232 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 233 * @param enable Enables/disables the feature.
AnnaBridge 145:64910690c574 234 */
AnnaBridge 145:64910690c574 235 static inline void DAC_EnableBuffer(DAC_Type *base, bool enable)
AnnaBridge 145:64910690c574 236 {
AnnaBridge 145:64910690c574 237 if (enable)
AnnaBridge 145:64910690c574 238 {
AnnaBridge 145:64910690c574 239 base->C1 |= DAC_C1_DACBFEN_MASK;
AnnaBridge 145:64910690c574 240 }
AnnaBridge 145:64910690c574 241 else
AnnaBridge 145:64910690c574 242 {
AnnaBridge 145:64910690c574 243 base->C1 &= ~DAC_C1_DACBFEN_MASK;
AnnaBridge 145:64910690c574 244 }
AnnaBridge 145:64910690c574 245 }
AnnaBridge 145:64910690c574 246
AnnaBridge 145:64910690c574 247 /*!
AnnaBridge 145:64910690c574 248 * @brief Configures the CMP buffer.
AnnaBridge 145:64910690c574 249 *
AnnaBridge 145:64910690c574 250 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 251 * @param config Pointer to the configuration structure. See "dac_buffer_config_t".
AnnaBridge 145:64910690c574 252 */
AnnaBridge 145:64910690c574 253 void DAC_SetBufferConfig(DAC_Type *base, const dac_buffer_config_t *config);
AnnaBridge 145:64910690c574 254
AnnaBridge 145:64910690c574 255 /*!
AnnaBridge 145:64910690c574 256 * @brief Initializes the DAC buffer configuration structure.
AnnaBridge 145:64910690c574 257 *
AnnaBridge 145:64910690c574 258 * This function initializes the DAC buffer configuration structure to a default value. The default values are:
AnnaBridge 145:64910690c574 259 * @code
AnnaBridge 145:64910690c574 260 * config->triggerMode = kDAC_BufferTriggerBySoftwareMode;
AnnaBridge 145:64910690c574 261 * config->watermark = kDAC_BufferWatermark1Word;
AnnaBridge 145:64910690c574 262 * config->workMode = kDAC_BufferWorkAsNormalMode;
AnnaBridge 145:64910690c574 263 * config->upperLimit = DAC_DATL_COUNT - 1U;
AnnaBridge 145:64910690c574 264 * @endcode
AnnaBridge 145:64910690c574 265 * @param config Pointer to the configuration structure. See "dac_buffer_config_t".
AnnaBridge 145:64910690c574 266 */
AnnaBridge 145:64910690c574 267 void DAC_GetDefaultBufferConfig(dac_buffer_config_t *config);
AnnaBridge 145:64910690c574 268
AnnaBridge 145:64910690c574 269 /*!
AnnaBridge 145:64910690c574 270 * @brief Enables the DMA for DAC buffer.
AnnaBridge 145:64910690c574 271 *
AnnaBridge 145:64910690c574 272 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 273 * @param enable Enables/disables the feature.
AnnaBridge 145:64910690c574 274 */
AnnaBridge 145:64910690c574 275 static inline void DAC_EnableBufferDMA(DAC_Type *base, bool enable)
AnnaBridge 145:64910690c574 276 {
AnnaBridge 145:64910690c574 277 if (enable)
AnnaBridge 145:64910690c574 278 {
AnnaBridge 145:64910690c574 279 base->C1 |= DAC_C1_DMAEN_MASK;
AnnaBridge 145:64910690c574 280 }
AnnaBridge 145:64910690c574 281 else
AnnaBridge 145:64910690c574 282 {
AnnaBridge 145:64910690c574 283 base->C1 &= ~DAC_C1_DMAEN_MASK;
AnnaBridge 145:64910690c574 284 }
AnnaBridge 145:64910690c574 285 }
AnnaBridge 145:64910690c574 286
AnnaBridge 145:64910690c574 287 /*!
AnnaBridge 145:64910690c574 288 * @brief Sets the value for items in the buffer.
AnnaBridge 145:64910690c574 289 *
AnnaBridge 145:64910690c574 290 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 291 * @param index Setting index for items in the buffer. The available index should not exceed the size of the DAC buffer.
AnnaBridge 145:64910690c574 292 * @param value Setting value for items in the buffer. 12-bits are available.
AnnaBridge 145:64910690c574 293 */
AnnaBridge 145:64910690c574 294 void DAC_SetBufferValue(DAC_Type *base, uint8_t index, uint16_t value);
AnnaBridge 145:64910690c574 295
AnnaBridge 145:64910690c574 296 /*!
AnnaBridge 145:64910690c574 297 * @brief Triggers the buffer by software and updates the read pointer of the DAC buffer.
AnnaBridge 145:64910690c574 298 *
AnnaBridge 145:64910690c574 299 * This function triggers the function by software. The read pointer of the DAC buffer is updated with one step
AnnaBridge 145:64910690c574 300 * after this function is called. Changing the read pointer depends on the buffer's work mode.
AnnaBridge 145:64910690c574 301 *
AnnaBridge 145:64910690c574 302 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 303 */
AnnaBridge 145:64910690c574 304 static inline void DAC_DoSoftwareTriggerBuffer(DAC_Type *base)
AnnaBridge 145:64910690c574 305 {
AnnaBridge 145:64910690c574 306 base->C0 |= DAC_C0_DACSWTRG_MASK;
AnnaBridge 145:64910690c574 307 }
AnnaBridge 145:64910690c574 308
AnnaBridge 145:64910690c574 309 /*!
AnnaBridge 145:64910690c574 310 * @brief Gets the current read pointer of the DAC buffer.
AnnaBridge 145:64910690c574 311 *
AnnaBridge 145:64910690c574 312 * This function gets the current read pointer of the DAC buffer.
AnnaBridge 145:64910690c574 313 * The current output value depends on the item indexed by the read pointer. It is updated
AnnaBridge 145:64910690c574 314 * by software trigger or hardware trigger.
AnnaBridge 145:64910690c574 315 *
AnnaBridge 145:64910690c574 316 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 317 *
AnnaBridge 145:64910690c574 318 * @return Current read pointer of DAC buffer.
AnnaBridge 145:64910690c574 319 */
AnnaBridge 145:64910690c574 320 static inline uint8_t DAC_GetBufferReadPointer(DAC_Type *base)
AnnaBridge 145:64910690c574 321 {
AnnaBridge 145:64910690c574 322 return ((base->C2 & DAC_C2_DACBFRP_MASK) >> DAC_C2_DACBFRP_SHIFT);
AnnaBridge 145:64910690c574 323 }
AnnaBridge 145:64910690c574 324
AnnaBridge 145:64910690c574 325 /*!
AnnaBridge 145:64910690c574 326 * @brief Sets the current read pointer of the DAC buffer.
AnnaBridge 145:64910690c574 327 *
AnnaBridge 145:64910690c574 328 * This function sets the current read pointer of the DAC buffer.
AnnaBridge 145:64910690c574 329 * The current output value depends on the item indexed by the read pointer. It is updated by
AnnaBridge 145:64910690c574 330 * software trigger or hardware trigger. After the read pointer changes, the DAC output value also changes.
AnnaBridge 145:64910690c574 331 *
AnnaBridge 145:64910690c574 332 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 333 * @param index Setting index value for the pointer.
AnnaBridge 145:64910690c574 334 */
AnnaBridge 145:64910690c574 335 void DAC_SetBufferReadPointer(DAC_Type *base, uint8_t index);
AnnaBridge 145:64910690c574 336
AnnaBridge 145:64910690c574 337 /*!
AnnaBridge 145:64910690c574 338 * @brief Enables interrupts for the DAC buffer.
AnnaBridge 145:64910690c574 339 *
AnnaBridge 145:64910690c574 340 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 341 * @param mask Mask value for interrupts. See "_dac_buffer_interrupt_enable".
AnnaBridge 145:64910690c574 342 */
AnnaBridge 145:64910690c574 343 void DAC_EnableBufferInterrupts(DAC_Type *base, uint32_t mask);
AnnaBridge 145:64910690c574 344
AnnaBridge 145:64910690c574 345 /*!
AnnaBridge 145:64910690c574 346 * @brief Disables interrupts for the DAC buffer.
AnnaBridge 145:64910690c574 347 *
AnnaBridge 145:64910690c574 348 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 349 * @param mask Mask value for interrupts. See "_dac_buffer_interrupt_enable".
AnnaBridge 145:64910690c574 350 */
AnnaBridge 145:64910690c574 351 void DAC_DisableBufferInterrupts(DAC_Type *base, uint32_t mask);
AnnaBridge 145:64910690c574 352
AnnaBridge 145:64910690c574 353 /*!
AnnaBridge 145:64910690c574 354 * @brief Gets the flags of events for the DAC buffer.
AnnaBridge 145:64910690c574 355 *
AnnaBridge 145:64910690c574 356 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 357 *
AnnaBridge 145:64910690c574 358 * @return Mask value for the asserted flags. See "_dac_buffer_status_flags".
AnnaBridge 145:64910690c574 359 */
AnnaBridge 145:64910690c574 360 uint32_t DAC_GetBufferStatusFlags(DAC_Type *base);
AnnaBridge 145:64910690c574 361
AnnaBridge 145:64910690c574 362 /*!
AnnaBridge 145:64910690c574 363 * @brief Clears the flags of events for the DAC buffer.
AnnaBridge 145:64910690c574 364 *
AnnaBridge 145:64910690c574 365 * @param base DAC peripheral base address.
AnnaBridge 145:64910690c574 366 * @param mask Mask value for flags. See "_dac_buffer_status_flags_t".
AnnaBridge 145:64910690c574 367 */
AnnaBridge 145:64910690c574 368 void DAC_ClearBufferStatusFlags(DAC_Type *base, uint32_t mask);
AnnaBridge 145:64910690c574 369
AnnaBridge 145:64910690c574 370 /* @} */
AnnaBridge 145:64910690c574 371
AnnaBridge 145:64910690c574 372 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 373 }
AnnaBridge 145:64910690c574 374 #endif
AnnaBridge 145:64910690c574 375 /*!
AnnaBridge 145:64910690c574 376 * @}
AnnaBridge 145:64910690c574 377 */
AnnaBridge 145:64910690c574 378 #endif /* _FSL_DAC_H_ */