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_KL27Z/TOOLCHAIN_IAR/fsl_cop.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 | 171:3a7713b1edbc | 1 | /* |
AnnaBridge | 171:3a7713b1edbc | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
AnnaBridge | 171:3a7713b1edbc | 3 | * All rights reserved. |
AnnaBridge | 171:3a7713b1edbc | 4 | * |
AnnaBridge | 171:3a7713b1edbc | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 171:3a7713b1edbc | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 171:3a7713b1edbc | 7 | * |
AnnaBridge | 171:3a7713b1edbc | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 171:3a7713b1edbc | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 171:3a7713b1edbc | 10 | * |
AnnaBridge | 171:3a7713b1edbc | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 171:3a7713b1edbc | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 171:3a7713b1edbc | 13 | * other materials provided with the distribution. |
AnnaBridge | 171:3a7713b1edbc | 14 | * |
AnnaBridge | 171:3a7713b1edbc | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
AnnaBridge | 171:3a7713b1edbc | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 171:3a7713b1edbc | 17 | * software without specific prior written permission. |
AnnaBridge | 171:3a7713b1edbc | 18 | * |
AnnaBridge | 171:3a7713b1edbc | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 171:3a7713b1edbc | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 171:3a7713b1edbc | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 171:3a7713b1edbc | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 171:3a7713b1edbc | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 171:3a7713b1edbc | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 171:3a7713b1edbc | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 171:3a7713b1edbc | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 171:3a7713b1edbc | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 171:3a7713b1edbc | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 171:3a7713b1edbc | 29 | */ |
AnnaBridge | 171:3a7713b1edbc | 30 | #ifndef _FSL_COP_H_ |
AnnaBridge | 171:3a7713b1edbc | 31 | #define _FSL_COP_H_ |
AnnaBridge | 171:3a7713b1edbc | 32 | |
AnnaBridge | 171:3a7713b1edbc | 33 | #include "fsl_common.h" |
AnnaBridge | 171:3a7713b1edbc | 34 | |
AnnaBridge | 171:3a7713b1edbc | 35 | /*! |
AnnaBridge | 171:3a7713b1edbc | 36 | * @addtogroup cop_driver |
AnnaBridge | 171:3a7713b1edbc | 37 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 38 | */ |
AnnaBridge | 171:3a7713b1edbc | 39 | |
AnnaBridge | 171:3a7713b1edbc | 40 | /*! @file */ |
AnnaBridge | 171:3a7713b1edbc | 41 | |
AnnaBridge | 171:3a7713b1edbc | 42 | /******************************************************************************* |
AnnaBridge | 171:3a7713b1edbc | 43 | * Definitions |
AnnaBridge | 171:3a7713b1edbc | 44 | *******************************************************************************/ |
AnnaBridge | 171:3a7713b1edbc | 45 | |
AnnaBridge | 171:3a7713b1edbc | 46 | /*! @name Driver version */ |
AnnaBridge | 171:3a7713b1edbc | 47 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 48 | /*! @brief COP driver version 2.0.0. */ |
AnnaBridge | 171:3a7713b1edbc | 49 | #define FSL_COP_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
AnnaBridge | 171:3a7713b1edbc | 50 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 51 | |
AnnaBridge | 171:3a7713b1edbc | 52 | /*! @name COP refresh sequence. */ |
AnnaBridge | 171:3a7713b1edbc | 53 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 54 | #define COP_FIRST_BYTE_OF_REFRESH (0x55U) /*!< First byte of refresh sequence */ |
AnnaBridge | 171:3a7713b1edbc | 55 | #define COP_SECOND_BYTE_OF_REFRESH (0xAAU) /*!< Second byte of refresh sequence */ |
AnnaBridge | 171:3a7713b1edbc | 56 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 57 | |
AnnaBridge | 171:3a7713b1edbc | 58 | /*! @brief COP clock source selection. */ |
AnnaBridge | 171:3a7713b1edbc | 59 | typedef enum _cop_clock_source |
AnnaBridge | 171:3a7713b1edbc | 60 | { |
AnnaBridge | 171:3a7713b1edbc | 61 | kCOP_LpoClock = 0U, /*!< COP clock sourced from LPO */ |
AnnaBridge | 171:3a7713b1edbc | 62 | #if defined(FSL_FEATURE_COP_HAS_MORE_CLKSRC) && FSL_FEATURE_COP_HAS_MORE_CLKSRC |
AnnaBridge | 171:3a7713b1edbc | 63 | kCOP_McgIrClock = 1U, /*!< COP clock sourced from MCGIRCLK */ |
AnnaBridge | 171:3a7713b1edbc | 64 | kCOP_OscErClock = 2U, /*!< COP clock sourced from OSCERCLK */ |
AnnaBridge | 171:3a7713b1edbc | 65 | #endif /* FSL_FEATURE_COP_HAS_MORE_CLKSRC */ |
AnnaBridge | 171:3a7713b1edbc | 66 | kCOP_BusClock = 3U, /*!< COP clock sourced from Bus clock */ |
AnnaBridge | 171:3a7713b1edbc | 67 | } cop_clock_source_t; |
AnnaBridge | 171:3a7713b1edbc | 68 | |
AnnaBridge | 171:3a7713b1edbc | 69 | /*! @brief Define the COP timeout cycles. */ |
AnnaBridge | 171:3a7713b1edbc | 70 | typedef enum _cop_timeout_cycles |
AnnaBridge | 171:3a7713b1edbc | 71 | { |
AnnaBridge | 171:3a7713b1edbc | 72 | kCOP_2Power5CyclesOr2Power13Cycles = 1U, /*!< 2^5 or 2^13 clock cycles */ |
AnnaBridge | 171:3a7713b1edbc | 73 | kCOP_2Power8CyclesOr2Power16Cycles = 2U, /*!< 2^8 or 2^16 clock cycles */ |
AnnaBridge | 171:3a7713b1edbc | 74 | kCOP_2Power10CyclesOr2Power18Cycles = 3U, /*!< 2^10 or 2^18 clock cycles */ |
AnnaBridge | 171:3a7713b1edbc | 75 | } cop_timeout_cycles_t; |
AnnaBridge | 171:3a7713b1edbc | 76 | |
AnnaBridge | 171:3a7713b1edbc | 77 | #if defined(FSL_FEATURE_COP_HAS_LONGTIME_MODE) && FSL_FEATURE_COP_HAS_LONGTIME_MODE |
AnnaBridge | 171:3a7713b1edbc | 78 | /*! @breif Define the COP timeout mode. */ |
AnnaBridge | 171:3a7713b1edbc | 79 | typedef enum _cop_timeout_mode |
AnnaBridge | 171:3a7713b1edbc | 80 | { |
AnnaBridge | 171:3a7713b1edbc | 81 | kCOP_ShortTimeoutMode = 0U, /*!< COP selects long timeout */ |
AnnaBridge | 171:3a7713b1edbc | 82 | kCOP_LongTimeoutMode = 1U, /*!< COP selects short timeout */ |
AnnaBridge | 171:3a7713b1edbc | 83 | } cop_timeout_mode_t; |
AnnaBridge | 171:3a7713b1edbc | 84 | #endif /* FSL_FEATURE_COP_HAS_LONGTIME_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 85 | |
AnnaBridge | 171:3a7713b1edbc | 86 | /*! @brief Describes COP configuration structure. */ |
AnnaBridge | 171:3a7713b1edbc | 87 | typedef struct _cop_config |
AnnaBridge | 171:3a7713b1edbc | 88 | { |
AnnaBridge | 171:3a7713b1edbc | 89 | bool enableWindowMode; /*!< COP run mode: window mode or normal mode */ |
AnnaBridge | 171:3a7713b1edbc | 90 | #if defined(FSL_FEATURE_COP_HAS_LONGTIME_MODE) && FSL_FEATURE_COP_HAS_LONGTIME_MODE |
AnnaBridge | 171:3a7713b1edbc | 91 | cop_timeout_mode_t timeoutMode; /*!< COP timeout mode: long timeout or short timeout */ |
AnnaBridge | 171:3a7713b1edbc | 92 | bool enableStop; /*!< Enable or disable COP in STOP mode */ |
AnnaBridge | 171:3a7713b1edbc | 93 | bool enableDebug; /*!< Enable or disable COP in DEBUG mode */ |
AnnaBridge | 171:3a7713b1edbc | 94 | #endif /* FSL_FEATURE_COP_HAS_LONGTIME_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 95 | cop_clock_source_t clockSource; /*!< Set COP clock source */ |
AnnaBridge | 171:3a7713b1edbc | 96 | cop_timeout_cycles_t timeoutCycles; /*!< Set COP timeout value */ |
AnnaBridge | 171:3a7713b1edbc | 97 | } cop_config_t; |
AnnaBridge | 171:3a7713b1edbc | 98 | |
AnnaBridge | 171:3a7713b1edbc | 99 | /******************************************************************************* |
AnnaBridge | 171:3a7713b1edbc | 100 | * API |
AnnaBridge | 171:3a7713b1edbc | 101 | *******************************************************************************/ |
AnnaBridge | 171:3a7713b1edbc | 102 | |
AnnaBridge | 171:3a7713b1edbc | 103 | #if defined(__cplusplus) |
AnnaBridge | 171:3a7713b1edbc | 104 | extern "C" { |
AnnaBridge | 171:3a7713b1edbc | 105 | #endif /* __cplusplus*/ |
AnnaBridge | 171:3a7713b1edbc | 106 | |
AnnaBridge | 171:3a7713b1edbc | 107 | /*! |
AnnaBridge | 171:3a7713b1edbc | 108 | * @name COP Functional Operation |
AnnaBridge | 171:3a7713b1edbc | 109 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 110 | */ |
AnnaBridge | 171:3a7713b1edbc | 111 | |
AnnaBridge | 171:3a7713b1edbc | 112 | /*! |
AnnaBridge | 171:3a7713b1edbc | 113 | * @brief Initializes the COP configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 114 | * |
AnnaBridge | 171:3a7713b1edbc | 115 | * This function initializes the COP configuration structure to default values. The default |
AnnaBridge | 171:3a7713b1edbc | 116 | * values are: |
AnnaBridge | 171:3a7713b1edbc | 117 | * @code |
AnnaBridge | 171:3a7713b1edbc | 118 | * copConfig->enableWindowMode = false; |
AnnaBridge | 171:3a7713b1edbc | 119 | * copConfig->timeoutMode = kCOP_LongTimeoutMode; |
AnnaBridge | 171:3a7713b1edbc | 120 | * copConfig->enableStop = false; |
AnnaBridge | 171:3a7713b1edbc | 121 | * copConfig->enableDebug = false; |
AnnaBridge | 171:3a7713b1edbc | 122 | * copConfig->clockSource = kCOP_LpoClock; |
AnnaBridge | 171:3a7713b1edbc | 123 | * copConfig->timeoutCycles = kCOP_2Power10CyclesOr2Power18Cycles; |
AnnaBridge | 171:3a7713b1edbc | 124 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 125 | * |
AnnaBridge | 171:3a7713b1edbc | 126 | * @param config Pointer to the COP configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 127 | * @see cop_config_t |
AnnaBridge | 171:3a7713b1edbc | 128 | */ |
AnnaBridge | 171:3a7713b1edbc | 129 | void COP_GetDefaultConfig(cop_config_t *config); |
AnnaBridge | 171:3a7713b1edbc | 130 | |
AnnaBridge | 171:3a7713b1edbc | 131 | /*! |
AnnaBridge | 171:3a7713b1edbc | 132 | * @brief Initializes the COP module. |
AnnaBridge | 171:3a7713b1edbc | 133 | * |
AnnaBridge | 171:3a7713b1edbc | 134 | * This function configures the COP. After it is called, the COP |
AnnaBridge | 171:3a7713b1edbc | 135 | * starts running according to the configuration. |
AnnaBridge | 171:3a7713b1edbc | 136 | * Because all COP control registers are write-once only, the COP_Init function |
AnnaBridge | 171:3a7713b1edbc | 137 | * and the COP_Disable function can be called only once. A second call has no effect. |
AnnaBridge | 171:3a7713b1edbc | 138 | * |
AnnaBridge | 171:3a7713b1edbc | 139 | * Example: |
AnnaBridge | 171:3a7713b1edbc | 140 | * @code |
AnnaBridge | 171:3a7713b1edbc | 141 | * cop_config_t config; |
AnnaBridge | 171:3a7713b1edbc | 142 | * COP_GetDefaultConfig(&config); |
AnnaBridge | 171:3a7713b1edbc | 143 | * config.timeoutCycles = kCOP_2Power8CyclesOr2Power16Cycles; |
AnnaBridge | 171:3a7713b1edbc | 144 | * COP_Init(sim_base,&config); |
AnnaBridge | 171:3a7713b1edbc | 145 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 146 | * |
AnnaBridge | 171:3a7713b1edbc | 147 | * @param base SIM peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 148 | * @param config The configuration of COP. |
AnnaBridge | 171:3a7713b1edbc | 149 | */ |
AnnaBridge | 171:3a7713b1edbc | 150 | void COP_Init(SIM_Type *base, const cop_config_t *config); |
AnnaBridge | 171:3a7713b1edbc | 151 | |
AnnaBridge | 171:3a7713b1edbc | 152 | /*! |
AnnaBridge | 171:3a7713b1edbc | 153 | * @brief De-initializes the COP module. |
AnnaBridge | 171:3a7713b1edbc | 154 | * This dedicated function is not provided. Instead, the COP_Disable function can be used to disable the COP. |
AnnaBridge | 171:3a7713b1edbc | 155 | */ |
AnnaBridge | 171:3a7713b1edbc | 156 | |
AnnaBridge | 171:3a7713b1edbc | 157 | /*! |
AnnaBridge | 171:3a7713b1edbc | 158 | * @brief Disables the COP module. |
AnnaBridge | 171:3a7713b1edbc | 159 | * |
AnnaBridge | 171:3a7713b1edbc | 160 | * This function disables the COP Watchdog. |
AnnaBridge | 171:3a7713b1edbc | 161 | * Note: The COP configuration register is a write-once after reset. |
AnnaBridge | 171:3a7713b1edbc | 162 | * To disable the COP Watchdog, call this function first. |
AnnaBridge | 171:3a7713b1edbc | 163 | * |
AnnaBridge | 171:3a7713b1edbc | 164 | * @param base SIM peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 165 | */ |
AnnaBridge | 171:3a7713b1edbc | 166 | static inline void COP_Disable(SIM_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 167 | { |
AnnaBridge | 171:3a7713b1edbc | 168 | base->COPC &= ~SIM_COPC_COPT_MASK; |
AnnaBridge | 171:3a7713b1edbc | 169 | } |
AnnaBridge | 171:3a7713b1edbc | 170 | |
AnnaBridge | 171:3a7713b1edbc | 171 | /*! |
AnnaBridge | 171:3a7713b1edbc | 172 | * @brief Refreshes the COP timer |
AnnaBridge | 171:3a7713b1edbc | 173 | * |
AnnaBridge | 171:3a7713b1edbc | 174 | * This function feeds the COP. |
AnnaBridge | 171:3a7713b1edbc | 175 | * |
AnnaBridge | 171:3a7713b1edbc | 176 | * @param base SIM peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 177 | */ |
AnnaBridge | 171:3a7713b1edbc | 178 | void COP_Refresh(SIM_Type *base); |
AnnaBridge | 171:3a7713b1edbc | 179 | |
AnnaBridge | 171:3a7713b1edbc | 180 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 181 | |
AnnaBridge | 171:3a7713b1edbc | 182 | #if defined(__cplusplus) |
AnnaBridge | 171:3a7713b1edbc | 183 | } |
AnnaBridge | 171:3a7713b1edbc | 184 | #endif /* __cplusplus */ |
AnnaBridge | 171:3a7713b1edbc | 185 | |
AnnaBridge | 171:3a7713b1edbc | 186 | /*! @}*/ |
AnnaBridge | 171:3a7713b1edbc | 187 | |
AnnaBridge | 171:3a7713b1edbc | 188 | #endif /* _FSL_COP_H_ */ |