Greg Steiert / pegasus_dev

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

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