The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Kojto
Date:
Wed Apr 29 10:16:23 2015 +0100
Revision:
98:8ab26030e058
Child:
113:f141b2784e32
Release 98 of the mbed library

Changes:
- Silabs new targets (Giant, Zero, Happy, Leopard, Wonder Geckos)
- Asynchronous SPI, I2C, Serial
- LowPower classes
- Nordic - nordic SDK v8.0 update
- Teensy - gcc arm fix for startup
- Nucleo F411 - usb freq fix

Who changed what in which revision?

UserRevisionLine numberNew 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
Kojto 98:8ab26030e058 4 * @version 3.20.12
Kojto 98:8ab26030e058 5 *******************************************************************************
Kojto 98:8ab26030e058 6 * @section License
Kojto 98:8ab26030e058 7 * <b>(C) Copyright 2014 Silicon Labs, 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
Kojto 98:8ab26030e058 33
Kojto 98:8ab26030e058 34 #ifndef __SILICON_LABS_EM_IDAC_H_
Kojto 98:8ab26030e058 35 #define __SILICON_LABS_EM_IDAC_H_
Kojto 98:8ab26030e058 36
Kojto 98:8ab26030e058 37 #include "em_device.h"
Kojto 98:8ab26030e058 38
Kojto 98:8ab26030e058 39 #if defined(IDAC_COUNT) && (IDAC_COUNT > 0)
Kojto 98:8ab26030e058 40 #include <stdbool.h>
Kojto 98:8ab26030e058 41
Kojto 98:8ab26030e058 42 #ifdef __cplusplus
Kojto 98:8ab26030e058 43 extern "C" {
Kojto 98:8ab26030e058 44 #endif
Kojto 98:8ab26030e058 45
Kojto 98:8ab26030e058 46 /***************************************************************************//**
Kojto 98:8ab26030e058 47 * @addtogroup EM_Library
Kojto 98:8ab26030e058 48 * @{
Kojto 98:8ab26030e058 49 ******************************************************************************/
Kojto 98:8ab26030e058 50
Kojto 98:8ab26030e058 51 /***************************************************************************//**
Kojto 98:8ab26030e058 52 * @addtogroup IDAC
Kojto 98:8ab26030e058 53 * @{
Kojto 98:8ab26030e058 54 ******************************************************************************/
Kojto 98:8ab26030e058 55
Kojto 98:8ab26030e058 56 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
Kojto 98:8ab26030e058 57
Kojto 98:8ab26030e058 58 /** Validation of IDAC register block pointer reference for assert statements. */
Kojto 98:8ab26030e058 59 #define IDAC_REF_VALID(ref) ((ref) == IDAC0)
Kojto 98:8ab26030e058 60
Kojto 98:8ab26030e058 61 /** @endcond */
Kojto 98:8ab26030e058 62
Kojto 98:8ab26030e058 63 /*******************************************************************************
Kojto 98:8ab26030e058 64 ******************************** ENUMS ************************************
Kojto 98:8ab26030e058 65 ******************************************************************************/
Kojto 98:8ab26030e058 66
Kojto 98:8ab26030e058 67 /** Output mode. */
Kojto 98:8ab26030e058 68 typedef enum
Kojto 98:8ab26030e058 69 {
Kojto 98:8ab26030e058 70 idacOutputPin = IDAC_CTRL_OUTMODE_PIN, /**< Output to IDAC OUT pin */
Kojto 98:8ab26030e058 71 idacOutputADC = IDAC_CTRL_OUTMODE_ADC /**< Output to ADC */
Kojto 98:8ab26030e058 72 } IDAC_OutMode_TypeDef;
Kojto 98:8ab26030e058 73
Kojto 98:8ab26030e058 74
Kojto 98:8ab26030e058 75 /** Selects which Peripheral Reflex System (PRS) signal to use when
Kojto 98:8ab26030e058 76 PRS is set to control the IDAC output. */
Kojto 98:8ab26030e058 77 typedef enum
Kojto 98:8ab26030e058 78 {
Kojto 98:8ab26030e058 79 idacPRSSELCh0 = IDAC_CTRL_PRSSEL_PRSCH0, /**< PRS channel 0. */
Kojto 98:8ab26030e058 80 idacPRSSELCh1 = IDAC_CTRL_PRSSEL_PRSCH1, /**< PRS channel 1. */
Kojto 98:8ab26030e058 81 idacPRSSELCh2 = IDAC_CTRL_PRSSEL_PRSCH2, /**< PRS channel 2. */
Kojto 98:8ab26030e058 82 idacPRSSELCh3 = IDAC_CTRL_PRSSEL_PRSCH3, /**< PRS channel 3. */
Kojto 98:8ab26030e058 83 #if defined( IDAC_CTRL_PRSSEL_PRSCH4 )
Kojto 98:8ab26030e058 84 idacPRSSELCh4 = IDAC_CTRL_PRSSEL_PRSCH4, /**< PRS channel 4. */
Kojto 98:8ab26030e058 85 #endif
Kojto 98:8ab26030e058 86 #if defined( IDAC_CTRL_PRSSEL_PRSCH5 )
Kojto 98:8ab26030e058 87 idacPRSSELCh5 = IDAC_CTRL_PRSSEL_PRSCH5, /**< PRS channel 5. */
Kojto 98:8ab26030e058 88 #endif
Kojto 98:8ab26030e058 89 #if defined( IDAC_CTRL_PRSSEL_PRSCH6 )
Kojto 98:8ab26030e058 90 idacPRSSELCh6 = IDAC_CTRL_PRSSEL_PRSCH6, /**< PRS channel 6. */
Kojto 98:8ab26030e058 91 #endif
Kojto 98:8ab26030e058 92 #if defined( IDAC_CTRL_PRSSEL_PRSCH7 )
Kojto 98:8ab26030e058 93 idacPRSSELCh7 = IDAC_CTRL_PRSSEL_PRSCH7, /**< PRS channel 7. */
Kojto 98:8ab26030e058 94 #endif
Kojto 98:8ab26030e058 95 #if defined( IDAC_CTRL_PRSSEL_PRSCH8 )
Kojto 98:8ab26030e058 96 idacPRSSELCh8 = IDAC_CTRL_PRSSEL_PRSCH8, /**< PRS channel 8. */
Kojto 98:8ab26030e058 97 #endif
Kojto 98:8ab26030e058 98 #if defined( IDAC_CTRL_PRSSEL_PRSCH9 )
Kojto 98:8ab26030e058 99 idacPRSSELCh9 = IDAC_CTRL_PRSSEL_PRSCH9, /**< PRS channel 9. */
Kojto 98:8ab26030e058 100 #endif
Kojto 98:8ab26030e058 101 #if defined( IDAC_CTRL_PRSSEL_PRSCH10 )
Kojto 98:8ab26030e058 102 idacPRSSELCh10 = IDAC_CTRL_PRSSEL_PRSCH10, /**< PRS channel 10 */
Kojto 98:8ab26030e058 103 #endif
Kojto 98:8ab26030e058 104 #if defined( IDAC_CTRL_PRSSEL_PRSCH11 )
Kojto 98:8ab26030e058 105 idacPRSSELCh11 = IDAC_CTRL_PRSSEL_PRSCH11, /**< PRS channel 11 */
Kojto 98:8ab26030e058 106 #endif
Kojto 98:8ab26030e058 107 } IDAC_PRSSEL_TypeDef;
Kojto 98:8ab26030e058 108
Kojto 98:8ab26030e058 109
Kojto 98:8ab26030e058 110 /** Selects which current range to use. */
Kojto 98:8ab26030e058 111 typedef enum
Kojto 98:8ab26030e058 112 {
Kojto 98:8ab26030e058 113 idacCurrentRange0 = IDAC_CURPROG_RANGESEL_RANGE0, /**< current range 0. */
Kojto 98:8ab26030e058 114 idacCurrentRange1 = IDAC_CURPROG_RANGESEL_RANGE1, /**< current range 1. */
Kojto 98:8ab26030e058 115 idacCurrentRange2 = IDAC_CURPROG_RANGESEL_RANGE2, /**< current range 2. */
Kojto 98:8ab26030e058 116 idacCurrentRange3 = IDAC_CURPROG_RANGESEL_RANGE3, /**< current range 3. */
Kojto 98:8ab26030e058 117 } IDAC_Range_TypeDef;
Kojto 98:8ab26030e058 118
Kojto 98:8ab26030e058 119 /*******************************************************************************
Kojto 98:8ab26030e058 120 ******************************* STRUCTS ***********************************
Kojto 98:8ab26030e058 121 ******************************************************************************/
Kojto 98:8ab26030e058 122
Kojto 98:8ab26030e058 123 /** IDAC init structure, common for both channels. */
Kojto 98:8ab26030e058 124 typedef struct
Kojto 98:8ab26030e058 125 {
Kojto 98:8ab26030e058 126 /** Enable IDAC. */
Kojto 98:8ab26030e058 127 bool enable;
Kojto 98:8ab26030e058 128
Kojto 98:8ab26030e058 129 /** Output mode */
Kojto 98:8ab26030e058 130 IDAC_OutMode_TypeDef outMode;
Kojto 98:8ab26030e058 131
Kojto 98:8ab26030e058 132 /**
Kojto 98:8ab26030e058 133 * Enable Peripheral reflex system (PRS) to control IDAC output. If false,
Kojto 98:8ab26030e058 134 * the IDAC output is controlled by writing to IDAC_OUTEN in IDAC_CTRL or
Kojto 98:8ab26030e058 135 * by calling IDAC_OutEnable().
Kojto 98:8ab26030e058 136 */
Kojto 98:8ab26030e058 137 bool prsEnable;
Kojto 98:8ab26030e058 138
Kojto 98:8ab26030e058 139 /**
Kojto 98:8ab26030e058 140 * Peripheral reflex system channel selection. Only applicable if @p prsEnable
Kojto 98:8ab26030e058 141 * is enabled.
Kojto 98:8ab26030e058 142 */
Kojto 98:8ab26030e058 143 IDAC_PRSSEL_TypeDef prsSel;
Kojto 98:8ab26030e058 144
Kojto 98:8ab26030e058 145 /** Enable/disable current sink mode. */
Kojto 98:8ab26030e058 146 bool sinkEnable;
Kojto 98:8ab26030e058 147
Kojto 98:8ab26030e058 148 } IDAC_Init_TypeDef;
Kojto 98:8ab26030e058 149
Kojto 98:8ab26030e058 150 /** Default config for IDAC init structure. */
Kojto 98:8ab26030e058 151 #define IDAC_INIT_DEFAULT \
Kojto 98:8ab26030e058 152 { false, /* Leave IDAC disabled when init done. */ \
Kojto 98:8ab26030e058 153 idacOutputPin, /* Output to IDAC OUT pin. */ \
Kojto 98:8ab26030e058 154 false, /* Disable PRS triggering. */ \
Kojto 98:8ab26030e058 155 idacPRSSELCh0, /* Select PRS ch0 (if PRS triggering enabled). */ \
Kojto 98:8ab26030e058 156 false /* Disable current sink mode. */ \
Kojto 98:8ab26030e058 157 }
Kojto 98:8ab26030e058 158
Kojto 98:8ab26030e058 159
Kojto 98:8ab26030e058 160 /*******************************************************************************
Kojto 98:8ab26030e058 161 ***************************** PROTOTYPES **********************************
Kojto 98:8ab26030e058 162 ******************************************************************************/
Kojto 98:8ab26030e058 163
Kojto 98:8ab26030e058 164 /***************************************************************************//**
Kojto 98:8ab26030e058 165 * @brief
Kojto 98:8ab26030e058 166 * Initialize IDAC.
Kojto 98:8ab26030e058 167 *
Kojto 98:8ab26030e058 168 * @details
Kojto 98:8ab26030e058 169 * Initializes IDAC according to the initialization structure parameter, and
Kojto 98:8ab26030e058 170 * sets the default calibration value stored in the DEVINFO structure.
Kojto 98:8ab26030e058 171 *
Kojto 98:8ab26030e058 172 * @note
Kojto 98:8ab26030e058 173 * This function will disable the IDAC prior to configuration.
Kojto 98:8ab26030e058 174 *
Kojto 98:8ab26030e058 175 * @param[in] idac
Kojto 98:8ab26030e058 176 * Pointer to IDAC peripheral register block.
Kojto 98:8ab26030e058 177 *
Kojto 98:8ab26030e058 178 * @param[in] init
Kojto 98:8ab26030e058 179 * Pointer to IDAC initialization structure.
Kojto 98:8ab26030e058 180 ******************************************************************************/
Kojto 98:8ab26030e058 181 void IDAC_Init(IDAC_TypeDef *idac, const IDAC_Init_TypeDef *init);
Kojto 98:8ab26030e058 182
Kojto 98:8ab26030e058 183
Kojto 98:8ab26030e058 184 /***************************************************************************//**
Kojto 98:8ab26030e058 185 * @brief
Kojto 98:8ab26030e058 186 * Enable/disable IDAC.
Kojto 98:8ab26030e058 187 *
Kojto 98:8ab26030e058 188 * @param[in] idac
Kojto 98:8ab26030e058 189 * Pointer to IDAC peripheral register block.
Kojto 98:8ab26030e058 190 *
Kojto 98:8ab26030e058 191 * @param[in] enable
Kojto 98:8ab26030e058 192 * true to enable IDAC, false to disable.
Kojto 98:8ab26030e058 193 ******************************************************************************/
Kojto 98:8ab26030e058 194 void IDAC_Enable(IDAC_TypeDef *idac, bool enable);
Kojto 98:8ab26030e058 195
Kojto 98:8ab26030e058 196
Kojto 98:8ab26030e058 197 /***************************************************************************//**
Kojto 98:8ab26030e058 198 * @brief
Kojto 98:8ab26030e058 199 * Reset IDAC to same state as after a HW reset.
Kojto 98:8ab26030e058 200 *
Kojto 98:8ab26030e058 201 * @param[in] idac
Kojto 98:8ab26030e058 202 * Pointer to IDAC peripheral register block.
Kojto 98:8ab26030e058 203 ******************************************************************************/
Kojto 98:8ab26030e058 204 void IDAC_Reset(IDAC_TypeDef *idac);
Kojto 98:8ab26030e058 205
Kojto 98:8ab26030e058 206
Kojto 98:8ab26030e058 207 /***************************************************************************//**
Kojto 98:8ab26030e058 208 * @brief
Kojto 98:8ab26030e058 209 * Enable/disable Minimal Output Transition mode.
Kojto 98:8ab26030e058 210 *
Kojto 98:8ab26030e058 211 * @param[in] idac
Kojto 98:8ab26030e058 212 * Pointer to IDAC peripheral register block.
Kojto 98:8ab26030e058 213 *
Kojto 98:8ab26030e058 214 * @param[in] enable
Kojto 98:8ab26030e058 215 * true to enable Minimal Output Transition mode, false to disable.
Kojto 98:8ab26030e058 216 ******************************************************************************/
Kojto 98:8ab26030e058 217 void IDAC_MinimalOutputTransitionMode(IDAC_TypeDef *idac, bool enable);
Kojto 98:8ab26030e058 218
Kojto 98:8ab26030e058 219
Kojto 98:8ab26030e058 220 /***************************************************************************//**
Kojto 98:8ab26030e058 221 * @brief
Kojto 98:8ab26030e058 222 * Set the current range of the IDAC output.
Kojto 98:8ab26030e058 223 *
Kojto 98:8ab26030e058 224 * @details
Kojto 98:8ab26030e058 225 * This function sets the current range of the IDAC output. The function
Kojto 98:8ab26030e058 226 * also updates the IDAC calibration register (IDAC_CAL) with the default
Kojto 98:8ab26030e058 227 * calibration value (from DEVINFO, factory setting) corresponding to the
Kojto 98:8ab26030e058 228 * specified range.
Kojto 98:8ab26030e058 229 *
Kojto 98:8ab26030e058 230 * @param[in] idac
Kojto 98:8ab26030e058 231 * Pointer to IDAC peripheral register block.
Kojto 98:8ab26030e058 232 *
Kojto 98:8ab26030e058 233 * @param[in] range
Kojto 98:8ab26030e058 234 * Current range value.
Kojto 98:8ab26030e058 235 ******************************************************************************/
Kojto 98:8ab26030e058 236 void IDAC_RangeSet(IDAC_TypeDef *idac, const IDAC_Range_TypeDef range);
Kojto 98:8ab26030e058 237
Kojto 98:8ab26030e058 238
Kojto 98:8ab26030e058 239 /***************************************************************************//**
Kojto 98:8ab26030e058 240 * @brief
Kojto 98:8ab26030e058 241 * Set the current step of the IDAC output.
Kojto 98:8ab26030e058 242 *
Kojto 98:8ab26030e058 243 * @param[in] idac
Kojto 98:8ab26030e058 244 * Pointer to IDAC peripheral register block.
Kojto 98:8ab26030e058 245 *
Kojto 98:8ab26030e058 246 * @param[in] step
Kojto 98:8ab26030e058 247 * Step value for IDAC output. Valid range is 0-31.
Kojto 98:8ab26030e058 248 ******************************************************************************/
Kojto 98:8ab26030e058 249 void IDAC_StepSet(IDAC_TypeDef *idac, const uint32_t step);
Kojto 98:8ab26030e058 250
Kojto 98:8ab26030e058 251
Kojto 98:8ab26030e058 252 /***************************************************************************//**
Kojto 98:8ab26030e058 253 * @brief
Kojto 98:8ab26030e058 254 * Enable/disable the IDAC OUT pin.
Kojto 98:8ab26030e058 255 *
Kojto 98:8ab26030e058 256 * @param[in] idac
Kojto 98:8ab26030e058 257 * Pointer to IDAC peripheral register block.
Kojto 98:8ab26030e058 258 *
Kojto 98:8ab26030e058 259 * @param[in] enable
Kojto 98:8ab26030e058 260 * true to enable the IDAC OUT pin, false to disable.
Kojto 98:8ab26030e058 261 ******************************************************************************/
Kojto 98:8ab26030e058 262 void IDAC_OutEnable(IDAC_TypeDef *idac, bool enable);
Kojto 98:8ab26030e058 263
Kojto 98:8ab26030e058 264
Kojto 98:8ab26030e058 265 /** @} (end addtogroup IDAC) */
Kojto 98:8ab26030e058 266 /** @} (end addtogroup EM_Library) */
Kojto 98:8ab26030e058 267
Kojto 98:8ab26030e058 268 #ifdef __cplusplus
Kojto 98:8ab26030e058 269 }
Kojto 98:8ab26030e058 270 #endif
Kojto 98:8ab26030e058 271
Kojto 98:8ab26030e058 272 #endif /* defined(IDAC_COUNT) && (IDAC_COUNT > 0) */
Kojto 98:8ab26030e058 273
Kojto 98:8ab26030e058 274 #endif /* __SILICON_LABS_EM_IDAC_H_ */