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