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:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

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