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-06-03 14:21:38 -0500 (Fri, 03 Jun 2016) $
AnnaBridge 167:84c0a372a020 33 * $Revision: 23194 $
AnnaBridge 167:84c0a372a020 34 *
AnnaBridge 167:84c0a372a020 35 ******************************************************************************/
AnnaBridge 167:84c0a372a020 36
AnnaBridge 167:84c0a372a020 37 /**
AnnaBridge 167:84c0a372a020 38 * @file mxc_sys.h
AnnaBridge 167:84c0a372a020 39 * @brief System level header file.
AnnaBridge 167:84c0a372a020 40 */
AnnaBridge 167:84c0a372a020 41
AnnaBridge 167:84c0a372a020 42 #ifndef _MXC_SYS_H_
AnnaBridge 167:84c0a372a020 43 #define _MXC_SYS_H_
AnnaBridge 167:84c0a372a020 44
AnnaBridge 167:84c0a372a020 45 #include "mxc_config.h"
AnnaBridge 167:84c0a372a020 46 #include "clkman.h"
AnnaBridge 167:84c0a372a020 47 #include "ioman.h"
AnnaBridge 167:84c0a372a020 48 #include "gpio.h"
AnnaBridge 167:84c0a372a020 49 #include "i2cm_regs.h"
AnnaBridge 167:84c0a372a020 50 #include "i2cs_regs.h"
AnnaBridge 167:84c0a372a020 51 #include "tmr_regs.h"
AnnaBridge 167:84c0a372a020 52 #include "pt_regs.h"
AnnaBridge 167:84c0a372a020 53 #include "wdt_regs.h"
AnnaBridge 167:84c0a372a020 54 #include "owm_regs.h"
AnnaBridge 167:84c0a372a020 55
AnnaBridge 167:84c0a372a020 56 #ifdef __cplusplus
AnnaBridge 167:84c0a372a020 57 extern "C" {
AnnaBridge 167:84c0a372a020 58 #endif
AnnaBridge 167:84c0a372a020 59
AnnaBridge 167:84c0a372a020 60 /***** Definitions *****/
AnnaBridge 167:84c0a372a020 61
AnnaBridge 167:84c0a372a020 62 /** @brief System Configuration Object */
AnnaBridge 167:84c0a372a020 63 typedef struct {
AnnaBridge 167:84c0a372a020 64 clkman_scale_t clk_scale; /** desired clock scale value for the peripheral */
AnnaBridge 167:84c0a372a020 65 ioman_cfg_t io_cfg; /** IOMAN configuration object */
AnnaBridge 167:84c0a372a020 66 } sys_cfg_t;
AnnaBridge 167:84c0a372a020 67
AnnaBridge 167:84c0a372a020 68 /** @brief Watchdog System Configuration Object */
AnnaBridge 167:84c0a372a020 69 typedef struct {
AnnaBridge 167:84c0a372a020 70 clkman_wdt_clk_select_t clk; /** select the clock source for the watchdog */
AnnaBridge 167:84c0a372a020 71 clkman_scale_t clk_scale; /** desired clock scale value for the peripheral */
AnnaBridge 167:84c0a372a020 72 /** clk_scale is only applied if the system clock is used as the clk */
AnnaBridge 167:84c0a372a020 73 } sys_cfg_wdt_t;
AnnaBridge 167:84c0a372a020 74
AnnaBridge 167:84c0a372a020 75 /** @brief UART System Configuration Object */
AnnaBridge 167:84c0a372a020 76 typedef sys_cfg_t sys_cfg_uart_t;
AnnaBridge 167:84c0a372a020 77
AnnaBridge 167:84c0a372a020 78 /** @brief I2CM System Configuration Object */
AnnaBridge 167:84c0a372a020 79 typedef sys_cfg_t sys_cfg_i2cm_t;
AnnaBridge 167:84c0a372a020 80
AnnaBridge 167:84c0a372a020 81 /** @brief I2CS System Configuration Object */
AnnaBridge 167:84c0a372a020 82 typedef sys_cfg_t sys_cfg_i2cs_t;
AnnaBridge 167:84c0a372a020 83
AnnaBridge 167:84c0a372a020 84 /** @brief SPIM System Configuration Object */
AnnaBridge 167:84c0a372a020 85 typedef sys_cfg_t sys_cfg_spim_t;
AnnaBridge 167:84c0a372a020 86
AnnaBridge 167:84c0a372a020 87 /** @brief SPIX System Configuration Object */
AnnaBridge 167:84c0a372a020 88 typedef sys_cfg_t sys_cfg_spix_t;
AnnaBridge 167:84c0a372a020 89
AnnaBridge 167:84c0a372a020 90 /** @brief SPIS System Configuration Object */
AnnaBridge 167:84c0a372a020 91 typedef sys_cfg_t sys_cfg_spis_t;
AnnaBridge 167:84c0a372a020 92
AnnaBridge 167:84c0a372a020 93 /** @brief OWM System Configuration Object */
AnnaBridge 167:84c0a372a020 94 typedef sys_cfg_t sys_cfg_owm_t;
AnnaBridge 167:84c0a372a020 95
AnnaBridge 167:84c0a372a020 96 /** @brief Timer System Configuration Object */
AnnaBridge 167:84c0a372a020 97 typedef gpio_cfg_t sys_cfg_tmr_t;
AnnaBridge 167:84c0a372a020 98
AnnaBridge 167:84c0a372a020 99 /** @brief Pulse Train System Configuration Object */
AnnaBridge 167:84c0a372a020 100 typedef gpio_cfg_t sys_cfg_pt_t;
AnnaBridge 167:84c0a372a020 101 typedef clkman_scale_t sys_pt_clk_scale;
AnnaBridge 167:84c0a372a020 102
AnnaBridge 167:84c0a372a020 103 /***** Include Files *****/
AnnaBridge 167:84c0a372a020 104 /* These includes require the above types to be defined first */
AnnaBridge 167:84c0a372a020 105 #include "uart.h"
AnnaBridge 167:84c0a372a020 106 #include "spim.h"
AnnaBridge 167:84c0a372a020 107
AnnaBridge 167:84c0a372a020 108 /***** Function Prototypes *****/
AnnaBridge 167:84c0a372a020 109
AnnaBridge 167:84c0a372a020 110 /**
AnnaBridge 167:84c0a372a020 111 * @brief Get the frequency of a clock scaler
AnnaBridge 167:84c0a372a020 112 * @param clk_scale value of clk_scale field from clk_ctrl register
AnnaBridge 167:84c0a372a020 113 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 114 */
AnnaBridge 167:84c0a372a020 115 uint32_t SYS_GetFreq(uint32_t clk_scale);
AnnaBridge 167:84c0a372a020 116
AnnaBridge 167:84c0a372a020 117 /**
AnnaBridge 167:84c0a372a020 118 * @brief Get the frequency of the CPU
AnnaBridge 167:84c0a372a020 119 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 120 */
AnnaBridge 167:84c0a372a020 121 uint32_t SYS_CPU_GetFreq(void);
AnnaBridge 167:84c0a372a020 122
AnnaBridge 167:84c0a372a020 123 /**
AnnaBridge 167:84c0a372a020 124 * @brief System level initialization for ADC module.
AnnaBridge 167:84c0a372a020 125 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 126 */
AnnaBridge 167:84c0a372a020 127 int SYS_ADC_Init(void);
AnnaBridge 167:84c0a372a020 128
AnnaBridge 167:84c0a372a020 129 /**
AnnaBridge 167:84c0a372a020 130 * @brief System level initialization for AES module.
AnnaBridge 167:84c0a372a020 131 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 132 */
AnnaBridge 167:84c0a372a020 133 int SYS_AES_Init(void);
AnnaBridge 167:84c0a372a020 134
AnnaBridge 167:84c0a372a020 135 /**
AnnaBridge 167:84c0a372a020 136 * @brief System level initialization for GPIO module.
AnnaBridge 167:84c0a372a020 137 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 138 */
AnnaBridge 167:84c0a372a020 139 int SYS_GPIO_Init(void);
AnnaBridge 167:84c0a372a020 140
AnnaBridge 167:84c0a372a020 141 /**
AnnaBridge 167:84c0a372a020 142 * @brief System level initialization for UART module.
AnnaBridge 167:84c0a372a020 143 * @param uart Pointer to UART module registers
AnnaBridge 167:84c0a372a020 144 * @param uart_cfg UART configuration object
AnnaBridge 167:84c0a372a020 145 * @param sys_cfg System configuration object
AnnaBridge 167:84c0a372a020 146 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 147 */
AnnaBridge 167:84c0a372a020 148 int SYS_UART_Init(mxc_uart_regs_t *uart, const uart_cfg_t *uart_cfg, const sys_cfg_uart_t *sys_cfg);
AnnaBridge 167:84c0a372a020 149
AnnaBridge 167:84c0a372a020 150 /**
AnnaBridge 167:84c0a372a020 151 * @brief System level shutdown for UART module
AnnaBridge 167:84c0a372a020 152 * @param uart Pointer to UART module registers
AnnaBridge 167:84c0a372a020 153 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 154 */
AnnaBridge 167:84c0a372a020 155 int SYS_UART_Shutdown(mxc_uart_regs_t *uart);
AnnaBridge 167:84c0a372a020 156
AnnaBridge 167:84c0a372a020 157 /**
AnnaBridge 167:84c0a372a020 158 * @brief Get the frequency of the UART module source clock
AnnaBridge 167:84c0a372a020 159 * @param uart Pointer to UART module registers
AnnaBridge 167:84c0a372a020 160 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 161 */
AnnaBridge 167:84c0a372a020 162 uint32_t SYS_UART_GetFreq(mxc_uart_regs_t *uart);
AnnaBridge 167:84c0a372a020 163
AnnaBridge 167:84c0a372a020 164 /**
AnnaBridge 167:84c0a372a020 165 * @brief System level initialization for I2CM module.
AnnaBridge 167:84c0a372a020 166 * @param i2cm Pointer to I2CM module registers
AnnaBridge 167:84c0a372a020 167 * @param cfg System configuration object
AnnaBridge 167:84c0a372a020 168 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 169 */
AnnaBridge 167:84c0a372a020 170 int SYS_I2CM_Init(mxc_i2cm_regs_t *i2cm, const sys_cfg_i2cm_t *cfg);
AnnaBridge 167:84c0a372a020 171
AnnaBridge 167:84c0a372a020 172 /**
AnnaBridge 167:84c0a372a020 173 * @brief System level shutdown for I2CM module
AnnaBridge 167:84c0a372a020 174 * @param i2cm Pointer to I2CM module registers
AnnaBridge 167:84c0a372a020 175 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 176 */
AnnaBridge 167:84c0a372a020 177 int SYS_I2CM_Shutdown(mxc_i2cm_regs_t *i2cm);
AnnaBridge 167:84c0a372a020 178
AnnaBridge 167:84c0a372a020 179 /**
AnnaBridge 167:84c0a372a020 180 * @brief Get the frequency of the I2CM module source clock
AnnaBridge 167:84c0a372a020 181 * @param i2cm Pointer to I2CM module registers
AnnaBridge 167:84c0a372a020 182 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 183 */
AnnaBridge 167:84c0a372a020 184 uint32_t SYS_I2CM_GetFreq(mxc_i2cm_regs_t *i2cm);
AnnaBridge 167:84c0a372a020 185
AnnaBridge 167:84c0a372a020 186 /**
AnnaBridge 167:84c0a372a020 187 * @brief System level initialization for I2CS module.
AnnaBridge 167:84c0a372a020 188 * @param i2cs Pointer to I2CS module registers
AnnaBridge 167:84c0a372a020 189 * @param cfg System configuration object
AnnaBridge 167:84c0a372a020 190 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 191 */
AnnaBridge 167:84c0a372a020 192 int SYS_I2CS_Init(mxc_i2cs_regs_t *i2cs, const sys_cfg_i2cs_t *cfg);
AnnaBridge 167:84c0a372a020 193
AnnaBridge 167:84c0a372a020 194 /**
AnnaBridge 167:84c0a372a020 195 * @brief System level shutdown for I2CS module
AnnaBridge 167:84c0a372a020 196 * @param i2cs Pointer to I2CS module registers
AnnaBridge 167:84c0a372a020 197 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 198 */
AnnaBridge 167:84c0a372a020 199 int SYS_I2CS_Shutdown(mxc_i2cs_regs_t *i2cs);
AnnaBridge 167:84c0a372a020 200
AnnaBridge 167:84c0a372a020 201 /**
AnnaBridge 167:84c0a372a020 202 * @brief Get the frequency of the I2CS module source clock
AnnaBridge 167:84c0a372a020 203 * @param i2cs Pointer to I2CS module registers
AnnaBridge 167:84c0a372a020 204 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 205 */
AnnaBridge 167:84c0a372a020 206 uint32_t SYS_I2CS_GetFreq(mxc_i2cs_regs_t *i2cs);
AnnaBridge 167:84c0a372a020 207
AnnaBridge 167:84c0a372a020 208 /**
AnnaBridge 167:84c0a372a020 209 * @brief System level initialization for SPIM module.
AnnaBridge 167:84c0a372a020 210 * @param spim Pointer to SPIM module registers
AnnaBridge 167:84c0a372a020 211 * @param spim_cfg SPIM configuration object
AnnaBridge 167:84c0a372a020 212 * @param sys_cfg System configuration object
AnnaBridge 167:84c0a372a020 213 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 214 */
AnnaBridge 167:84c0a372a020 215 int SYS_SPIM_Init(mxc_spim_regs_t *spim, const spim_cfg_t *spim_cfg, const sys_cfg_spim_t *sys_cfg);
AnnaBridge 167:84c0a372a020 216
AnnaBridge 167:84c0a372a020 217 /**
AnnaBridge 167:84c0a372a020 218 * @brief System level shutdown for SPIM module
AnnaBridge 167:84c0a372a020 219 * @param spim Pointer to SPIM module registers
AnnaBridge 167:84c0a372a020 220 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 221 */
AnnaBridge 167:84c0a372a020 222 int SYS_SPIM_Shutdown(mxc_spim_regs_t *spim);
AnnaBridge 167:84c0a372a020 223
AnnaBridge 167:84c0a372a020 224 /**
AnnaBridge 167:84c0a372a020 225 * @brief Get the frequency of the SPIM module source clock
AnnaBridge 167:84c0a372a020 226 * @param spim Pointer to SPIM module registers
AnnaBridge 167:84c0a372a020 227 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 228 */
AnnaBridge 167:84c0a372a020 229 uint32_t SYS_SPIM_GetFreq(mxc_spim_regs_t *spim);
AnnaBridge 167:84c0a372a020 230
AnnaBridge 167:84c0a372a020 231 /**
AnnaBridge 167:84c0a372a020 232 * @brief System level initialization for SPIX module.
AnnaBridge 167:84c0a372a020 233 * @param sys_cfg System configuration object
AnnaBridge 167:84c0a372a020 234 * @param baud Baud rate for clock divider configuration
AnnaBridge 167:84c0a372a020 235 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 236 */
AnnaBridge 167:84c0a372a020 237 int SYS_SPIX_Init(const sys_cfg_spix_t *sys_cfg, uint32_t baud);
AnnaBridge 167:84c0a372a020 238
AnnaBridge 167:84c0a372a020 239 /**
AnnaBridge 167:84c0a372a020 240 * @brief System level shutdown for SPIX module
AnnaBridge 167:84c0a372a020 241 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 242 */
AnnaBridge 167:84c0a372a020 243 int SYS_SPIX_Shutdown(void);
AnnaBridge 167:84c0a372a020 244
AnnaBridge 167:84c0a372a020 245 /**
AnnaBridge 167:84c0a372a020 246 * @brief Get the frequency of the SPIX module source clock
AnnaBridge 167:84c0a372a020 247 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 248 */
AnnaBridge 167:84c0a372a020 249 uint32_t SYS_SPIX_GetFreq(void);
AnnaBridge 167:84c0a372a020 250
AnnaBridge 167:84c0a372a020 251 /**
AnnaBridge 167:84c0a372a020 252 * @brief System level initialization for SPIS module.
AnnaBridge 167:84c0a372a020 253 * @param sys_cfg System configuration object.
AnnaBridge 167:84c0a372a020 254 * @returns E_NO_ERROR if everything is successful.
AnnaBridge 167:84c0a372a020 255 */
AnnaBridge 167:84c0a372a020 256 int SYS_SPIS_Init(const sys_cfg_spix_t *sys_cfg);
AnnaBridge 167:84c0a372a020 257
AnnaBridge 167:84c0a372a020 258 /**
AnnaBridge 167:84c0a372a020 259 * @brief System level shutdown for SPIS module
AnnaBridge 167:84c0a372a020 260 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 261 */
AnnaBridge 167:84c0a372a020 262 int SYS_SPIS_Shutdown(void);
AnnaBridge 167:84c0a372a020 263
AnnaBridge 167:84c0a372a020 264 /**
AnnaBridge 167:84c0a372a020 265 * @brief Get the frequency of the SPIS module source clock
AnnaBridge 167:84c0a372a020 266 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 267 */
AnnaBridge 167:84c0a372a020 268 uint32_t SYS_SPIS_GetFreq(void);
AnnaBridge 167:84c0a372a020 269
AnnaBridge 167:84c0a372a020 270 /**
AnnaBridge 167:84c0a372a020 271 * @brief System level initialization for OWM module.
AnnaBridge 167:84c0a372a020 272 * @param owm Pointer to OWM module registers
AnnaBridge 167:84c0a372a020 273 * @param owm_cfg OWM configuration object
AnnaBridge 167:84c0a372a020 274 * @param sys_cfg System configuration object
AnnaBridge 167:84c0a372a020 275 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 276 */
AnnaBridge 167:84c0a372a020 277 int SYS_OWM_Init(mxc_owm_regs_t *owm, const sys_cfg_owm_t *sys_cfg);
AnnaBridge 167:84c0a372a020 278
AnnaBridge 167:84c0a372a020 279 /**
AnnaBridge 167:84c0a372a020 280 * @brief System level shutdown for OWM module
AnnaBridge 167:84c0a372a020 281 * @param owm Pointer to OWM module registers
AnnaBridge 167:84c0a372a020 282 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 283 */
AnnaBridge 167:84c0a372a020 284 int SYS_OWM_Shutdown(mxc_owm_regs_t *owm);
AnnaBridge 167:84c0a372a020 285
AnnaBridge 167:84c0a372a020 286 /**
AnnaBridge 167:84c0a372a020 287 * @brief Get the frequency of the OWM module source clock
AnnaBridge 167:84c0a372a020 288 * @param owm Pointer to OWM module registers
AnnaBridge 167:84c0a372a020 289 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 290 */
AnnaBridge 167:84c0a372a020 291 uint32_t SYS_OWM_GetFreq(mxc_owm_regs_t *owm);
AnnaBridge 167:84c0a372a020 292
AnnaBridge 167:84c0a372a020 293 /**
AnnaBridge 167:84c0a372a020 294 * @brief System level initialization for TMR module.
AnnaBridge 167:84c0a372a020 295 * @param tmr Pointer to TMR module registers
AnnaBridge 167:84c0a372a020 296 * @param cfg System configuration object
AnnaBridge 167:84c0a372a020 297 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 298 */
AnnaBridge 167:84c0a372a020 299 int SYS_TMR_Init(mxc_tmr_regs_t *tmr, const sys_cfg_tmr_t *cfg);
AnnaBridge 167:84c0a372a020 300
AnnaBridge 167:84c0a372a020 301 /**
AnnaBridge 167:84c0a372a020 302 * @brief Get the frequency of the TMR module source clock
AnnaBridge 167:84c0a372a020 303 * @param spim Pointer to TMR module registers
AnnaBridge 167:84c0a372a020 304 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 305 */
AnnaBridge 167:84c0a372a020 306 uint32_t SYS_TMR_GetFreq(mxc_tmr_regs_t *tmr);
AnnaBridge 167:84c0a372a020 307
AnnaBridge 167:84c0a372a020 308 /**
AnnaBridge 167:84c0a372a020 309 * @brief Get the frequency of the Pulse Train module source clock
AnnaBridge 167:84c0a372a020 310 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 311 */
AnnaBridge 167:84c0a372a020 312 uint32_t SYS_PT_GetFreq(void);
AnnaBridge 167:84c0a372a020 313
AnnaBridge 167:84c0a372a020 314 /**
AnnaBridge 167:84c0a372a020 315 * @brief Initialize the global pulse train clock scale
AnnaBridge 167:84c0a372a020 316 * @param clk_scale scale the system clock for the PT clock
AnnaBridge 167:84c0a372a020 317 */
AnnaBridge 167:84c0a372a020 318 void SYS_PT_Init(sys_pt_clk_scale clk_scale);
AnnaBridge 167:84c0a372a020 319
AnnaBridge 167:84c0a372a020 320 /**
AnnaBridge 167:84c0a372a020 321 * @brief System level initialization for Pulse Train module.
AnnaBridge 167:84c0a372a020 322 * @param pt Pointer to PT module registers
AnnaBridge 167:84c0a372a020 323 * @param cfg System configuration object
AnnaBridge 167:84c0a372a020 324 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 325 */
AnnaBridge 167:84c0a372a020 326 int SYS_PT_Config(mxc_pt_regs_t *pt, const sys_cfg_pt_t *cfg);
AnnaBridge 167:84c0a372a020 327
AnnaBridge 167:84c0a372a020 328 /**
AnnaBridge 167:84c0a372a020 329 * @brief System level initialization for USB device.
AnnaBridge 167:84c0a372a020 330 * @param enable 1 to enable the peripheral, 0 to disable.
AnnaBridge 167:84c0a372a020 331 */
AnnaBridge 167:84c0a372a020 332 void SYS_USB_Enable(uint8_t enable);
AnnaBridge 167:84c0a372a020 333
AnnaBridge 167:84c0a372a020 334 /**
AnnaBridge 167:84c0a372a020 335 * @brief System Tick Configuration Helper
AnnaBridge 167:84c0a372a020 336 *
AnnaBridge 167:84c0a372a020 337 * The function enables selection of the external clock source for the
AnnaBridge 167:84c0a372a020 338 * System Tick Timer. It initializes the System Timer and its interrupt,
AnnaBridge 167:84c0a372a020 339 * and starts the System Tick Timer. Counter is in free running mode to generate
AnnaBridge 167:84c0a372a020 340 * periodic interrupts.
AnnaBridge 167:84c0a372a020 341
AnnaBridge 167:84c0a372a020 342 * @param ticks Number of ticks between two interrupts.
AnnaBridge 167:84c0a372a020 343 * @param clk_src Selects between default SystemClock or External Clock.
AnnaBridge 167:84c0a372a020 344 * - 0 Use external clock source
AnnaBridge 167:84c0a372a020 345 * - 1 SystemClock
AnnaBridge 167:84c0a372a020 346 * @return E_NO_ERROR Function succeeded.
AnnaBridge 167:84c0a372a020 347 * @return E_INVALID Invalid reload value requested.
AnnaBridge 167:84c0a372a020 348 *
AnnaBridge 167:84c0a372a020 349 * @see CLKMAN_SetRTOSMode(uint8_t enable) if using the external clock source to drive the System Tick Timer
AnnaBridge 167:84c0a372a020 350 *
AnnaBridge 167:84c0a372a020 351 */
AnnaBridge 167:84c0a372a020 352 int SYS_SysTick_Config(uint32_t ticks, int clk_src);
AnnaBridge 167:84c0a372a020 353
AnnaBridge 167:84c0a372a020 354 /**
AnnaBridge 167:84c0a372a020 355 * @brief Disable System Tick timer
AnnaBridge 167:84c0a372a020 356 *
AnnaBridge 167:84c0a372a020 357 *
AnnaBridge 167:84c0a372a020 358 */
AnnaBridge 167:84c0a372a020 359 __STATIC_INLINE void SYS_SysTick_Disable(void)
AnnaBridge 167:84c0a372a020 360 {
AnnaBridge 167:84c0a372a020 361 SysTick->CTRL = 0;
AnnaBridge 167:84c0a372a020 362 }
AnnaBridge 167:84c0a372a020 363
AnnaBridge 167:84c0a372a020 364 /**
AnnaBridge 167:84c0a372a020 365 * @brief Delay a requested number of SysTick Timer Ticks.
AnnaBridge 167:84c0a372a020 366 * @param ticks Number of System Ticks to delay.
AnnaBridge 167:84c0a372a020 367 * @note This delay function is based on the clock used for the SysTick timer
AnnaBridge 167:84c0a372a020 368 * if the SysTick timer is enabled. If the SysTick timer is
AnnaBridge 167:84c0a372a020 369 * not enabled, the current SysTick registers are saved and the
AnnaBridge 167:84c0a372a020 370 * timer will use the SystemClock as the source for the delay.
AnnaBridge 167:84c0a372a020 371 * The delay is measured in clock ticks and is not based on the
AnnaBridge 167:84c0a372a020 372 * SysTick interval.
AnnaBridge 167:84c0a372a020 373 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 374 */
AnnaBridge 167:84c0a372a020 375 int SYS_SysTick_Delay(uint32_t ticks);
AnnaBridge 167:84c0a372a020 376
AnnaBridge 167:84c0a372a020 377 /**
AnnaBridge 167:84c0a372a020 378 * @brief Get the frequency of the SysTick Timer
AnnaBridge 167:84c0a372a020 379 * @returns frequency in Hz
AnnaBridge 167:84c0a372a020 380 */
AnnaBridge 167:84c0a372a020 381 uint32_t SYS_SysTick_GetFreq(void);
AnnaBridge 167:84c0a372a020 382
AnnaBridge 167:84c0a372a020 383 /**
AnnaBridge 167:84c0a372a020 384 * @brief Delay a requested number of microseconds.
AnnaBridge 167:84c0a372a020 385 * @param us Number of microseconds to delay.
AnnaBridge 167:84c0a372a020 386 * @note Calls SYS_SysTick_Delay.
AnnaBridge 167:84c0a372a020 387 */
AnnaBridge 167:84c0a372a020 388 __STATIC_INLINE void SYS_SysTick_DelayUs(uint32_t us)
AnnaBridge 167:84c0a372a020 389 {
AnnaBridge 167:84c0a372a020 390 SYS_SysTick_Delay((uint32_t)(((uint64_t)SYS_SysTick_GetFreq() * us) / 1000000));
AnnaBridge 167:84c0a372a020 391 }
AnnaBridge 167:84c0a372a020 392
AnnaBridge 167:84c0a372a020 393 /**
AnnaBridge 167:84c0a372a020 394 * @brief System level initialization for RTC module.
AnnaBridge 167:84c0a372a020 395 * @returns E_NO_ERROR if everything is successful
AnnaBridge 167:84c0a372a020 396 */
AnnaBridge 167:84c0a372a020 397 int SYS_RTC_Init(void);
AnnaBridge 167:84c0a372a020 398
AnnaBridge 167:84c0a372a020 399 /**
AnnaBridge 167:84c0a372a020 400 * @brief Select VDDIO for the specified GPIO pin.
AnnaBridge 167:84c0a372a020 401 */
AnnaBridge 167:84c0a372a020 402 void SYS_IOMAN_UseVDDIO(const gpio_cfg_t *cfg);
AnnaBridge 167:84c0a372a020 403
AnnaBridge 167:84c0a372a020 404 /**
AnnaBridge 167:84c0a372a020 405 * @brief Select VDDIOH for the specified GPIO pin.
AnnaBridge 167:84c0a372a020 406 */
AnnaBridge 167:84c0a372a020 407 void SYS_IOMAN_UseVDDIOH(const gpio_cfg_t *cfg);
AnnaBridge 167:84c0a372a020 408
AnnaBridge 167:84c0a372a020 409 /**
AnnaBridge 167:84c0a372a020 410 * @brief System level initialization for Watchdog module.
AnnaBridge 167:84c0a372a020 411 * @param wdt Pointer to Watchdog module registers
AnnaBridge 167:84c0a372a020 412 * @param cfg Watchdog System configuration object
AnnaBridge 167:84c0a372a020 413 */
AnnaBridge 167:84c0a372a020 414 void SYS_WDT_Init(mxc_wdt_regs_t *wdt, const sys_cfg_wdt_t *cfg);
AnnaBridge 167:84c0a372a020 415
AnnaBridge 167:84c0a372a020 416 /**
AnnaBridge 167:84c0a372a020 417 * @brief System level initialization for PRNG module.
AnnaBridge 167:84c0a372a020 418 * Enable crypto clock and set divisors to 1 if disabled
AnnaBridge 167:84c0a372a020 419 */
AnnaBridge 167:84c0a372a020 420 void SYS_PRNG_Init(void);
AnnaBridge 167:84c0a372a020 421
AnnaBridge 167:84c0a372a020 422 /**
AnnaBridge 167:84c0a372a020 423 * @brief System level initialization for MAA module.
AnnaBridge 167:84c0a372a020 424 * Enable crypto clock and set divisors to 1 if disabled
AnnaBridge 167:84c0a372a020 425 */
AnnaBridge 167:84c0a372a020 426 void SYS_MAA_Init(void);
AnnaBridge 167:84c0a372a020 427
AnnaBridge 167:84c0a372a020 428 /*
AnnaBridge 167:84c0a372a020 429 * @brief Gets the size of the SRAM
AnnaBridge 167:84c0a372a020 430 * @returns size of SRAM in bytes
AnnaBridge 167:84c0a372a020 431 */
AnnaBridge 167:84c0a372a020 432 uint32_t SYS_SRAM_GetSize(void);
AnnaBridge 167:84c0a372a020 433
AnnaBridge 167:84c0a372a020 434 /*
AnnaBridge 167:84c0a372a020 435 * @brief Gets the size of the Flash
AnnaBridge 167:84c0a372a020 436 * @returns size of Flash in bytes
AnnaBridge 167:84c0a372a020 437 */
AnnaBridge 167:84c0a372a020 438 uint32_t SYS_FLASH_GetSize(void);
AnnaBridge 167:84c0a372a020 439
AnnaBridge 167:84c0a372a020 440 #ifdef __cplusplus
AnnaBridge 167:84c0a372a020 441 }
AnnaBridge 167:84c0a372a020 442 #endif
AnnaBridge 167:84c0a372a020 443
AnnaBridge 167:84c0a372a020 444 #endif /* _MXC_SYS_H_*/