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_EFM32LG_STK3600/TARGET_Silicon_Labs/TARGET_EFM32/emlib/inc/em_dac.h@159:7130f322cb7e, 2017-12-21 (annotated)
- Committer:
- mbed_official
- Date:
- Thu Dec 21 18:20:02 2017 +0000
- Revision:
- 159:7130f322cb7e
- Parent:
- 156:ff21514d8981
mbed library version 157
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 156:ff21514d8981 | 1 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 2 | * @file em_dac.h |
AnnaBridge | 156:ff21514d8981 | 3 | * @brief Digital to Analog Converter (DAC) peripheral API |
mbed_official | 159:7130f322cb7e | 4 | * @version 5.3.3 |
AnnaBridge | 156:ff21514d8981 | 5 | ******************************************************************************* |
mbed_official | 159:7130f322cb7e | 6 | * # License |
AnnaBridge | 156:ff21514d8981 | 7 | * <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b> |
AnnaBridge | 156:ff21514d8981 | 8 | ******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 9 | * |
AnnaBridge | 156:ff21514d8981 | 10 | * Permission is granted to anyone to use this software for any purpose, |
AnnaBridge | 156:ff21514d8981 | 11 | * including commercial applications, and to alter it and redistribute it |
AnnaBridge | 156:ff21514d8981 | 12 | * freely, subject to the following restrictions: |
AnnaBridge | 156:ff21514d8981 | 13 | * |
AnnaBridge | 156:ff21514d8981 | 14 | * 1. The origin of this software must not be misrepresented; you must not |
AnnaBridge | 156:ff21514d8981 | 15 | * claim that you wrote the original software. |
AnnaBridge | 156:ff21514d8981 | 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
AnnaBridge | 156:ff21514d8981 | 17 | * misrepresented as being the original software. |
AnnaBridge | 156:ff21514d8981 | 18 | * 3. This notice may not be removed or altered from any source distribution. |
AnnaBridge | 156:ff21514d8981 | 19 | * |
AnnaBridge | 156:ff21514d8981 | 20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
AnnaBridge | 156:ff21514d8981 | 21 | * obligation to support this Software. Silicon Labs is providing the |
AnnaBridge | 156:ff21514d8981 | 22 | * Software "AS IS", with no express or implied warranties of any kind, |
AnnaBridge | 156:ff21514d8981 | 23 | * including, but not limited to, any implied warranties of merchantability |
AnnaBridge | 156:ff21514d8981 | 24 | * or fitness for any particular purpose or warranties against infringement |
AnnaBridge | 156:ff21514d8981 | 25 | * of any proprietary rights of a third party. |
AnnaBridge | 156:ff21514d8981 | 26 | * |
AnnaBridge | 156:ff21514d8981 | 27 | * Silicon Labs will not be liable for any consequential, incidental, or |
AnnaBridge | 156:ff21514d8981 | 28 | * special damages, or any other relief, or for any claim by any third party, |
AnnaBridge | 156:ff21514d8981 | 29 | * arising from your use of this Software. |
AnnaBridge | 156:ff21514d8981 | 30 | * |
AnnaBridge | 156:ff21514d8981 | 31 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 32 | |
AnnaBridge | 156:ff21514d8981 | 33 | #ifndef EM_DAC_H |
AnnaBridge | 156:ff21514d8981 | 34 | #define EM_DAC_H |
AnnaBridge | 156:ff21514d8981 | 35 | |
AnnaBridge | 156:ff21514d8981 | 36 | #include "em_device.h" |
AnnaBridge | 156:ff21514d8981 | 37 | |
AnnaBridge | 156:ff21514d8981 | 38 | #if defined(DAC_COUNT) && (DAC_COUNT > 0) |
AnnaBridge | 156:ff21514d8981 | 39 | |
AnnaBridge | 156:ff21514d8981 | 40 | #include "em_assert.h" |
AnnaBridge | 156:ff21514d8981 | 41 | #include <stdbool.h> |
AnnaBridge | 156:ff21514d8981 | 42 | |
AnnaBridge | 156:ff21514d8981 | 43 | #ifdef __cplusplus |
AnnaBridge | 156:ff21514d8981 | 44 | extern "C" { |
AnnaBridge | 156:ff21514d8981 | 45 | #endif |
AnnaBridge | 156:ff21514d8981 | 46 | |
AnnaBridge | 156:ff21514d8981 | 47 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 48 | * @addtogroup emlib |
AnnaBridge | 156:ff21514d8981 | 49 | * @{ |
AnnaBridge | 156:ff21514d8981 | 50 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 51 | |
AnnaBridge | 156:ff21514d8981 | 52 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 53 | * @addtogroup DAC |
AnnaBridge | 156:ff21514d8981 | 54 | * @{ |
AnnaBridge | 156:ff21514d8981 | 55 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 56 | |
AnnaBridge | 156:ff21514d8981 | 57 | /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */ |
AnnaBridge | 156:ff21514d8981 | 58 | |
AnnaBridge | 156:ff21514d8981 | 59 | /** Validation of DAC register block pointer reference for assert statements. */ |
AnnaBridge | 156:ff21514d8981 | 60 | #define DAC_REF_VALID(ref) ((ref) == DAC0) |
AnnaBridge | 156:ff21514d8981 | 61 | |
AnnaBridge | 156:ff21514d8981 | 62 | /** @endcond */ |
AnnaBridge | 156:ff21514d8981 | 63 | |
AnnaBridge | 156:ff21514d8981 | 64 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 65 | ******************************** ENUMS ************************************ |
AnnaBridge | 156:ff21514d8981 | 66 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 67 | |
AnnaBridge | 156:ff21514d8981 | 68 | /** Conversion mode. */ |
mbed_official | 159:7130f322cb7e | 69 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 70 | dacConvModeContinuous = _DAC_CTRL_CONVMODE_CONTINUOUS, /**< Continuous mode. */ |
AnnaBridge | 156:ff21514d8981 | 71 | dacConvModeSampleHold = _DAC_CTRL_CONVMODE_SAMPLEHOLD, /**< Sample/hold mode. */ |
AnnaBridge | 156:ff21514d8981 | 72 | dacConvModeSampleOff = _DAC_CTRL_CONVMODE_SAMPLEOFF /**< Sample/shut off mode. */ |
AnnaBridge | 156:ff21514d8981 | 73 | } DAC_ConvMode_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 74 | |
AnnaBridge | 156:ff21514d8981 | 75 | /** Output mode. */ |
mbed_official | 159:7130f322cb7e | 76 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 77 | dacOutputDisable = _DAC_CTRL_OUTMODE_DISABLE, /**< Output to pin and ADC disabled. */ |
AnnaBridge | 156:ff21514d8981 | 78 | dacOutputPin = _DAC_CTRL_OUTMODE_PIN, /**< Output to pin only. */ |
AnnaBridge | 156:ff21514d8981 | 79 | dacOutputADC = _DAC_CTRL_OUTMODE_ADC, /**< Output to ADC only */ |
AnnaBridge | 156:ff21514d8981 | 80 | dacOutputPinADC = _DAC_CTRL_OUTMODE_PINADC /**< Output to pin and ADC. */ |
AnnaBridge | 156:ff21514d8981 | 81 | } DAC_Output_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 82 | |
AnnaBridge | 156:ff21514d8981 | 83 | /** Peripheral Reflex System signal used to trigger single sample. */ |
mbed_official | 159:7130f322cb7e | 84 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 85 | dacPRSSELCh0 = _DAC_CH0CTRL_PRSSEL_PRSCH0, /**< PRS channel 0. */ |
AnnaBridge | 156:ff21514d8981 | 86 | dacPRSSELCh1 = _DAC_CH0CTRL_PRSSEL_PRSCH1, /**< PRS channel 1. */ |
AnnaBridge | 156:ff21514d8981 | 87 | dacPRSSELCh2 = _DAC_CH0CTRL_PRSSEL_PRSCH2, /**< PRS channel 2. */ |
AnnaBridge | 156:ff21514d8981 | 88 | dacPRSSELCh3 = _DAC_CH0CTRL_PRSSEL_PRSCH3, /**< PRS channel 3. */ |
mbed_official | 159:7130f322cb7e | 89 | #if defined(_DAC_CH0CTRL_PRSSEL_PRSCH4) |
AnnaBridge | 156:ff21514d8981 | 90 | dacPRSSELCh4 = _DAC_CH0CTRL_PRSSEL_PRSCH4, /**< PRS channel 4. */ |
AnnaBridge | 156:ff21514d8981 | 91 | #endif |
mbed_official | 159:7130f322cb7e | 92 | #if defined(_DAC_CH0CTRL_PRSSEL_PRSCH5) |
AnnaBridge | 156:ff21514d8981 | 93 | dacPRSSELCh5 = _DAC_CH0CTRL_PRSSEL_PRSCH5, /**< PRS channel 5. */ |
AnnaBridge | 156:ff21514d8981 | 94 | #endif |
mbed_official | 159:7130f322cb7e | 95 | #if defined(_DAC_CH0CTRL_PRSSEL_PRSCH6) |
AnnaBridge | 156:ff21514d8981 | 96 | dacPRSSELCh6 = _DAC_CH0CTRL_PRSSEL_PRSCH6, /**< PRS channel 6. */ |
AnnaBridge | 156:ff21514d8981 | 97 | #endif |
mbed_official | 159:7130f322cb7e | 98 | #if defined(_DAC_CH0CTRL_PRSSEL_PRSCH7) |
AnnaBridge | 156:ff21514d8981 | 99 | dacPRSSELCh7 = _DAC_CH0CTRL_PRSSEL_PRSCH7, /**< PRS channel 7. */ |
AnnaBridge | 156:ff21514d8981 | 100 | #endif |
mbed_official | 159:7130f322cb7e | 101 | #if defined(_DAC_CH0CTRL_PRSSEL_PRSCH8) |
AnnaBridge | 156:ff21514d8981 | 102 | dacPRSSELCh8 = _DAC_CH0CTRL_PRSSEL_PRSCH8, /**< PRS channel 8. */ |
AnnaBridge | 156:ff21514d8981 | 103 | #endif |
mbed_official | 159:7130f322cb7e | 104 | #if defined(_DAC_CH0CTRL_PRSSEL_PRSCH9) |
AnnaBridge | 156:ff21514d8981 | 105 | dacPRSSELCh9 = _DAC_CH0CTRL_PRSSEL_PRSCH9, /**< PRS channel 9. */ |
AnnaBridge | 156:ff21514d8981 | 106 | #endif |
mbed_official | 159:7130f322cb7e | 107 | #if defined(_DAC_CH0CTRL_PRSSEL_PRSCH10) |
AnnaBridge | 156:ff21514d8981 | 108 | dacPRSSELCh10 = _DAC_CH0CTRL_PRSSEL_PRSCH10, /**< PRS channel 10. */ |
AnnaBridge | 156:ff21514d8981 | 109 | #endif |
mbed_official | 159:7130f322cb7e | 110 | #if defined(_DAC_CH0CTRL_PRSSEL_PRSCH11) |
AnnaBridge | 156:ff21514d8981 | 111 | dacPRSSELCh11 = _DAC_CH0CTRL_PRSSEL_PRSCH11, /**< PRS channel 11. */ |
AnnaBridge | 156:ff21514d8981 | 112 | #endif |
AnnaBridge | 156:ff21514d8981 | 113 | } DAC_PRSSEL_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 114 | |
AnnaBridge | 156:ff21514d8981 | 115 | /** Reference voltage for DAC. */ |
mbed_official | 159:7130f322cb7e | 116 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 117 | dacRef1V25 = _DAC_CTRL_REFSEL_1V25, /**< Internal 1.25V bandgap reference. */ |
AnnaBridge | 156:ff21514d8981 | 118 | dacRef2V5 = _DAC_CTRL_REFSEL_2V5, /**< Internal 2.5V bandgap reference. */ |
AnnaBridge | 156:ff21514d8981 | 119 | dacRefVDD = _DAC_CTRL_REFSEL_VDD /**< VDD reference. */ |
AnnaBridge | 156:ff21514d8981 | 120 | } DAC_Ref_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 121 | |
AnnaBridge | 156:ff21514d8981 | 122 | /** Refresh interval. */ |
mbed_official | 159:7130f322cb7e | 123 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 124 | dacRefresh8 = _DAC_CTRL_REFRSEL_8CYCLES, /**< Refresh every 8 prescaled cycles. */ |
AnnaBridge | 156:ff21514d8981 | 125 | dacRefresh16 = _DAC_CTRL_REFRSEL_16CYCLES, /**< Refresh every 16 prescaled cycles. */ |
AnnaBridge | 156:ff21514d8981 | 126 | dacRefresh32 = _DAC_CTRL_REFRSEL_32CYCLES, /**< Refresh every 32 prescaled cycles. */ |
AnnaBridge | 156:ff21514d8981 | 127 | dacRefresh64 = _DAC_CTRL_REFRSEL_64CYCLES /**< Refresh every 64 prescaled cycles. */ |
AnnaBridge | 156:ff21514d8981 | 128 | } DAC_Refresh_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 129 | |
AnnaBridge | 156:ff21514d8981 | 130 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 131 | ******************************* STRUCTS *********************************** |
AnnaBridge | 156:ff21514d8981 | 132 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 133 | |
AnnaBridge | 156:ff21514d8981 | 134 | /** DAC init structure, common for both channels. */ |
mbed_official | 159:7130f322cb7e | 135 | typedef struct { |
AnnaBridge | 156:ff21514d8981 | 136 | /** Refresh interval. Only used if REFREN bit set for a DAC channel. */ |
AnnaBridge | 156:ff21514d8981 | 137 | DAC_Refresh_TypeDef refresh; |
AnnaBridge | 156:ff21514d8981 | 138 | |
AnnaBridge | 156:ff21514d8981 | 139 | /** Reference voltage to use. */ |
AnnaBridge | 156:ff21514d8981 | 140 | DAC_Ref_TypeDef reference; |
AnnaBridge | 156:ff21514d8981 | 141 | |
AnnaBridge | 156:ff21514d8981 | 142 | /** Output mode */ |
AnnaBridge | 156:ff21514d8981 | 143 | DAC_Output_TypeDef outMode; |
AnnaBridge | 156:ff21514d8981 | 144 | |
AnnaBridge | 156:ff21514d8981 | 145 | /** Conversion mode. */ |
AnnaBridge | 156:ff21514d8981 | 146 | DAC_ConvMode_TypeDef convMode; |
AnnaBridge | 156:ff21514d8981 | 147 | |
AnnaBridge | 156:ff21514d8981 | 148 | /** |
AnnaBridge | 156:ff21514d8981 | 149 | * Prescaler used to get DAC clock. Derived as follows: |
AnnaBridge | 156:ff21514d8981 | 150 | * DACclk=HFPERclk/(2^prescale). The DAC clock should be <= 1MHz. |
AnnaBridge | 156:ff21514d8981 | 151 | */ |
AnnaBridge | 156:ff21514d8981 | 152 | uint8_t prescale; |
AnnaBridge | 156:ff21514d8981 | 153 | |
AnnaBridge | 156:ff21514d8981 | 154 | /** Enable/disable use of low pass filter on output. */ |
AnnaBridge | 156:ff21514d8981 | 155 | bool lpEnable; |
AnnaBridge | 156:ff21514d8981 | 156 | |
AnnaBridge | 156:ff21514d8981 | 157 | /** Enable/disable reset of prescaler on ch0 start. */ |
AnnaBridge | 156:ff21514d8981 | 158 | bool ch0ResetPre; |
AnnaBridge | 156:ff21514d8981 | 159 | |
AnnaBridge | 156:ff21514d8981 | 160 | /** Enable/disable output enable control by CH1 PRS signal. */ |
AnnaBridge | 156:ff21514d8981 | 161 | bool outEnablePRS; |
AnnaBridge | 156:ff21514d8981 | 162 | |
AnnaBridge | 156:ff21514d8981 | 163 | /** Enable/disable sine mode. */ |
AnnaBridge | 156:ff21514d8981 | 164 | bool sineEnable; |
AnnaBridge | 156:ff21514d8981 | 165 | |
AnnaBridge | 156:ff21514d8981 | 166 | /** Select if single ended or differential mode. */ |
AnnaBridge | 156:ff21514d8981 | 167 | bool diff; |
AnnaBridge | 156:ff21514d8981 | 168 | } DAC_Init_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 169 | |
AnnaBridge | 156:ff21514d8981 | 170 | /** Default config for DAC init structure. */ |
AnnaBridge | 156:ff21514d8981 | 171 | #define DAC_INIT_DEFAULT \ |
mbed_official | 159:7130f322cb7e | 172 | { \ |
mbed_official | 159:7130f322cb7e | 173 | dacRefresh8, /* Refresh every 8 prescaled cycles. */ \ |
mbed_official | 159:7130f322cb7e | 174 | dacRef1V25, /* 1.25V internal reference. */ \ |
mbed_official | 159:7130f322cb7e | 175 | dacOutputPin, /* Output to pin only. */ \ |
mbed_official | 159:7130f322cb7e | 176 | dacConvModeContinuous, /* Continuous mode. */ \ |
mbed_official | 159:7130f322cb7e | 177 | 0, /* No prescaling. */ \ |
mbed_official | 159:7130f322cb7e | 178 | false, /* Do not enable low pass filter. */ \ |
mbed_official | 159:7130f322cb7e | 179 | false, /* Do not reset prescaler on ch0 start. */ \ |
mbed_official | 159:7130f322cb7e | 180 | false, /* DAC output enable always on. */ \ |
mbed_official | 159:7130f322cb7e | 181 | false, /* Disable sine mode. */ \ |
mbed_official | 159:7130f322cb7e | 182 | false /* Single ended mode. */ \ |
mbed_official | 159:7130f322cb7e | 183 | } |
AnnaBridge | 156:ff21514d8981 | 184 | |
AnnaBridge | 156:ff21514d8981 | 185 | /** DAC channel init structure. */ |
mbed_official | 159:7130f322cb7e | 186 | typedef struct { |
AnnaBridge | 156:ff21514d8981 | 187 | /** Enable channel. */ |
AnnaBridge | 156:ff21514d8981 | 188 | bool enable; |
AnnaBridge | 156:ff21514d8981 | 189 | |
AnnaBridge | 156:ff21514d8981 | 190 | /** |
AnnaBridge | 156:ff21514d8981 | 191 | * Peripheral reflex system trigger enable. If false, channel is triggered |
AnnaBridge | 156:ff21514d8981 | 192 | * by writing to CHnDATA. |
AnnaBridge | 156:ff21514d8981 | 193 | */ |
AnnaBridge | 156:ff21514d8981 | 194 | bool prsEnable; |
AnnaBridge | 156:ff21514d8981 | 195 | |
AnnaBridge | 156:ff21514d8981 | 196 | /** |
AnnaBridge | 156:ff21514d8981 | 197 | * Enable/disable automatic refresh of channel. Refresh interval must be |
AnnaBridge | 156:ff21514d8981 | 198 | * defined in common control init, please see DAC_Init(). |
AnnaBridge | 156:ff21514d8981 | 199 | */ |
AnnaBridge | 156:ff21514d8981 | 200 | bool refreshEnable; |
AnnaBridge | 156:ff21514d8981 | 201 | |
AnnaBridge | 156:ff21514d8981 | 202 | /** |
AnnaBridge | 156:ff21514d8981 | 203 | * Peripheral reflex system trigger selection. Only applicable if @p prsEnable |
AnnaBridge | 156:ff21514d8981 | 204 | * is enabled. |
AnnaBridge | 156:ff21514d8981 | 205 | */ |
AnnaBridge | 156:ff21514d8981 | 206 | DAC_PRSSEL_TypeDef prsSel; |
AnnaBridge | 156:ff21514d8981 | 207 | } DAC_InitChannel_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 208 | |
AnnaBridge | 156:ff21514d8981 | 209 | /** Default config for DAC channel init structure. */ |
AnnaBridge | 156:ff21514d8981 | 210 | #define DAC_INITCHANNEL_DEFAULT \ |
mbed_official | 159:7130f322cb7e | 211 | { \ |
mbed_official | 159:7130f322cb7e | 212 | false, /* Leave channel disabled when init done. */ \ |
mbed_official | 159:7130f322cb7e | 213 | false, /* Disable PRS triggering. */ \ |
mbed_official | 159:7130f322cb7e | 214 | false, /* Channel not refreshed automatically. */ \ |
mbed_official | 159:7130f322cb7e | 215 | dacPRSSELCh0 /* Select PRS ch0 (if PRS triggering enabled). */ \ |
mbed_official | 159:7130f322cb7e | 216 | } |
AnnaBridge | 156:ff21514d8981 | 217 | |
AnnaBridge | 156:ff21514d8981 | 218 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 219 | ***************************** PROTOTYPES ********************************** |
AnnaBridge | 156:ff21514d8981 | 220 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 221 | |
AnnaBridge | 156:ff21514d8981 | 222 | void DAC_Enable(DAC_TypeDef *dac, unsigned int ch, bool enable); |
AnnaBridge | 156:ff21514d8981 | 223 | void DAC_Init(DAC_TypeDef *dac, const DAC_Init_TypeDef *init); |
AnnaBridge | 156:ff21514d8981 | 224 | void DAC_InitChannel(DAC_TypeDef *dac, |
AnnaBridge | 156:ff21514d8981 | 225 | const DAC_InitChannel_TypeDef *init, |
AnnaBridge | 156:ff21514d8981 | 226 | unsigned int ch); |
AnnaBridge | 156:ff21514d8981 | 227 | void DAC_ChannelOutputSet(DAC_TypeDef *dac, |
AnnaBridge | 156:ff21514d8981 | 228 | unsigned int channel, |
AnnaBridge | 156:ff21514d8981 | 229 | uint32_t value); |
AnnaBridge | 156:ff21514d8981 | 230 | |
AnnaBridge | 156:ff21514d8981 | 231 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 232 | * @brief |
AnnaBridge | 156:ff21514d8981 | 233 | * Set the output signal of DAC channel 0 to a given value. |
AnnaBridge | 156:ff21514d8981 | 234 | * |
AnnaBridge | 156:ff21514d8981 | 235 | * @details |
AnnaBridge | 156:ff21514d8981 | 236 | * This function sets the output signal of DAC channel 0 by writing @p value |
AnnaBridge | 156:ff21514d8981 | 237 | * to the CH0DATA register. |
AnnaBridge | 156:ff21514d8981 | 238 | * |
AnnaBridge | 156:ff21514d8981 | 239 | * @param[in] dac |
AnnaBridge | 156:ff21514d8981 | 240 | * Pointer to DAC peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 241 | * |
AnnaBridge | 156:ff21514d8981 | 242 | * @param[in] value |
AnnaBridge | 156:ff21514d8981 | 243 | * Value to write to the channel 0 output register CH0DATA. |
AnnaBridge | 156:ff21514d8981 | 244 | ******************************************************************************/ |
mbed_official | 159:7130f322cb7e | 245 | __STATIC_INLINE void DAC_Channel0OutputSet(DAC_TypeDef *dac, |
mbed_official | 159:7130f322cb7e | 246 | uint32_t value) |
AnnaBridge | 156:ff21514d8981 | 247 | { |
mbed_official | 159:7130f322cb7e | 248 | EFM_ASSERT(value <= _DAC_CH0DATA_MASK); |
AnnaBridge | 156:ff21514d8981 | 249 | dac->CH0DATA = value; |
AnnaBridge | 156:ff21514d8981 | 250 | } |
AnnaBridge | 156:ff21514d8981 | 251 | |
AnnaBridge | 156:ff21514d8981 | 252 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 253 | * @brief |
AnnaBridge | 156:ff21514d8981 | 254 | * Set the output signal of DAC channel 1 to a given value. |
AnnaBridge | 156:ff21514d8981 | 255 | * |
AnnaBridge | 156:ff21514d8981 | 256 | * @details |
AnnaBridge | 156:ff21514d8981 | 257 | * This function sets the output signal of DAC channel 1 by writing @p value |
AnnaBridge | 156:ff21514d8981 | 258 | * to the CH1DATA register. |
AnnaBridge | 156:ff21514d8981 | 259 | * |
AnnaBridge | 156:ff21514d8981 | 260 | * @param[in] dac |
AnnaBridge | 156:ff21514d8981 | 261 | * Pointer to DAC peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 262 | * |
AnnaBridge | 156:ff21514d8981 | 263 | * @param[in] value |
AnnaBridge | 156:ff21514d8981 | 264 | * Value to write to the channel 1 output register CH1DATA. |
AnnaBridge | 156:ff21514d8981 | 265 | ******************************************************************************/ |
mbed_official | 159:7130f322cb7e | 266 | __STATIC_INLINE void DAC_Channel1OutputSet(DAC_TypeDef *dac, |
mbed_official | 159:7130f322cb7e | 267 | uint32_t value) |
AnnaBridge | 156:ff21514d8981 | 268 | { |
mbed_official | 159:7130f322cb7e | 269 | EFM_ASSERT(value <= _DAC_CH1DATA_MASK); |
AnnaBridge | 156:ff21514d8981 | 270 | dac->CH1DATA = value; |
AnnaBridge | 156:ff21514d8981 | 271 | } |
AnnaBridge | 156:ff21514d8981 | 272 | |
AnnaBridge | 156:ff21514d8981 | 273 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 274 | * @brief |
AnnaBridge | 156:ff21514d8981 | 275 | * Clear one or more pending DAC interrupts. |
AnnaBridge | 156:ff21514d8981 | 276 | * |
AnnaBridge | 156:ff21514d8981 | 277 | * @param[in] dac |
AnnaBridge | 156:ff21514d8981 | 278 | * Pointer to DAC peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 279 | * |
AnnaBridge | 156:ff21514d8981 | 280 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 281 | * Pending DAC interrupt source to clear. Use a bitwise logic OR combination of |
AnnaBridge | 156:ff21514d8981 | 282 | * valid interrupt flags for the DAC module (DAC_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 283 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 284 | __STATIC_INLINE void DAC_IntClear(DAC_TypeDef *dac, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 285 | { |
AnnaBridge | 156:ff21514d8981 | 286 | dac->IFC = flags; |
AnnaBridge | 156:ff21514d8981 | 287 | } |
AnnaBridge | 156:ff21514d8981 | 288 | |
AnnaBridge | 156:ff21514d8981 | 289 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 290 | * @brief |
AnnaBridge | 156:ff21514d8981 | 291 | * Disable one or more DAC interrupts. |
AnnaBridge | 156:ff21514d8981 | 292 | * |
AnnaBridge | 156:ff21514d8981 | 293 | * @param[in] dac |
AnnaBridge | 156:ff21514d8981 | 294 | * Pointer to DAC peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 295 | * |
AnnaBridge | 156:ff21514d8981 | 296 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 297 | * DAC interrupt sources to disable. Use a bitwise logic OR combination of |
AnnaBridge | 156:ff21514d8981 | 298 | * valid interrupt flags for the DAC module (DAC_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 299 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 300 | __STATIC_INLINE void DAC_IntDisable(DAC_TypeDef *dac, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 301 | { |
AnnaBridge | 156:ff21514d8981 | 302 | dac->IEN &= ~flags; |
AnnaBridge | 156:ff21514d8981 | 303 | } |
AnnaBridge | 156:ff21514d8981 | 304 | |
AnnaBridge | 156:ff21514d8981 | 305 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 306 | * @brief |
AnnaBridge | 156:ff21514d8981 | 307 | * Enable one or more DAC interrupts. |
AnnaBridge | 156:ff21514d8981 | 308 | * |
AnnaBridge | 156:ff21514d8981 | 309 | * @note |
AnnaBridge | 156:ff21514d8981 | 310 | * Depending on the use, a pending interrupt may already be set prior to |
AnnaBridge | 156:ff21514d8981 | 311 | * enabling the interrupt. Consider using DAC_IntClear() prior to enabling |
AnnaBridge | 156:ff21514d8981 | 312 | * if such a pending interrupt should be ignored. |
AnnaBridge | 156:ff21514d8981 | 313 | * |
AnnaBridge | 156:ff21514d8981 | 314 | * @param[in] dac |
AnnaBridge | 156:ff21514d8981 | 315 | * Pointer to DAC peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 316 | * |
AnnaBridge | 156:ff21514d8981 | 317 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 318 | * DAC interrupt sources to enable. Use a bitwise logic OR combination of |
AnnaBridge | 156:ff21514d8981 | 319 | * valid interrupt flags for the DAC module (DAC_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 320 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 321 | __STATIC_INLINE void DAC_IntEnable(DAC_TypeDef *dac, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 322 | { |
AnnaBridge | 156:ff21514d8981 | 323 | dac->IEN |= flags; |
AnnaBridge | 156:ff21514d8981 | 324 | } |
AnnaBridge | 156:ff21514d8981 | 325 | |
AnnaBridge | 156:ff21514d8981 | 326 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 327 | * @brief |
AnnaBridge | 156:ff21514d8981 | 328 | * Get pending DAC interrupt flags. |
AnnaBridge | 156:ff21514d8981 | 329 | * |
AnnaBridge | 156:ff21514d8981 | 330 | * @note |
AnnaBridge | 156:ff21514d8981 | 331 | * The event bits are not cleared by the use of this function. |
AnnaBridge | 156:ff21514d8981 | 332 | * |
AnnaBridge | 156:ff21514d8981 | 333 | * @param[in] dac |
AnnaBridge | 156:ff21514d8981 | 334 | * Pointer to DAC peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 335 | * |
AnnaBridge | 156:ff21514d8981 | 336 | * @return |
AnnaBridge | 156:ff21514d8981 | 337 | * DAC interrupt sources pending. A bitwise logic OR combination of valid |
AnnaBridge | 156:ff21514d8981 | 338 | * interrupt flags for the DAC module (DAC_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 339 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 340 | __STATIC_INLINE uint32_t DAC_IntGet(DAC_TypeDef *dac) |
AnnaBridge | 156:ff21514d8981 | 341 | { |
AnnaBridge | 156:ff21514d8981 | 342 | return dac->IF; |
AnnaBridge | 156:ff21514d8981 | 343 | } |
AnnaBridge | 156:ff21514d8981 | 344 | |
AnnaBridge | 156:ff21514d8981 | 345 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 346 | * @brief |
AnnaBridge | 156:ff21514d8981 | 347 | * Get enabled and pending DAC interrupt flags. |
AnnaBridge | 156:ff21514d8981 | 348 | * Useful for handling more interrupt sources in the same interrupt handler. |
AnnaBridge | 156:ff21514d8981 | 349 | * |
AnnaBridge | 156:ff21514d8981 | 350 | * @param[in] dac |
AnnaBridge | 156:ff21514d8981 | 351 | * Pointer to DAC peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 352 | * |
AnnaBridge | 156:ff21514d8981 | 353 | * @note |
AnnaBridge | 156:ff21514d8981 | 354 | * Interrupt flags are not cleared by the use of this function. |
AnnaBridge | 156:ff21514d8981 | 355 | * |
AnnaBridge | 156:ff21514d8981 | 356 | * @return |
AnnaBridge | 156:ff21514d8981 | 357 | * Pending and enabled DAC interrupt sources. |
AnnaBridge | 156:ff21514d8981 | 358 | * The return value is the bitwise AND combination of |
AnnaBridge | 156:ff21514d8981 | 359 | * - the OR combination of enabled interrupt sources in DACx_IEN_nnn |
AnnaBridge | 156:ff21514d8981 | 360 | * register (DACx_IEN_nnn) and |
AnnaBridge | 156:ff21514d8981 | 361 | * - the OR combination of valid interrupt flags of the DAC module |
AnnaBridge | 156:ff21514d8981 | 362 | * (DACx_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 363 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 364 | __STATIC_INLINE uint32_t DAC_IntGetEnabled(DAC_TypeDef *dac) |
AnnaBridge | 156:ff21514d8981 | 365 | { |
AnnaBridge | 156:ff21514d8981 | 366 | uint32_t ien; |
AnnaBridge | 156:ff21514d8981 | 367 | |
AnnaBridge | 156:ff21514d8981 | 368 | /* Store DAC->IEN in temporary variable in order to define explicit order |
AnnaBridge | 156:ff21514d8981 | 369 | * of volatile accesses. */ |
AnnaBridge | 156:ff21514d8981 | 370 | ien = dac->IEN; |
AnnaBridge | 156:ff21514d8981 | 371 | |
AnnaBridge | 156:ff21514d8981 | 372 | /* Bitwise AND of pending and enabled interrupts */ |
AnnaBridge | 156:ff21514d8981 | 373 | return dac->IF & ien; |
AnnaBridge | 156:ff21514d8981 | 374 | } |
AnnaBridge | 156:ff21514d8981 | 375 | |
AnnaBridge | 156:ff21514d8981 | 376 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 377 | * @brief |
AnnaBridge | 156:ff21514d8981 | 378 | * Set one or more pending DAC interrupts from SW. |
AnnaBridge | 156:ff21514d8981 | 379 | * |
AnnaBridge | 156:ff21514d8981 | 380 | * @param[in] dac |
AnnaBridge | 156:ff21514d8981 | 381 | * Pointer to DAC peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 382 | * |
AnnaBridge | 156:ff21514d8981 | 383 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 384 | * DAC interrupt sources to set to pending. Use a bitwise logic OR combination |
AnnaBridge | 156:ff21514d8981 | 385 | * of valid interrupt flags for the DAC module (DAC_IF_nnn). |
AnnaBridge | 156:ff21514d8981 | 386 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 387 | __STATIC_INLINE void DAC_IntSet(DAC_TypeDef *dac, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 388 | { |
AnnaBridge | 156:ff21514d8981 | 389 | dac->IFS = flags; |
AnnaBridge | 156:ff21514d8981 | 390 | } |
AnnaBridge | 156:ff21514d8981 | 391 | |
AnnaBridge | 156:ff21514d8981 | 392 | uint8_t DAC_PrescaleCalc(uint32_t dacFreq, uint32_t hfperFreq); |
AnnaBridge | 156:ff21514d8981 | 393 | void DAC_Reset(DAC_TypeDef *dac); |
AnnaBridge | 156:ff21514d8981 | 394 | |
AnnaBridge | 156:ff21514d8981 | 395 | /** @} (end addtogroup DAC) */ |
AnnaBridge | 156:ff21514d8981 | 396 | /** @} (end addtogroup emlib) */ |
AnnaBridge | 156:ff21514d8981 | 397 | |
AnnaBridge | 156:ff21514d8981 | 398 | #ifdef __cplusplus |
AnnaBridge | 156:ff21514d8981 | 399 | } |
AnnaBridge | 156:ff21514d8981 | 400 | #endif |
AnnaBridge | 156:ff21514d8981 | 401 | |
AnnaBridge | 156:ff21514d8981 | 402 | #endif /* defined(DAC_COUNT) && (DAC_COUNT > 0) */ |
AnnaBridge | 156:ff21514d8981 | 403 | #endif /* EM_DAC_H */ |