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