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.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_MAX32625PICO_NO_BOOT/TARGET_Maxim/TARGET_MAX32625/mxc/clkman.h@169:a7c7b631e539
mbed library. Release version 164

Who changed what in which revision?

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