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:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 145:64910690c574 1 /*
AnnaBridge 145:64910690c574 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
AnnaBridge 145:64910690c574 3 * All rights reserved.
AnnaBridge 145:64910690c574 4 *
AnnaBridge 145:64910690c574 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 145:64910690c574 6 * are permitted provided that the following conditions are met:
AnnaBridge 145:64910690c574 7 *
AnnaBridge 145:64910690c574 8 * o Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 145:64910690c574 9 * of conditions and the following disclaimer.
AnnaBridge 145:64910690c574 10 *
AnnaBridge 145:64910690c574 11 * o Redistributions in binary form must reproduce the above copyright notice, this
AnnaBridge 145:64910690c574 12 * list of conditions and the following disclaimer in the documentation and/or
AnnaBridge 145:64910690c574 13 * other materials provided with the distribution.
AnnaBridge 145:64910690c574 14 *
AnnaBridge 145:64910690c574 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
AnnaBridge 145:64910690c574 16 * contributors may be used to endorse or promote products derived from this
AnnaBridge 145:64910690c574 17 * software without specific prior written permission.
AnnaBridge 145:64910690c574 18 *
AnnaBridge 145:64910690c574 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 145:64910690c574 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 145:64910690c574 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 145:64910690c574 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 145:64910690c574 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 145:64910690c574 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 145:64910690c574 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 145:64910690c574 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 145:64910690c574 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 145:64910690c574 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 145:64910690c574 29 */
AnnaBridge 145:64910690c574 30 #ifndef _FSL_EWM_H_
AnnaBridge 145:64910690c574 31 #define _FSL_EWM_H_
AnnaBridge 145:64910690c574 32
AnnaBridge 145:64910690c574 33 #include "fsl_common.h"
AnnaBridge 145:64910690c574 34
AnnaBridge 145:64910690c574 35 /*!
AnnaBridge 145:64910690c574 36 * @addtogroup ewm
AnnaBridge 145:64910690c574 37 * @{
AnnaBridge 145:64910690c574 38 */
AnnaBridge 145:64910690c574 39
AnnaBridge 145:64910690c574 40
AnnaBridge 145:64910690c574 41 /*******************************************************************************
AnnaBridge 145:64910690c574 42 * Definitions
AnnaBridge 145:64910690c574 43 *******************************************************************************/
AnnaBridge 145:64910690c574 44
AnnaBridge 145:64910690c574 45 /*! @name Driver version */
AnnaBridge 145:64910690c574 46 /*@{*/
AnnaBridge 145:64910690c574 47 /*! @brief EWM driver version 2.0.1. */
AnnaBridge 145:64910690c574 48 #define FSL_EWM_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
AnnaBridge 145:64910690c574 49 /*@}*/
AnnaBridge 145:64910690c574 50
AnnaBridge 145:64910690c574 51 /*! @brief Describes EWM clock source. */
AnnaBridge 145:64910690c574 52 #if defined(FSL_FEATURE_EWM_HAS_CLOCK_SELECT) && FSL_FEATURE_EWM_HAS_CLOCK_SELECT
AnnaBridge 145:64910690c574 53 typedef enum _ewm_lpo_clock_source
AnnaBridge 145:64910690c574 54 {
AnnaBridge 145:64910690c574 55 kEWM_LpoClockSource0 = 0U, /*!< EWM clock sourced from lpo_clk[0]*/
AnnaBridge 145:64910690c574 56 kEWM_LpoClockSource1 = 1U, /*!< EWM clock sourced from lpo_clk[1]*/
AnnaBridge 145:64910690c574 57 kEWM_LpoClockSource2 = 2U, /*!< EWM clock sourced from lpo_clk[2]*/
AnnaBridge 145:64910690c574 58 kEWM_LpoClockSource3 = 3U, /*!< EWM clock sourced from lpo_clk[3]*/
AnnaBridge 145:64910690c574 59 } ewm_lpo_clock_source_t;
AnnaBridge 145:64910690c574 60 #endif /* FSL_FEATURE_EWM_HAS_CLOCK_SELECT */
AnnaBridge 145:64910690c574 61
AnnaBridge 145:64910690c574 62 /*!
AnnaBridge 145:64910690c574 63 * @brief Data structure for EWM configuration.
AnnaBridge 145:64910690c574 64 *
AnnaBridge 145:64910690c574 65 * This structure is used to configure the EWM.
AnnaBridge 145:64910690c574 66 */
AnnaBridge 145:64910690c574 67 typedef struct _ewm_config
AnnaBridge 145:64910690c574 68 {
AnnaBridge 145:64910690c574 69 bool enableEwm; /*!< Enable EWM module */
AnnaBridge 145:64910690c574 70 bool enableEwmInput; /*!< Enable EWM_in input */
AnnaBridge 145:64910690c574 71 bool setInputAssertLogic; /*!< EWM_in signal assertion state */
AnnaBridge 145:64910690c574 72 bool enableInterrupt; /*!< Enable EWM interrupt */
AnnaBridge 145:64910690c574 73 #if defined(FSL_FEATURE_EWM_HAS_CLOCK_SELECT) && FSL_FEATURE_EWM_HAS_CLOCK_SELECT
AnnaBridge 145:64910690c574 74 ewm_lpo_clock_source_t clockSource; /*!< Clock source select */
AnnaBridge 145:64910690c574 75 #endif /* FSL_FEATURE_EWM_HAS_CLOCK_SELECT */
AnnaBridge 145:64910690c574 76 #if defined(FSL_FEATURE_EWM_HAS_PRESCALER) && FSL_FEATURE_EWM_HAS_PRESCALER
AnnaBridge 145:64910690c574 77 uint8_t prescaler; /*!< Clock prescaler value */
AnnaBridge 145:64910690c574 78 #endif /* FSL_FEATURE_EWM_HAS_PRESCALER */
AnnaBridge 145:64910690c574 79 uint8_t compareLowValue; /*!< Compare low-register value */
AnnaBridge 145:64910690c574 80 uint8_t compareHighValue; /*!< Compare high-register value */
AnnaBridge 145:64910690c574 81 } ewm_config_t;
AnnaBridge 145:64910690c574 82
AnnaBridge 145:64910690c574 83 /*!
AnnaBridge 145:64910690c574 84 * @brief EWM interrupt configuration structure with default settings all disabled.
AnnaBridge 145:64910690c574 85 *
AnnaBridge 145:64910690c574 86 * This structure contains the settings for all of EWM interrupt configurations.
AnnaBridge 145:64910690c574 87 */
AnnaBridge 145:64910690c574 88 enum _ewm_interrupt_enable_t
AnnaBridge 145:64910690c574 89 {
AnnaBridge 145:64910690c574 90 kEWM_InterruptEnable = EWM_CTRL_INTEN_MASK, /*!< Enable the EWM to generate an interrupt*/
AnnaBridge 145:64910690c574 91 };
AnnaBridge 145:64910690c574 92
AnnaBridge 145:64910690c574 93 /*!
AnnaBridge 145:64910690c574 94 * @brief EWM status flags.
AnnaBridge 145:64910690c574 95 *
AnnaBridge 145:64910690c574 96 * This structure contains the constants for the EWM status flags for use in the EWM functions.
AnnaBridge 145:64910690c574 97 */
AnnaBridge 145:64910690c574 98 enum _ewm_status_flags_t
AnnaBridge 145:64910690c574 99 {
AnnaBridge 145:64910690c574 100 kEWM_RunningFlag = EWM_CTRL_EWMEN_MASK, /*!< Running flag, set when EWM is enabled*/
AnnaBridge 145:64910690c574 101 };
AnnaBridge 145:64910690c574 102
AnnaBridge 145:64910690c574 103 /*******************************************************************************
AnnaBridge 145:64910690c574 104 * API
AnnaBridge 145:64910690c574 105 *******************************************************************************/
AnnaBridge 145:64910690c574 106
AnnaBridge 145:64910690c574 107 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 108 extern "C" {
AnnaBridge 145:64910690c574 109 #endif /* __cplusplus */
AnnaBridge 145:64910690c574 110
AnnaBridge 145:64910690c574 111 /*!
AnnaBridge 145:64910690c574 112 * @name EWM initialization and de-initialization
AnnaBridge 145:64910690c574 113 * @{
AnnaBridge 145:64910690c574 114 */
AnnaBridge 145:64910690c574 115
AnnaBridge 145:64910690c574 116 /*!
AnnaBridge 145:64910690c574 117 * @brief Initializes the EWM peripheral.
AnnaBridge 145:64910690c574 118 *
AnnaBridge 145:64910690c574 119 * This function is used to initialize the EWM. After calling, the EWM
AnnaBridge 145:64910690c574 120 * runs immediately according to the configuration.
AnnaBridge 145:64910690c574 121 * Note that, except for the interrupt enable control bit, other control bits and registers are write once after a
AnnaBridge 145:64910690c574 122 * CPU reset. Modifying them more than once generates a bus transfer error.
AnnaBridge 145:64910690c574 123 *
AnnaBridge 145:64910690c574 124 * This is an example.
AnnaBridge 145:64910690c574 125 * @code
AnnaBridge 145:64910690c574 126 * ewm_config_t config;
AnnaBridge 145:64910690c574 127 * EWM_GetDefaultConfig(&config);
AnnaBridge 145:64910690c574 128 * config.compareHighValue = 0xAAU;
AnnaBridge 145:64910690c574 129 * EWM_Init(ewm_base,&config);
AnnaBridge 145:64910690c574 130 * @endcode
AnnaBridge 145:64910690c574 131 *
AnnaBridge 145:64910690c574 132 * @param base EWM peripheral base address
AnnaBridge 145:64910690c574 133 * @param config The configuration of the EWM
AnnaBridge 145:64910690c574 134 */
AnnaBridge 145:64910690c574 135 void EWM_Init(EWM_Type *base, const ewm_config_t *config);
AnnaBridge 145:64910690c574 136
AnnaBridge 145:64910690c574 137 /*!
AnnaBridge 145:64910690c574 138 * @brief Deinitializes the EWM peripheral.
AnnaBridge 145:64910690c574 139 *
AnnaBridge 145:64910690c574 140 * This function is used to shut down the EWM.
AnnaBridge 145:64910690c574 141 *
AnnaBridge 145:64910690c574 142 * @param base EWM peripheral base address
AnnaBridge 145:64910690c574 143 */
AnnaBridge 145:64910690c574 144 void EWM_Deinit(EWM_Type *base);
AnnaBridge 145:64910690c574 145
AnnaBridge 145:64910690c574 146 /*!
AnnaBridge 145:64910690c574 147 * @brief Initializes the EWM configuration structure.
AnnaBridge 145:64910690c574 148 *
AnnaBridge 145:64910690c574 149 * This function initializes the EWM configuration structure to default values. The default
AnnaBridge 145:64910690c574 150 * values are as follows.
AnnaBridge 145:64910690c574 151 * @code
AnnaBridge 145:64910690c574 152 * ewmConfig->enableEwm = true;
AnnaBridge 145:64910690c574 153 * ewmConfig->enableEwmInput = false;
AnnaBridge 145:64910690c574 154 * ewmConfig->setInputAssertLogic = false;
AnnaBridge 145:64910690c574 155 * ewmConfig->enableInterrupt = false;
AnnaBridge 145:64910690c574 156 * ewmConfig->ewm_lpo_clock_source_t = kEWM_LpoClockSource0;
AnnaBridge 145:64910690c574 157 * ewmConfig->prescaler = 0;
AnnaBridge 145:64910690c574 158 * ewmConfig->compareLowValue = 0;
AnnaBridge 145:64910690c574 159 * ewmConfig->compareHighValue = 0xFEU;
AnnaBridge 145:64910690c574 160 * @endcode
AnnaBridge 145:64910690c574 161 *
AnnaBridge 145:64910690c574 162 * @param config Pointer to the EWM configuration structure.
AnnaBridge 145:64910690c574 163 * @see ewm_config_t
AnnaBridge 145:64910690c574 164 */
AnnaBridge 145:64910690c574 165 void EWM_GetDefaultConfig(ewm_config_t *config);
AnnaBridge 145:64910690c574 166
AnnaBridge 145:64910690c574 167 /* @} */
AnnaBridge 145:64910690c574 168
AnnaBridge 145:64910690c574 169 /*!
AnnaBridge 145:64910690c574 170 * @name EWM functional Operation
AnnaBridge 145:64910690c574 171 * @{
AnnaBridge 145:64910690c574 172 */
AnnaBridge 145:64910690c574 173
AnnaBridge 145:64910690c574 174 /*!
AnnaBridge 145:64910690c574 175 * @brief Enables the EWM interrupt.
AnnaBridge 145:64910690c574 176 *
AnnaBridge 145:64910690c574 177 * This function enables the EWM interrupt.
AnnaBridge 145:64910690c574 178 *
AnnaBridge 145:64910690c574 179 * @param base EWM peripheral base address
AnnaBridge 145:64910690c574 180 * @param mask The interrupts to enable
AnnaBridge 145:64910690c574 181 * The parameter can be combination of the following source if defined
AnnaBridge 145:64910690c574 182 * @arg kEWM_InterruptEnable
AnnaBridge 145:64910690c574 183 */
AnnaBridge 145:64910690c574 184 static inline void EWM_EnableInterrupts(EWM_Type *base, uint32_t mask)
AnnaBridge 145:64910690c574 185 {
AnnaBridge 145:64910690c574 186 base->CTRL |= mask;
AnnaBridge 145:64910690c574 187 }
AnnaBridge 145:64910690c574 188
AnnaBridge 145:64910690c574 189 /*!
AnnaBridge 145:64910690c574 190 * @brief Disables the EWM interrupt.
AnnaBridge 145:64910690c574 191 *
AnnaBridge 145:64910690c574 192 * This function enables the EWM interrupt.
AnnaBridge 145:64910690c574 193 *
AnnaBridge 145:64910690c574 194 * @param base EWM peripheral base address
AnnaBridge 145:64910690c574 195 * @param mask The interrupts to disable
AnnaBridge 145:64910690c574 196 * The parameter can be combination of the following source if defined
AnnaBridge 145:64910690c574 197 * @arg kEWM_InterruptEnable
AnnaBridge 145:64910690c574 198 */
AnnaBridge 145:64910690c574 199 static inline void EWM_DisableInterrupts(EWM_Type *base, uint32_t mask)
AnnaBridge 145:64910690c574 200 {
AnnaBridge 145:64910690c574 201 base->CTRL &= ~mask;
AnnaBridge 145:64910690c574 202 }
AnnaBridge 145:64910690c574 203
AnnaBridge 145:64910690c574 204 /*!
AnnaBridge 145:64910690c574 205 * @brief Gets all status flags.
AnnaBridge 145:64910690c574 206 *
AnnaBridge 145:64910690c574 207 * This function gets all status flags.
AnnaBridge 145:64910690c574 208 *
AnnaBridge 145:64910690c574 209 * This is an example for getting the running flag.
AnnaBridge 145:64910690c574 210 * @code
AnnaBridge 145:64910690c574 211 * uint32_t status;
AnnaBridge 145:64910690c574 212 * status = EWM_GetStatusFlags(ewm_base) & kEWM_RunningFlag;
AnnaBridge 145:64910690c574 213 * @endcode
AnnaBridge 145:64910690c574 214 * @param base EWM peripheral base address
AnnaBridge 145:64910690c574 215 * @return State of the status flag: asserted (true) or not-asserted (false).@see _ewm_status_flags_t
AnnaBridge 145:64910690c574 216 * - True: a related status flag has been set.
AnnaBridge 145:64910690c574 217 * - False: a related status flag is not set.
AnnaBridge 145:64910690c574 218 */
AnnaBridge 145:64910690c574 219 static inline uint32_t EWM_GetStatusFlags(EWM_Type *base)
AnnaBridge 145:64910690c574 220 {
AnnaBridge 145:64910690c574 221 return (base->CTRL & EWM_CTRL_EWMEN_MASK);
AnnaBridge 145:64910690c574 222 }
AnnaBridge 145:64910690c574 223
AnnaBridge 145:64910690c574 224 /*!
AnnaBridge 145:64910690c574 225 * @brief Services the EWM.
AnnaBridge 145:64910690c574 226 *
AnnaBridge 145:64910690c574 227 * This function resets the EWM counter to zero.
AnnaBridge 145:64910690c574 228 *
AnnaBridge 145:64910690c574 229 * @param base EWM peripheral base address
AnnaBridge 145:64910690c574 230 */
AnnaBridge 145:64910690c574 231 void EWM_Refresh(EWM_Type *base);
AnnaBridge 145:64910690c574 232
AnnaBridge 145:64910690c574 233 /*@}*/
AnnaBridge 145:64910690c574 234
AnnaBridge 145:64910690c574 235 #if defined(__cplusplus)
AnnaBridge 145:64910690c574 236 }
AnnaBridge 145:64910690c574 237 #endif /* __cplusplus */
AnnaBridge 145:64910690c574 238
AnnaBridge 145:64910690c574 239 /*! @}*/
AnnaBridge 145:64910690c574 240
AnnaBridge 145:64910690c574 241 #endif /* _FSL_EWM_H_ */