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:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

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