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