Forked.

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Tue Nov 08 17:45:16 2016 +0000
Revision:
150:02e0a0aed4ec
This updates the lib to the mbed lib v129

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 150:02e0a0aed4ec 1 /*******************************************************************************
<> 150:02e0a0aed4ec 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
<> 150:02e0a0aed4ec 3 *
<> 150:02e0a0aed4ec 4 * Permission is hereby granted, free of charge, to any person obtaining a
<> 150:02e0a0aed4ec 5 * copy of this software and associated documentation files (the "Software"),
<> 150:02e0a0aed4ec 6 * to deal in the Software without restriction, including without limitation
<> 150:02e0a0aed4ec 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
<> 150:02e0a0aed4ec 8 * and/or sell copies of the Software, and to permit persons to whom the
<> 150:02e0a0aed4ec 9 * Software is furnished to do so, subject to the following conditions:
<> 150:02e0a0aed4ec 10 *
<> 150:02e0a0aed4ec 11 * The above copyright notice and this permission notice shall be included
<> 150:02e0a0aed4ec 12 * in all copies or substantial portions of the Software.
<> 150:02e0a0aed4ec 13 *
<> 150:02e0a0aed4ec 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
<> 150:02e0a0aed4ec 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
<> 150:02e0a0aed4ec 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
<> 150:02e0a0aed4ec 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
<> 150:02e0a0aed4ec 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
<> 150:02e0a0aed4ec 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
<> 150:02e0a0aed4ec 20 * OTHER DEALINGS IN THE SOFTWARE.
<> 150:02e0a0aed4ec 21 *
<> 150:02e0a0aed4ec 22 * Except as contained in this notice, the name of Maxim Integrated
<> 150:02e0a0aed4ec 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
<> 150:02e0a0aed4ec 24 * Products, Inc. Branding Policy.
<> 150:02e0a0aed4ec 25 *
<> 150:02e0a0aed4ec 26 * The mere transfer of this software does not imply any licenses
<> 150:02e0a0aed4ec 27 * of trade secrets, proprietary technology, copyrights, patents,
<> 150:02e0a0aed4ec 28 * trademarks, maskwork rights, or any other form of intellectual
<> 150:02e0a0aed4ec 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
<> 150:02e0a0aed4ec 30 * ownership rights.
<> 150:02e0a0aed4ec 31 *
<> 150:02e0a0aed4ec 32 * $Date: 2016-04-27 09:12:45 -0500 (Wed, 27 Apr 2016) $
<> 150:02e0a0aed4ec 33 * $Revision: 22531 $
<> 150:02e0a0aed4ec 34 *
<> 150:02e0a0aed4ec 35 ******************************************************************************/
<> 150:02e0a0aed4ec 36
<> 150:02e0a0aed4ec 37 /**
<> 150:02e0a0aed4ec 38 * @file clkman.h
<> 150:02e0a0aed4ec 39 * @brief Clock management driver header file.
<> 150:02e0a0aed4ec 40 */
<> 150:02e0a0aed4ec 41
<> 150:02e0a0aed4ec 42 #ifndef _CLKMAN_H_
<> 150:02e0a0aed4ec 43 #define _CLKMAN_H_
<> 150:02e0a0aed4ec 44
<> 150:02e0a0aed4ec 45 /***** Includes *****/
<> 150:02e0a0aed4ec 46 #include "mxc_config.h"
<> 150:02e0a0aed4ec 47 #include "clkman_regs.h"
<> 150:02e0a0aed4ec 48
<> 150:02e0a0aed4ec 49 #ifdef __cplusplus
<> 150:02e0a0aed4ec 50 extern "C" {
<> 150:02e0a0aed4ec 51 #endif
<> 150:02e0a0aed4ec 52
<> 150:02e0a0aed4ec 53 /***** Definitions *****/
<> 150:02e0a0aed4ec 54
<> 150:02e0a0aed4ec 55 /**
<> 150:02e0a0aed4ec 56 * @brief Defines clock source selections for the system clock.
<> 150:02e0a0aed4ec 57 */
<> 150:02e0a0aed4ec 58 typedef enum {
<> 150:02e0a0aed4ec 59 /** Clock select for 96MHz oscillator */
<> 150:02e0a0aed4ec 60 CLKMAN_SYSTEM_SOURCE_96MHZ,
<> 150:02e0a0aed4ec 61 /** Clock select for 4MHz oscillator */
<> 150:02e0a0aed4ec 62 CLKMAN_SYSTEM_SOURCE_4MHZ
<> 150:02e0a0aed4ec 63 }
<> 150:02e0a0aed4ec 64 clkman_system_source_select_t;
<> 150:02e0a0aed4ec 65
<> 150:02e0a0aed4ec 66 /**
<> 150:02e0a0aed4ec 67 * @brief Defines clock scales for the system clock.
<> 150:02e0a0aed4ec 68 * @note 4MHz System source can only be divided down by a maximum factor of 8.
<> 150:02e0a0aed4ec 69 */
<> 150:02e0a0aed4ec 70 typedef enum {
<> 150:02e0a0aed4ec 71 CLKMAN_SYSTEM_SCALE_DIV_1, /** Clock scale for dividing system by 1 */
<> 150:02e0a0aed4ec 72 CLKMAN_SYSTEM_SCALE_DIV_2, /** Clock scale for dividing system by 2 */
<> 150:02e0a0aed4ec 73 CLKMAN_SYSTEM_SCALE_DIV_4, /** Clock scale for dividing system by 4 */
<> 150:02e0a0aed4ec 74 CLKMAN_SYSTEM_SCALE_DIV_8, /** Clock scale for dividing system by 8 */
<> 150:02e0a0aed4ec 75 CLKMAN_SYSTEM_SCALE_DIV_16 /** Clock scale for dividing system by 16 */
<> 150:02e0a0aed4ec 76 } clkman_system_scale_t;
<> 150:02e0a0aed4ec 77
<> 150:02e0a0aed4ec 78 /**
<> 150:02e0a0aed4ec 79 * @brief Selects an internal module clock for clock scaling configuration.
<> 150:02e0a0aed4ec 80 */
<> 150:02e0a0aed4ec 81 typedef enum {
<> 150:02e0a0aed4ec 82 CLKMAN_CLK_CPU = 0, /** CPU clock */
<> 150:02e0a0aed4ec 83 CLKMAN_CLK_SYNC = 1, /** Synchronizer clock */
<> 150:02e0a0aed4ec 84 CLKMAN_CLK_SPIX = 2, /** SPI XIP module clock */
<> 150:02e0a0aed4ec 85 CLKMAN_CLK_PRNG = 3, /** PRNG module clock */
<> 150:02e0a0aed4ec 86 CLKMAN_CLK_WDT0 = 4, /** Watchdog Timer 0 clock */
<> 150:02e0a0aed4ec 87 CLKMAN_CLK_WDT1 = 5, /** Watchdog Timer 1 clock */
<> 150:02e0a0aed4ec 88 CLKMAN_CLK_GPIO = 6, /** GPIO module clock */
<> 150:02e0a0aed4ec 89 CLKMAN_CLK_PT = 7, /** Pulse Train engine clock */
<> 150:02e0a0aed4ec 90 CLKMAN_CLK_UART = 8, /** UART clock */
<> 150:02e0a0aed4ec 91 CLKMAN_CLK_I2CM = 9, /** I2C Master module clock (for all instances) */
<> 150:02e0a0aed4ec 92 CLKMAN_CLK_I2CS = 10, /** I2C Slave module clock */
<> 150:02e0a0aed4ec 93 CLKMAN_CLK_SPIM0 = 11, /** SPI Master instance 0 module clock */
<> 150:02e0a0aed4ec 94 CLKMAN_CLK_SPIM1 = 12, /** SPI Master instance 1 module clock */
<> 150:02e0a0aed4ec 95 CLKMAN_CLK_SPIM2 = 13, /** SPI Master instance 2 module clock */
<> 150:02e0a0aed4ec 96 CLKMAN_CLK_OWM = 15, /** OWM module clock*/
<> 150:02e0a0aed4ec 97 CLKMAN_CLK_SPIS = 16, /** SPI Slave module clock*/
<> 150:02e0a0aed4ec 98 CLKMAN_CRYPTO_CLK_AES = 17, /** AES engine clock */
<> 150:02e0a0aed4ec 99 CLKMAN_CRYPTO_CLK_MAA = 18, /** Modular Arithmetic Accelerator (MAA) clock */
<> 150:02e0a0aed4ec 100 CLKMAN_CRYPTO_CLK_PRNG = 19, /** Pseudo-random number Generator (PRNG) clock */
<> 150:02e0a0aed4ec 101 CLKMAN_CLK_MAX = 19
<> 150:02e0a0aed4ec 102 } clkman_clk_t;
<> 150:02e0a0aed4ec 103
<> 150:02e0a0aed4ec 104 /**
<> 150:02e0a0aed4ec 105 * @brief Selects a clock to enable/disable
<> 150:02e0a0aed4ec 106 */
<> 150:02e0a0aed4ec 107 typedef enum {
<> 150:02e0a0aed4ec 108 CLKMAN_USB_CLOCK = MXC_F_CLKMAN_CLK_CTRL_USB_CLOCK_ENABLE,
<> 150:02e0a0aed4ec 109 CLKMAN_CRYPTO_CLOCK = MXC_F_CLKMAN_CLK_CTRL_CRYPTO_CLOCK_ENABLE,
<> 150:02e0a0aed4ec 110 CLKMAN_ADC_CLOCK = MXC_F_CLKMAN_CLK_CTRL_ADC_CLOCK_ENABLE,
<> 150:02e0a0aed4ec 111 CLKMAN_WDT0_CLOCK = MXC_F_CLKMAN_CLK_CTRL_WDT0_CLOCK_ENABLE,
<> 150:02e0a0aed4ec 112 CLKMAN_WDT1_CLOCK = MXC_F_CLKMAN_CLK_CTRL_WDT1_CLOCK_ENABLE,
<> 150:02e0a0aed4ec 113 CLKMAN_RTOS_MODE = MXC_F_CLKMAN_CLK_CTRL_RTOS_MODE,
<> 150:02e0a0aed4ec 114 } clkman_enable_clk_t;
<> 150:02e0a0aed4ec 115
<> 150:02e0a0aed4ec 116 /**
<> 150:02e0a0aed4ec 117 * @brief Defines clock scales for various clocks.
<> 150:02e0a0aed4ec 118 */
<> 150:02e0a0aed4ec 119 typedef enum {
<> 150:02e0a0aed4ec 120 CLKMAN_SCALE_DISABLED = MXC_V_CLKMAN_CLK_SCALE_DISABLED, /** Clock disabled */
<> 150:02e0a0aed4ec 121 CLKMAN_SCALE_DIV_1 = MXC_V_CLKMAN_CLK_SCALE_DIV_1, /** Clock scale for dividing by 1 */
<> 150:02e0a0aed4ec 122 CLKMAN_SCALE_DIV_2 = MXC_V_CLKMAN_CLK_SCALE_DIV_2, /** Clock scale for dividing by 2 */
<> 150:02e0a0aed4ec 123 CLKMAN_SCALE_DIV_4 = MXC_V_CLKMAN_CLK_SCALE_DIV_4, /** Clock scale for dividing by 4 */
<> 150:02e0a0aed4ec 124 CLKMAN_SCALE_DIV_8 = MXC_V_CLKMAN_CLK_SCALE_DIV_8, /** Clock scale for dividing by 8 */
<> 150:02e0a0aed4ec 125 CLKMAN_SCALE_DIV_16 = MXC_V_CLKMAN_CLK_SCALE_DIV_16, /** Clock scale for dividing by 16 */
<> 150:02e0a0aed4ec 126 CLKMAN_SCALE_DIV_32 = MXC_V_CLKMAN_CLK_SCALE_DIV_32, /** Clock scale for dividing by 32 */
<> 150:02e0a0aed4ec 127 CLKMAN_SCALE_DIV_64 = MXC_V_CLKMAN_CLK_SCALE_DIV_64, /** Clock scale for dividing by 64 */
<> 150:02e0a0aed4ec 128 CLKMAN_SCALE_DIV_128 = MXC_V_CLKMAN_CLK_SCALE_DIV_128, /** Clock scale for dividing by 128 */
<> 150:02e0a0aed4ec 129 CLKMAN_SCALE_DIV_256 = MXC_V_CLKMAN_CLK_SCALE_DIV_256, /** Clock scale for dividing by 256 */
<> 150:02e0a0aed4ec 130 CLKMAN_SCALE_AUTO /** Clock scale to auto select divider */
<> 150:02e0a0aed4ec 131 } clkman_scale_t;
<> 150:02e0a0aed4ec 132
<> 150:02e0a0aed4ec 133 /**
<> 150:02e0a0aed4ec 134 * @brief Defines clock selections for the watchdog timers.
<> 150:02e0a0aed4ec 135 */
<> 150:02e0a0aed4ec 136 typedef enum {
<> 150:02e0a0aed4ec 137 CLKMAN_WDT_SELECT_SCALED_SYS_CLK_CTRL = MXC_V_CLKMAN_WDT0_CLOCK_SELECT_SCALED_SYS_CLK_CTRL_4_WDT0,
<> 150:02e0a0aed4ec 138 CLKMAN_WDT_SELECT_32KHZ_RTC_OSCILLATOR = MXC_V_CLKMAN_WDT0_CLOCK_SELECT_32KHZ_RTC_OSCILLATOR,
<> 150:02e0a0aed4ec 139 CLKMAN_WDT_SELECT_96MHZ_OSCILLATOR = MXC_V_CLKMAN_WDT0_CLOCK_SELECT_96MHZ_OSCILLATOR,
<> 150:02e0a0aed4ec 140 CLKMAN_WDT_SELECT_NANO_RING_OSCILLATOR = MXC_V_CLKMAN_WDT0_CLOCK_SELECT_NANO_RING_OSCILLATOR,
<> 150:02e0a0aed4ec 141 CLKMAN_WDT_SELECT_DISABLED
<> 150:02e0a0aed4ec 142 } clkman_wdt_clk_select_t;
<> 150:02e0a0aed4ec 143
<> 150:02e0a0aed4ec 144
<> 150:02e0a0aed4ec 145 /***** Function Prototypes *****/
<> 150:02e0a0aed4ec 146
<> 150:02e0a0aed4ec 147 /**
<> 150:02e0a0aed4ec 148 * @brief Selects the system clock source.
<> 150:02e0a0aed4ec 149 * @note 4MHz System source can only be divided down by a maximum factor of 8.
<> 150:02e0a0aed4ec 150 * @param select System clock source.
<> 150:02e0a0aed4ec 151 * @param scale System clock scaler.
<> 150:02e0a0aed4ec 152 */
<> 150:02e0a0aed4ec 153 void CLKMAN_SetSystemClock(clkman_system_source_select_t select, clkman_system_scale_t scale);
<> 150:02e0a0aed4ec 154
<> 150:02e0a0aed4ec 155 /**
<> 150:02e0a0aed4ec 156 * @brief Enables/disables the Crypto/TPU relaxation oscillator
<> 150:02e0a0aed4ec 157 * @param enable enable (1) or disable (0)
<> 150:02e0a0aed4ec 158 */
<> 150:02e0a0aed4ec 159 void CLKMAN_CryptoClockEnable(int enable);
<> 150:02e0a0aed4ec 160
<> 150:02e0a0aed4ec 161 /**
<> 150:02e0a0aed4ec 162 * @brief Enables/Disables the specified clock.
<> 150:02e0a0aed4ec 163 * @param clk clock to enable/disable
<> 150:02e0a0aed4ec 164 * @param enable enable (1) or disable (0)
<> 150:02e0a0aed4ec 165 */
<> 150:02e0a0aed4ec 166 void CLKMAN_ClockGate(clkman_enable_clk_t clk, int enable);
<> 150:02e0a0aed4ec 167
<> 150:02e0a0aed4ec 168 /**
<> 150:02e0a0aed4ec 169 * @brief Sets the specified clock scaler value.
<> 150:02e0a0aed4ec 170 * @param clk clock to set scaler value for
<> 150:02e0a0aed4ec 171 * @param scale clock scaler value
<> 150:02e0a0aed4ec 172 */
<> 150:02e0a0aed4ec 173 void CLKMAN_SetClkScale(clkman_clk_t clk, clkman_scale_t scale);
<> 150:02e0a0aed4ec 174
<> 150:02e0a0aed4ec 175 /**
<> 150:02e0a0aed4ec 176 * @brief Get the specified clock scaler value
<> 150:02e0a0aed4ec 177 * @param clk clock to get the scaler value for
<> 150:02e0a0aed4ec 178 */
<> 150:02e0a0aed4ec 179 clkman_scale_t CLKMAN_GetClkScale(clkman_clk_t clk);
<> 150:02e0a0aed4ec 180
<> 150:02e0a0aed4ec 181 /**
<> 150:02e0a0aed4ec 182 * @brief Selects the clock source for the watchdog timer
<> 150:02e0a0aed4ec 183 * @param idx index of the watchdog timer
<> 150:02e0a0aed4ec 184 * @param select clock to select
<> 150:02e0a0aed4ec 185 * @returns E_NO_ERROR if successful
<> 150:02e0a0aed4ec 186 */
<> 150:02e0a0aed4ec 187 int CLKMAN_WdtClkSelect(unsigned int idx, clkman_wdt_clk_select_t select);
<> 150:02e0a0aed4ec 188
<> 150:02e0a0aed4ec 189 /**
<> 150:02e0a0aed4ec 190 * @brief Get the interrupt flags
<> 150:02e0a0aed4ec 191 * @returns mask mask of flags set
<> 150:02e0a0aed4ec 192 */
<> 150:02e0a0aed4ec 193 __STATIC_INLINE uint32_t CLKMAN_GetFlags(void)
<> 150:02e0a0aed4ec 194 {
<> 150:02e0a0aed4ec 195 return MXC_CLKMAN->intfl;
<> 150:02e0a0aed4ec 196 }
<> 150:02e0a0aed4ec 197
<> 150:02e0a0aed4ec 198 /**
<> 150:02e0a0aed4ec 199 * @brief Clear the specified interrupt flags
<> 150:02e0a0aed4ec 200 * @param mask mask of flags to clear
<> 150:02e0a0aed4ec 201 */
<> 150:02e0a0aed4ec 202 __STATIC_INLINE void CLKMAN_ClrFlags(uint32_t mask)
<> 150:02e0a0aed4ec 203 {
<> 150:02e0a0aed4ec 204 MXC_CLKMAN->intfl = mask;
<> 150:02e0a0aed4ec 205 }
<> 150:02e0a0aed4ec 206
<> 150:02e0a0aed4ec 207 /**
<> 150:02e0a0aed4ec 208 * @brief Enable the specified interrupt flags
<> 150:02e0a0aed4ec 209 * @param mask mask of flags to enable
<> 150:02e0a0aed4ec 210 */
<> 150:02e0a0aed4ec 211 __STATIC_INLINE void CLKMAN_EnableInt(uint32_t mask)
<> 150:02e0a0aed4ec 212 {
<> 150:02e0a0aed4ec 213 MXC_CLKMAN->inten |= mask;
<> 150:02e0a0aed4ec 214 }
<> 150:02e0a0aed4ec 215
<> 150:02e0a0aed4ec 216 /**
<> 150:02e0a0aed4ec 217 * @brief Disable the specified interrupt flags
<> 150:02e0a0aed4ec 218 * @param mask mask of flags to disable
<> 150:02e0a0aed4ec 219 */
<> 150:02e0a0aed4ec 220 __STATIC_INLINE void CLKMAN_DisableInt(uint32_t mask)
<> 150:02e0a0aed4ec 221 {
<> 150:02e0a0aed4ec 222 MXC_CLKMAN->inten &= ~mask;
<> 150:02e0a0aed4ec 223 }
<> 150:02e0a0aed4ec 224
<> 150:02e0a0aed4ec 225 /**
<> 150:02e0a0aed4ec 226 * @brief Trim the ring oscillator.
<> 150:02e0a0aed4ec 227 */
<> 150:02e0a0aed4ec 228 void CLKMAN_TrimRO(void);
<> 150:02e0a0aed4ec 229
<> 150:02e0a0aed4ec 230 #ifdef __cplusplus
<> 150:02e0a0aed4ec 231 }
<> 150:02e0a0aed4ec 232 #endif
<> 150:02e0a0aed4ec 233
<> 150:02e0a0aed4ec 234 #endif /* _CLKMAN_H_ */