mbed library sources. Supersedes mbed-src. Edited target satm32f446 for user USART3 pins

Dependents:   IGLOO_board

Fork of mbed-dev by mbed official

Committer:
ua1arn
Date:
Mon Jul 30 12:31:10 2018 +0000
Revision:
188:3f10722804f9
Parent:
186:707f6e361f3e
before add multi-configuration USB descriptors

Who changed what in which revision?

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