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