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_EFM32HG_STK3400/TARGET_Silicon_Labs/TARGET_EFM32/emlib/inc/em_idac.h@136:ef9c61f8c49f, 2017-02-14 (annotated)
- Committer:
- Kojto
- Date:
- Tue Feb 14 11:24:20 2017 +0000
- Revision:
- 136:ef9c61f8c49f
- Parent:
- 128:9bcdf88f62b0
- Child:
- 139:856d2700e60b
Release 136 of the mbed library
Ports for Upcoming Targets
Fixes and Changes
3432: Target STM USBHOST support https://github.com/ARMmbed/mbed-os/pull/3432
3181: NUCLEO_F207ZG extending PeripheralPins.c: all available alternate functions can be used now https://github.com/ARMmbed/mbed-os/pull/3181
3626: NUCLEO_F412ZG : Add USB Device +Host https://github.com/ARMmbed/mbed-os/pull/3626
3628: Fix warnings https://github.com/ARMmbed/mbed-os/pull/3628
3629: STM32: L0 LL layer https://github.com/ARMmbed/mbed-os/pull/3629
3632: IDE Export support for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3632
3642: Missing IRQ pin fix for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3642
3664: Fix ncs36510 sleep definitions https://github.com/ARMmbed/mbed-os/pull/3664
3655: [STM32F4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3655
3657: [STM32L4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3657
3658: [STM32F3] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3658
3685: STM32: I2C: reset state machine https://github.com/ARMmbed/mbed-os/pull/3685
3692: uVisor: Standardize available legacy heap and stack https://github.com/ARMmbed/mbed-os/pull/3692
3621: Fix for #2884, LPC824: export to LPCXpresso, target running with wron https://github.com/ARMmbed/mbed-os/pull/3621
3649: [STM32F7] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3649
3695: Enforce device_name is valid in targets.json https://github.com/ARMmbed/mbed-os/pull/3695
3723: NCS36510: spi_format function bug fix https://github.com/ARMmbed/mbed-os/pull/3723
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 98:8ab26030e058 | 1 | /***************************************************************************//** |
Kojto | 98:8ab26030e058 | 2 | * @file em_idac.h |
Kojto | 98:8ab26030e058 | 3 | * @brief Current Digital to Analog Converter (IDAC) peripheral API |
<> | 128:9bcdf88f62b0 | 4 | * @version 5.0.0 |
Kojto | 98:8ab26030e058 | 5 | ******************************************************************************* |
Kojto | 98:8ab26030e058 | 6 | * @section License |
<> | 128:9bcdf88f62b0 | 7 | * <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b> |
Kojto | 98:8ab26030e058 | 8 | ******************************************************************************* |
Kojto | 98:8ab26030e058 | 9 | * |
Kojto | 98:8ab26030e058 | 10 | * Permission is granted to anyone to use this software for any purpose, |
Kojto | 98:8ab26030e058 | 11 | * including commercial applications, and to alter it and redistribute it |
Kojto | 98:8ab26030e058 | 12 | * freely, subject to the following restrictions: |
Kojto | 98:8ab26030e058 | 13 | * |
Kojto | 98:8ab26030e058 | 14 | * 1. The origin of this software must not be misrepresented; you must not |
Kojto | 98:8ab26030e058 | 15 | * claim that you wrote the original software. |
Kojto | 98:8ab26030e058 | 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
Kojto | 98:8ab26030e058 | 17 | * misrepresented as being the original software. |
Kojto | 98:8ab26030e058 | 18 | * 3. This notice may not be removed or altered from any source distribution. |
Kojto | 98:8ab26030e058 | 19 | * |
Kojto | 98:8ab26030e058 | 20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
Kojto | 98:8ab26030e058 | 21 | * obligation to support this Software. Silicon Labs is providing the |
Kojto | 98:8ab26030e058 | 22 | * Software "AS IS", with no express or implied warranties of any kind, |
Kojto | 98:8ab26030e058 | 23 | * including, but not limited to, any implied warranties of merchantability |
Kojto | 98:8ab26030e058 | 24 | * or fitness for any particular purpose or warranties against infringement |
Kojto | 98:8ab26030e058 | 25 | * of any proprietary rights of a third party. |
Kojto | 98:8ab26030e058 | 26 | * |
Kojto | 98:8ab26030e058 | 27 | * Silicon Labs will not be liable for any consequential, incidental, or |
Kojto | 98:8ab26030e058 | 28 | * special damages, or any other relief, or for any claim by any third party, |
Kojto | 98:8ab26030e058 | 29 | * arising from your use of this Software. |
Kojto | 98:8ab26030e058 | 30 | * |
Kojto | 98:8ab26030e058 | 31 | ******************************************************************************/ |
Kojto | 98:8ab26030e058 | 32 | |
<> | 128:9bcdf88f62b0 | 33 | #ifndef EM_IDAC_H |
<> | 128:9bcdf88f62b0 | 34 | #define EM_IDAC_H |
Kojto | 98:8ab26030e058 | 35 | |
Kojto | 98:8ab26030e058 | 36 | #include "em_device.h" |
Kojto | 98:8ab26030e058 | 37 | |
Kojto | 98:8ab26030e058 | 38 | #if defined(IDAC_COUNT) && (IDAC_COUNT > 0) |
Kojto | 98:8ab26030e058 | 39 | #include <stdbool.h> |
Kojto | 98:8ab26030e058 | 40 | |
Kojto | 98:8ab26030e058 | 41 | #ifdef __cplusplus |
Kojto | 98:8ab26030e058 | 42 | extern "C" { |
Kojto | 98:8ab26030e058 | 43 | #endif |
Kojto | 98:8ab26030e058 | 44 | |
Kojto | 98:8ab26030e058 | 45 | /***************************************************************************//** |
<> | 128:9bcdf88f62b0 | 46 | * @addtogroup emlib |
Kojto | 98:8ab26030e058 | 47 | * @{ |
Kojto | 98:8ab26030e058 | 48 | ******************************************************************************/ |
Kojto | 98:8ab26030e058 | 49 | |
Kojto | 98:8ab26030e058 | 50 | /***************************************************************************//** |
Kojto | 98:8ab26030e058 | 51 | * @addtogroup IDAC |
<> | 128:9bcdf88f62b0 | 52 | * @brief |
<> | 128:9bcdf88f62b0 | 53 | * Current Digital-to-Analog Converter (IDAC) Peripheral API |
<> | 128:9bcdf88f62b0 | 54 | * |
<> | 128:9bcdf88f62b0 | 55 | * @details |
<> | 128:9bcdf88f62b0 | 56 | * The current digital-to-analog converter (IDAC) can source or sink a configurable |
<> | 128:9bcdf88f62b0 | 57 | * constant current, which can be output on, or sinked from pin or ADC. The current |
<> | 128:9bcdf88f62b0 | 58 | * is configurable with several ranges of various step sizes. The IDAC can be used |
<> | 128:9bcdf88f62b0 | 59 | * with PRS and it can operate down to EM3. |
<> | 128:9bcdf88f62b0 | 60 | * |
<> | 128:9bcdf88f62b0 | 61 | * The following steps are necessary for basic operation: |
<> | 128:9bcdf88f62b0 | 62 | * |
<> | 128:9bcdf88f62b0 | 63 | * Clock enable: |
<> | 128:9bcdf88f62b0 | 64 | * @include em_idac_clock_enable.c |
<> | 128:9bcdf88f62b0 | 65 | * |
<> | 128:9bcdf88f62b0 | 66 | * Initialize the peripheral with default settings and modify selected fields such as |
<> | 128:9bcdf88f62b0 | 67 | * output select: |
<> | 128:9bcdf88f62b0 | 68 | * @if DOXYDOC_P1_DEVICE |
<> | 128:9bcdf88f62b0 | 69 | * @include em_idac_init_adc.c |
<> | 128:9bcdf88f62b0 | 70 | * @endif |
<> | 128:9bcdf88f62b0 | 71 | * @if DOXYDOC_P2_DEVICE |
<> | 128:9bcdf88f62b0 | 72 | * @include em_idac_init_aport.c |
<> | 128:9bcdf88f62b0 | 73 | * @endif |
<> | 128:9bcdf88f62b0 | 74 | * |
<> | 128:9bcdf88f62b0 | 75 | * Set output: |
<> | 128:9bcdf88f62b0 | 76 | * @include em_idac_basic_usage.c |
<> | 128:9bcdf88f62b0 | 77 | * |
Kojto | 98:8ab26030e058 | 78 | * @{ |
Kojto | 98:8ab26030e058 | 79 | ******************************************************************************/ |
Kojto | 98:8ab26030e058 | 80 | |
Kojto | 98:8ab26030e058 | 81 | /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */ |
Kojto | 98:8ab26030e058 | 82 | |
Kojto | 98:8ab26030e058 | 83 | /** Validation of IDAC register block pointer reference for assert statements. */ |
Kojto | 98:8ab26030e058 | 84 | #define IDAC_REF_VALID(ref) ((ref) == IDAC0) |
Kojto | 98:8ab26030e058 | 85 | |
Kojto | 98:8ab26030e058 | 86 | /** @endcond */ |
Kojto | 98:8ab26030e058 | 87 | |
Kojto | 98:8ab26030e058 | 88 | /******************************************************************************* |
Kojto | 98:8ab26030e058 | 89 | ******************************** ENUMS ************************************ |
Kojto | 98:8ab26030e058 | 90 | ******************************************************************************/ |
Kojto | 98:8ab26030e058 | 91 | |
Kojto | 98:8ab26030e058 | 92 | /** Output mode. */ |
Kojto | 98:8ab26030e058 | 93 | typedef enum |
Kojto | 98:8ab26030e058 | 94 | { |
Kojto | 113:f141b2784e32 | 95 | #if defined( _IDAC_CTRL_OUTMODE_MASK ) |
Kojto | 98:8ab26030e058 | 96 | idacOutputPin = IDAC_CTRL_OUTMODE_PIN, /**< Output to IDAC OUT pin */ |
Kojto | 98:8ab26030e058 | 97 | idacOutputADC = IDAC_CTRL_OUTMODE_ADC /**< Output to ADC */ |
Kojto | 113:f141b2784e32 | 98 | #elif ( _IDAC_CTRL_APORTOUTSEL_MASK ) |
Kojto | 113:f141b2784e32 | 99 | idacOutputAPORT1XCH0 = IDAC_CTRL_APORTOUTSEL_APORT1XCH0, /**< Output to APORT 1X CH0 */ |
Kojto | 113:f141b2784e32 | 100 | idacOutputAPORT1YCH1 = IDAC_CTRL_APORTOUTSEL_APORT1YCH1, /**< Output to APORT 1Y CH1 */ |
Kojto | 113:f141b2784e32 | 101 | idacOutputAPORT1XCH2 = IDAC_CTRL_APORTOUTSEL_APORT1XCH2, /**< Output to APORT 1X CH2 */ |
Kojto | 113:f141b2784e32 | 102 | idacOutputAPORT1YCH3 = IDAC_CTRL_APORTOUTSEL_APORT1YCH3, /**< Output to APORT 1Y CH3 */ |
Kojto | 113:f141b2784e32 | 103 | idacOutputAPORT1XCH4 = IDAC_CTRL_APORTOUTSEL_APORT1XCH4, /**< Output to APORT 1X CH4 */ |
Kojto | 113:f141b2784e32 | 104 | idacOutputAPORT1YCH5 = IDAC_CTRL_APORTOUTSEL_APORT1YCH5, /**< Output to APORT 1Y CH5 */ |
Kojto | 113:f141b2784e32 | 105 | idacOutputAPORT1XCH6 = IDAC_CTRL_APORTOUTSEL_APORT1XCH6, /**< Output to APORT 1X CH6 */ |
Kojto | 113:f141b2784e32 | 106 | idacOutputAPORT1YCH7 = IDAC_CTRL_APORTOUTSEL_APORT1YCH7, /**< Output to APORT 1Y CH7 */ |
Kojto | 113:f141b2784e32 | 107 | idacOutputAPORT1XCH8 = IDAC_CTRL_APORTOUTSEL_APORT1XCH8, /**< Output to APORT 1X CH8 */ |
Kojto | 113:f141b2784e32 | 108 | idacOutputAPORT1YCH9 = IDAC_CTRL_APORTOUTSEL_APORT1YCH9, /**< Output to APORT 1Y CH9 */ |
Kojto | 113:f141b2784e32 | 109 | idacOutputAPORT1XCH10 = IDAC_CTRL_APORTOUTSEL_APORT1XCH10, /**< Output to APORT 1X CH10 */ |
Kojto | 113:f141b2784e32 | 110 | idacOutputAPORT1YCH11 = IDAC_CTRL_APORTOUTSEL_APORT1YCH11, /**< Output to APORT 1Y CH11 */ |
Kojto | 113:f141b2784e32 | 111 | idacOutputAPORT1XCH12 = IDAC_CTRL_APORTOUTSEL_APORT1XCH12, /**< Output to APORT 1X CH12 */ |
Kojto | 113:f141b2784e32 | 112 | idacOutputAPORT1YCH13 = IDAC_CTRL_APORTOUTSEL_APORT1YCH13, /**< Output to APORT 1Y CH13 */ |
Kojto | 113:f141b2784e32 | 113 | idacOutputAPORT1XCH14 = IDAC_CTRL_APORTOUTSEL_APORT1XCH14, /**< Output to APORT 1X CH14 */ |
Kojto | 113:f141b2784e32 | 114 | idacOutputAPORT1YCH15 = IDAC_CTRL_APORTOUTSEL_APORT1YCH15, /**< Output to APORT 1Y CH15 */ |
Kojto | 113:f141b2784e32 | 115 | idacOutputAPORT1XCH16 = IDAC_CTRL_APORTOUTSEL_APORT1XCH16, /**< Output to APORT 1X CH16 */ |
Kojto | 113:f141b2784e32 | 116 | idacOutputAPORT1YCH17 = IDAC_CTRL_APORTOUTSEL_APORT1YCH17, /**< Output to APORT 1Y CH17 */ |
Kojto | 113:f141b2784e32 | 117 | idacOutputAPORT1XCH18 = IDAC_CTRL_APORTOUTSEL_APORT1XCH18, /**< Output to APORT 1X CH18 */ |
Kojto | 113:f141b2784e32 | 118 | idacOutputAPORT1YCH19 = IDAC_CTRL_APORTOUTSEL_APORT1YCH19, /**< Output to APORT 1Y CH19 */ |
Kojto | 113:f141b2784e32 | 119 | idacOutputAPORT1XCH20 = IDAC_CTRL_APORTOUTSEL_APORT1XCH20, /**< Output to APORT 1X CH20 */ |
Kojto | 113:f141b2784e32 | 120 | idacOutputAPORT1YCH21 = IDAC_CTRL_APORTOUTSEL_APORT1YCH21, /**< Output to APORT 1Y CH21 */ |
Kojto | 113:f141b2784e32 | 121 | idacOutputAPORT1XCH22 = IDAC_CTRL_APORTOUTSEL_APORT1XCH22, /**< Output to APORT 1X CH22 */ |
Kojto | 113:f141b2784e32 | 122 | idacOutputAPORT1YCH23 = IDAC_CTRL_APORTOUTSEL_APORT1YCH23, /**< Output to APORT 1Y CH23 */ |
Kojto | 113:f141b2784e32 | 123 | idacOutputAPORT1XCH24 = IDAC_CTRL_APORTOUTSEL_APORT1XCH24, /**< Output to APORT 1X CH24 */ |
Kojto | 113:f141b2784e32 | 124 | idacOutputAPORT1YCH25 = IDAC_CTRL_APORTOUTSEL_APORT1YCH25, /**< Output to APORT 1Y CH25 */ |
Kojto | 113:f141b2784e32 | 125 | idacOutputAPORT1XCH26 = IDAC_CTRL_APORTOUTSEL_APORT1XCH26, /**< Output to APORT 1X CH26 */ |
Kojto | 113:f141b2784e32 | 126 | idacOutputAPORT1YCH27 = IDAC_CTRL_APORTOUTSEL_APORT1YCH27, /**< Output to APORT 1Y CH27 */ |
Kojto | 113:f141b2784e32 | 127 | idacOutputAPORT1XCH28 = IDAC_CTRL_APORTOUTSEL_APORT1XCH28, /**< Output to APORT 1X CH28 */ |
Kojto | 113:f141b2784e32 | 128 | idacOutputAPORT1YCH29 = IDAC_CTRL_APORTOUTSEL_APORT1YCH29, /**< Output to APORT 1Y CH29 */ |
Kojto | 113:f141b2784e32 | 129 | idacOutputAPORT1XCH30 = IDAC_CTRL_APORTOUTSEL_APORT1XCH30, /**< Output to APORT 1X CH30 */ |
Kojto | 113:f141b2784e32 | 130 | idacOutputAPORT1YCH31 = IDAC_CTRL_APORTOUTSEL_APORT1YCH31, /**< Output to APORT 1Y CH31 */ |
Kojto | 113:f141b2784e32 | 131 | #endif |
Kojto | 98:8ab26030e058 | 132 | } IDAC_OutMode_TypeDef; |
Kojto | 98:8ab26030e058 | 133 | |
Kojto | 98:8ab26030e058 | 134 | |
Kojto | 98:8ab26030e058 | 135 | /** Selects which Peripheral Reflex System (PRS) signal to use when |
Kojto | 98:8ab26030e058 | 136 | PRS is set to control the IDAC output. */ |
Kojto | 98:8ab26030e058 | 137 | typedef enum |
Kojto | 98:8ab26030e058 | 138 | { |
Kojto | 98:8ab26030e058 | 139 | idacPRSSELCh0 = IDAC_CTRL_PRSSEL_PRSCH0, /**< PRS channel 0. */ |
Kojto | 98:8ab26030e058 | 140 | idacPRSSELCh1 = IDAC_CTRL_PRSSEL_PRSCH1, /**< PRS channel 1. */ |
Kojto | 98:8ab26030e058 | 141 | idacPRSSELCh2 = IDAC_CTRL_PRSSEL_PRSCH2, /**< PRS channel 2. */ |
Kojto | 98:8ab26030e058 | 142 | idacPRSSELCh3 = IDAC_CTRL_PRSSEL_PRSCH3, /**< PRS channel 3. */ |
Kojto | 113:f141b2784e32 | 143 | #if defined( IDAC_CTRL_PRSSEL_PRSCH4 ) |
Kojto | 98:8ab26030e058 | 144 | idacPRSSELCh4 = IDAC_CTRL_PRSSEL_PRSCH4, /**< PRS channel 4. */ |
Kojto | 98:8ab26030e058 | 145 | idacPRSSELCh5 = IDAC_CTRL_PRSSEL_PRSCH5, /**< PRS channel 5. */ |
Kojto | 98:8ab26030e058 | 146 | #endif |
Kojto | 113:f141b2784e32 | 147 | #if defined( IDAC_CTRL_PRSSEL_PRSCH6 ) |
Kojto | 98:8ab26030e058 | 148 | idacPRSSELCh6 = IDAC_CTRL_PRSSEL_PRSCH6, /**< PRS channel 6. */ |
Kojto | 98:8ab26030e058 | 149 | idacPRSSELCh7 = IDAC_CTRL_PRSSEL_PRSCH7, /**< PRS channel 7. */ |
Kojto | 98:8ab26030e058 | 150 | idacPRSSELCh8 = IDAC_CTRL_PRSSEL_PRSCH8, /**< PRS channel 8. */ |
Kojto | 98:8ab26030e058 | 151 | idacPRSSELCh9 = IDAC_CTRL_PRSSEL_PRSCH9, /**< PRS channel 9. */ |
Kojto | 98:8ab26030e058 | 152 | idacPRSSELCh10 = IDAC_CTRL_PRSSEL_PRSCH10, /**< PRS channel 10 */ |
Kojto | 98:8ab26030e058 | 153 | idacPRSSELCh11 = IDAC_CTRL_PRSSEL_PRSCH11, /**< PRS channel 11 */ |
Kojto | 98:8ab26030e058 | 154 | #endif |
Kojto | 98:8ab26030e058 | 155 | } IDAC_PRSSEL_TypeDef; |
Kojto | 98:8ab26030e058 | 156 | |
Kojto | 98:8ab26030e058 | 157 | |
Kojto | 98:8ab26030e058 | 158 | /** Selects which current range to use. */ |
Kojto | 98:8ab26030e058 | 159 | typedef enum |
Kojto | 98:8ab26030e058 | 160 | { |
Kojto | 98:8ab26030e058 | 161 | idacCurrentRange0 = IDAC_CURPROG_RANGESEL_RANGE0, /**< current range 0. */ |
Kojto | 98:8ab26030e058 | 162 | idacCurrentRange1 = IDAC_CURPROG_RANGESEL_RANGE1, /**< current range 1. */ |
Kojto | 98:8ab26030e058 | 163 | idacCurrentRange2 = IDAC_CURPROG_RANGESEL_RANGE2, /**< current range 2. */ |
Kojto | 98:8ab26030e058 | 164 | idacCurrentRange3 = IDAC_CURPROG_RANGESEL_RANGE3, /**< current range 3. */ |
Kojto | 98:8ab26030e058 | 165 | } IDAC_Range_TypeDef; |
Kojto | 98:8ab26030e058 | 166 | |
Kojto | 98:8ab26030e058 | 167 | /******************************************************************************* |
Kojto | 98:8ab26030e058 | 168 | ******************************* STRUCTS *********************************** |
Kojto | 98:8ab26030e058 | 169 | ******************************************************************************/ |
Kojto | 98:8ab26030e058 | 170 | |
Kojto | 98:8ab26030e058 | 171 | /** IDAC init structure, common for both channels. */ |
Kojto | 98:8ab26030e058 | 172 | typedef struct |
Kojto | 98:8ab26030e058 | 173 | { |
Kojto | 98:8ab26030e058 | 174 | /** Enable IDAC. */ |
Kojto | 98:8ab26030e058 | 175 | bool enable; |
Kojto | 98:8ab26030e058 | 176 | |
Kojto | 98:8ab26030e058 | 177 | /** Output mode */ |
Kojto | 98:8ab26030e058 | 178 | IDAC_OutMode_TypeDef outMode; |
Kojto | 98:8ab26030e058 | 179 | |
Kojto | 98:8ab26030e058 | 180 | /** |
Kojto | 98:8ab26030e058 | 181 | * Enable Peripheral reflex system (PRS) to control IDAC output. If false, |
Kojto | 98:8ab26030e058 | 182 | * the IDAC output is controlled by writing to IDAC_OUTEN in IDAC_CTRL or |
Kojto | 98:8ab26030e058 | 183 | * by calling IDAC_OutEnable(). |
Kojto | 98:8ab26030e058 | 184 | */ |
Kojto | 98:8ab26030e058 | 185 | bool prsEnable; |
Kojto | 98:8ab26030e058 | 186 | |
Kojto | 98:8ab26030e058 | 187 | /** |
Kojto | 98:8ab26030e058 | 188 | * Peripheral reflex system channel selection. Only applicable if @p prsEnable |
Kojto | 98:8ab26030e058 | 189 | * is enabled. |
Kojto | 98:8ab26030e058 | 190 | */ |
Kojto | 98:8ab26030e058 | 191 | IDAC_PRSSEL_TypeDef prsSel; |
Kojto | 98:8ab26030e058 | 192 | |
Kojto | 98:8ab26030e058 | 193 | /** Enable/disable current sink mode. */ |
Kojto | 98:8ab26030e058 | 194 | bool sinkEnable; |
Kojto | 98:8ab26030e058 | 195 | |
Kojto | 98:8ab26030e058 | 196 | } IDAC_Init_TypeDef; |
Kojto | 98:8ab26030e058 | 197 | |
Kojto | 98:8ab26030e058 | 198 | /** Default config for IDAC init structure. */ |
Kojto | 113:f141b2784e32 | 199 | #if defined( _IDAC_CTRL_OUTMODE_MASK ) |
Kojto | 113:f141b2784e32 | 200 | #define IDAC_INIT_DEFAULT \ |
Kojto | 113:f141b2784e32 | 201 | { \ |
Kojto | 113:f141b2784e32 | 202 | false, /**< Leave IDAC disabled when init done. */ \ |
Kojto | 113:f141b2784e32 | 203 | idacOutputPin, /**< Output to IDAC output pin. */ \ |
Kojto | 113:f141b2784e32 | 204 | false, /**< Disable PRS triggering. */ \ |
Kojto | 113:f141b2784e32 | 205 | idacPRSSELCh0, /**< Select PRS ch0 (if PRS triggering enabled). */ \ |
Kojto | 113:f141b2784e32 | 206 | false /**< Disable current sink mode. */ \ |
Kojto | 113:f141b2784e32 | 207 | } |
Kojto | 113:f141b2784e32 | 208 | #elif ( _IDAC_CTRL_APORTOUTSEL_MASK ) |
Kojto | 113:f141b2784e32 | 209 | #define IDAC_INIT_DEFAULT \ |
Kojto | 113:f141b2784e32 | 210 | { \ |
Kojto | 113:f141b2784e32 | 211 | false, /**< Leave IDAC disabled when init done. */ \ |
Kojto | 113:f141b2784e32 | 212 | idacOutputAPORT1XCH0, /**< Output to APORT. */ \ |
Kojto | 113:f141b2784e32 | 213 | false, /**< Disable PRS triggering. */ \ |
Kojto | 113:f141b2784e32 | 214 | idacPRSSELCh0, /**< Select PRS ch0 (if PRS triggering enabled). */ \ |
Kojto | 113:f141b2784e32 | 215 | false /**< Disable current sink mode. */ \ |
Kojto | 113:f141b2784e32 | 216 | } |
Kojto | 113:f141b2784e32 | 217 | #endif |
Kojto | 98:8ab26030e058 | 218 | |
Kojto | 98:8ab26030e058 | 219 | |
Kojto | 98:8ab26030e058 | 220 | /******************************************************************************* |
Kojto | 98:8ab26030e058 | 221 | ***************************** PROTOTYPES ********************************** |
Kojto | 98:8ab26030e058 | 222 | ******************************************************************************/ |
Kojto | 98:8ab26030e058 | 223 | |
<> | 128:9bcdf88f62b0 | 224 | |
Kojto | 98:8ab26030e058 | 225 | void IDAC_Init(IDAC_TypeDef *idac, const IDAC_Init_TypeDef *init); |
Kojto | 98:8ab26030e058 | 226 | void IDAC_Enable(IDAC_TypeDef *idac, bool enable); |
Kojto | 98:8ab26030e058 | 227 | void IDAC_Reset(IDAC_TypeDef *idac); |
Kojto | 98:8ab26030e058 | 228 | void IDAC_MinimalOutputTransitionMode(IDAC_TypeDef *idac, bool enable); |
Kojto | 98:8ab26030e058 | 229 | void IDAC_RangeSet(IDAC_TypeDef *idac, const IDAC_Range_TypeDef range); |
Kojto | 98:8ab26030e058 | 230 | void IDAC_StepSet(IDAC_TypeDef *idac, const uint32_t step); |
Kojto | 98:8ab26030e058 | 231 | void IDAC_OutEnable(IDAC_TypeDef *idac, bool enable); |
Kojto | 98:8ab26030e058 | 232 | |
Kojto | 98:8ab26030e058 | 233 | |
Kojto | 113:f141b2784e32 | 234 | #if defined( _IDAC_IEN_MASK ) |
Kojto | 113:f141b2784e32 | 235 | /***************************************************************************//** |
Kojto | 113:f141b2784e32 | 236 | * @brief |
Kojto | 113:f141b2784e32 | 237 | * Clear one or more pending IDAC interrupts. |
Kojto | 113:f141b2784e32 | 238 | * |
<> | 128:9bcdf88f62b0 | 239 | * @param[in] idac |
Kojto | 113:f141b2784e32 | 240 | * Pointer to IDAC peripheral register block. |
Kojto | 113:f141b2784e32 | 241 | * |
Kojto | 113:f141b2784e32 | 242 | * @param[in] flags |
Kojto | 113:f141b2784e32 | 243 | * Pending IDAC interrupt source(s) to clear. Use one or more valid |
Kojto | 113:f141b2784e32 | 244 | * interrupt flags for the IDAC module (IDAC_IF_nnn) OR'ed together. |
Kojto | 113:f141b2784e32 | 245 | ******************************************************************************/ |
Kojto | 113:f141b2784e32 | 246 | __STATIC_INLINE void IDAC_IntClear(IDAC_TypeDef *idac, uint32_t flags) |
Kojto | 113:f141b2784e32 | 247 | { |
Kojto | 113:f141b2784e32 | 248 | idac->IFC = flags; |
Kojto | 113:f141b2784e32 | 249 | } |
Kojto | 113:f141b2784e32 | 250 | |
Kojto | 113:f141b2784e32 | 251 | |
Kojto | 113:f141b2784e32 | 252 | /***************************************************************************//** |
Kojto | 113:f141b2784e32 | 253 | * @brief |
Kojto | 113:f141b2784e32 | 254 | * Disable one or more IDAC interrupts. |
Kojto | 113:f141b2784e32 | 255 | * |
<> | 128:9bcdf88f62b0 | 256 | * @param[in] idac |
Kojto | 113:f141b2784e32 | 257 | * Pointer to IDAC peripheral register block. |
Kojto | 113:f141b2784e32 | 258 | * |
Kojto | 113:f141b2784e32 | 259 | * @param[in] flags |
Kojto | 113:f141b2784e32 | 260 | * IDAC interrupt source(s) to disable. Use one or more valid |
Kojto | 113:f141b2784e32 | 261 | * interrupt flags for the IDAC module (IDAC_IF_nnn) OR'ed together. |
Kojto | 113:f141b2784e32 | 262 | ******************************************************************************/ |
Kojto | 113:f141b2784e32 | 263 | __STATIC_INLINE void IDAC_IntDisable(IDAC_TypeDef *idac, uint32_t flags) |
Kojto | 113:f141b2784e32 | 264 | { |
Kojto | 113:f141b2784e32 | 265 | idac->IEN &= ~flags; |
Kojto | 113:f141b2784e32 | 266 | } |
Kojto | 113:f141b2784e32 | 267 | |
Kojto | 113:f141b2784e32 | 268 | |
Kojto | 113:f141b2784e32 | 269 | /***************************************************************************//** |
Kojto | 113:f141b2784e32 | 270 | * @brief |
Kojto | 113:f141b2784e32 | 271 | * Enable one or more IDAC interrupts. |
Kojto | 113:f141b2784e32 | 272 | * |
Kojto | 113:f141b2784e32 | 273 | * @note |
Kojto | 113:f141b2784e32 | 274 | * Depending on the use, a pending interrupt may already be set prior to |
Kojto | 113:f141b2784e32 | 275 | * enabling the interrupt. Consider using IDAC_IntClear() prior to enabling |
Kojto | 113:f141b2784e32 | 276 | * if such a pending interrupt should be ignored. |
Kojto | 113:f141b2784e32 | 277 | * |
<> | 128:9bcdf88f62b0 | 278 | * @param[in] idac |
Kojto | 113:f141b2784e32 | 279 | * Pointer to IDAC peripheral register block. |
Kojto | 113:f141b2784e32 | 280 | * |
Kojto | 113:f141b2784e32 | 281 | * @param[in] flags |
Kojto | 113:f141b2784e32 | 282 | * IDAC interrupt source(s) to enable. Use one or more valid |
Kojto | 113:f141b2784e32 | 283 | * interrupt flags for the IDAC module (IDAC_IF_nnn) OR'ed together. |
Kojto | 113:f141b2784e32 | 284 | ******************************************************************************/ |
Kojto | 113:f141b2784e32 | 285 | __STATIC_INLINE void IDAC_IntEnable(IDAC_TypeDef *idac, uint32_t flags) |
Kojto | 113:f141b2784e32 | 286 | { |
Kojto | 113:f141b2784e32 | 287 | idac->IEN |= flags; |
Kojto | 113:f141b2784e32 | 288 | } |
Kojto | 113:f141b2784e32 | 289 | |
Kojto | 113:f141b2784e32 | 290 | |
Kojto | 113:f141b2784e32 | 291 | /***************************************************************************//** |
Kojto | 113:f141b2784e32 | 292 | * @brief |
Kojto | 113:f141b2784e32 | 293 | * Get pending IDAC interrupt flags. |
Kojto | 113:f141b2784e32 | 294 | * |
Kojto | 113:f141b2784e32 | 295 | * @note |
Kojto | 113:f141b2784e32 | 296 | * The event bits are not cleared by the use of this function. |
Kojto | 113:f141b2784e32 | 297 | * |
<> | 128:9bcdf88f62b0 | 298 | * @param[in] idac |
Kojto | 113:f141b2784e32 | 299 | * Pointer to IDAC peripheral register block. |
Kojto | 113:f141b2784e32 | 300 | * |
Kojto | 113:f141b2784e32 | 301 | * @return |
Kojto | 113:f141b2784e32 | 302 | * IDAC interrupt source(s) pending. Returns one or more valid |
Kojto | 113:f141b2784e32 | 303 | * interrupt flags for the IDAC module (IDAC_IF_nnn) OR'ed together. |
Kojto | 113:f141b2784e32 | 304 | ******************************************************************************/ |
Kojto | 113:f141b2784e32 | 305 | __STATIC_INLINE uint32_t IDAC_IntGet(IDAC_TypeDef *idac) |
Kojto | 113:f141b2784e32 | 306 | { |
Kojto | 113:f141b2784e32 | 307 | return idac->IF; |
Kojto | 113:f141b2784e32 | 308 | } |
Kojto | 113:f141b2784e32 | 309 | |
Kojto | 113:f141b2784e32 | 310 | |
Kojto | 113:f141b2784e32 | 311 | /***************************************************************************//** |
Kojto | 113:f141b2784e32 | 312 | * @brief |
Kojto | 113:f141b2784e32 | 313 | * Get enabled and pending IDAC interrupt flags. |
Kojto | 113:f141b2784e32 | 314 | * Useful for handling more interrupt sources in the same interrupt handler. |
Kojto | 113:f141b2784e32 | 315 | * |
<> | 128:9bcdf88f62b0 | 316 | * @param[in] idac |
Kojto | 113:f141b2784e32 | 317 | * Pointer to IDAC peripheral register block. |
Kojto | 113:f141b2784e32 | 318 | * |
Kojto | 113:f141b2784e32 | 319 | * @note |
Kojto | 113:f141b2784e32 | 320 | * Interrupt flags are not cleared by the use of this function. |
Kojto | 113:f141b2784e32 | 321 | * |
Kojto | 113:f141b2784e32 | 322 | * @return |
Kojto | 113:f141b2784e32 | 323 | * Pending and enabled IDAC interrupt sources. |
Kojto | 113:f141b2784e32 | 324 | * The return value is the bitwise AND combination of |
Kojto | 113:f141b2784e32 | 325 | * - the OR combination of enabled interrupt sources in IDACx_IEN_nnn |
Kojto | 113:f141b2784e32 | 326 | * register (IDACx_IEN_nnn) and |
Kojto | 113:f141b2784e32 | 327 | * - the OR combination of valid interrupt flags of the IDAC module |
Kojto | 113:f141b2784e32 | 328 | * (IDACx_IF_nnn). |
Kojto | 113:f141b2784e32 | 329 | ******************************************************************************/ |
Kojto | 113:f141b2784e32 | 330 | __STATIC_INLINE uint32_t IDAC_IntGetEnabled(IDAC_TypeDef *idac) |
Kojto | 113:f141b2784e32 | 331 | { |
Kojto | 113:f141b2784e32 | 332 | uint32_t ien; |
Kojto | 113:f141b2784e32 | 333 | |
Kojto | 113:f141b2784e32 | 334 | /* Store flags in temporary variable in order to define explicit order |
Kojto | 113:f141b2784e32 | 335 | * of volatile accesses. */ |
Kojto | 113:f141b2784e32 | 336 | ien = idac->IEN; |
Kojto | 113:f141b2784e32 | 337 | |
Kojto | 113:f141b2784e32 | 338 | /* Bitwise AND of pending and enabled interrupts */ |
Kojto | 113:f141b2784e32 | 339 | return idac->IF & ien; |
Kojto | 113:f141b2784e32 | 340 | } |
Kojto | 113:f141b2784e32 | 341 | |
Kojto | 113:f141b2784e32 | 342 | |
Kojto | 113:f141b2784e32 | 343 | /***************************************************************************//** |
Kojto | 113:f141b2784e32 | 344 | * @brief |
Kojto | 113:f141b2784e32 | 345 | * Set one or more pending IDAC interrupts from SW. |
Kojto | 113:f141b2784e32 | 346 | * |
<> | 128:9bcdf88f62b0 | 347 | * @param[in] idac |
Kojto | 113:f141b2784e32 | 348 | * Pointer to IDAC peripheral register block. |
Kojto | 113:f141b2784e32 | 349 | * |
Kojto | 113:f141b2784e32 | 350 | * @param[in] flags |
Kojto | 113:f141b2784e32 | 351 | * IDAC interrupt source(s) to set to pending. Use one or more valid |
Kojto | 113:f141b2784e32 | 352 | * interrupt flags for the IDAC module (IDAC_IF_nnn) OR'ed together. |
Kojto | 113:f141b2784e32 | 353 | ******************************************************************************/ |
Kojto | 113:f141b2784e32 | 354 | __STATIC_INLINE void IDAC_IntSet(IDAC_TypeDef *idac, uint32_t flags) |
Kojto | 113:f141b2784e32 | 355 | { |
Kojto | 113:f141b2784e32 | 356 | idac->IFS = flags; |
Kojto | 113:f141b2784e32 | 357 | } |
Kojto | 113:f141b2784e32 | 358 | #endif |
Kojto | 113:f141b2784e32 | 359 | |
Kojto | 113:f141b2784e32 | 360 | |
Kojto | 98:8ab26030e058 | 361 | /** @} (end addtogroup IDAC) */ |
<> | 128:9bcdf88f62b0 | 362 | /** @} (end addtogroup emlib) */ |
Kojto | 98:8ab26030e058 | 363 | |
Kojto | 98:8ab26030e058 | 364 | #ifdef __cplusplus |
Kojto | 98:8ab26030e058 | 365 | } |
Kojto | 98:8ab26030e058 | 366 | #endif |
Kojto | 98:8ab26030e058 | 367 | |
Kojto | 98:8ab26030e058 | 368 | #endif /* defined(IDAC_COUNT) && (IDAC_COUNT > 0) */ |
Kojto | 98:8ab26030e058 | 369 | |
<> | 128:9bcdf88f62b0 | 370 | #endif /* EM_IDAC_H */ |