added prescaler for 16 bit pwm in LPC1347 target

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Fri Sep 02 15:07:44 2016 +0100
Revision:
144:ef7eb2e8f9f7
This updates the lib to the mbed lib v125

Who changed what in which revision?

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