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.
TARGET_K64F/TOOLCHAIN_IAR/fsl_common.h@172:65be27845400, 2019-02-20 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 145:64910690c574 | 1 | /* |
AnnaBridge | 145:64910690c574 | 2 | * Copyright (c) 2015-2016, Freescale Semiconductor, Inc. |
AnnaBridge | 145:64910690c574 | 3 | * All rights reserved. |
AnnaBridge | 145:64910690c574 | 4 | * |
AnnaBridge | 145:64910690c574 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 145:64910690c574 | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 145:64910690c574 | 7 | * |
AnnaBridge | 145:64910690c574 | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 145:64910690c574 | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 145:64910690c574 | 10 | * |
AnnaBridge | 145:64910690c574 | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 145:64910690c574 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 145:64910690c574 | 13 | * other materials provided with the distribution. |
AnnaBridge | 145:64910690c574 | 14 | * |
AnnaBridge | 145:64910690c574 | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
AnnaBridge | 145:64910690c574 | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 145:64910690c574 | 17 | * software without specific prior written permission. |
AnnaBridge | 145:64910690c574 | 18 | * |
AnnaBridge | 145:64910690c574 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 145:64910690c574 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 145:64910690c574 | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 145:64910690c574 | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 145:64910690c574 | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 145:64910690c574 | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 145:64910690c574 | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 145:64910690c574 | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 145:64910690c574 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 145:64910690c574 | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 145:64910690c574 | 29 | */ |
AnnaBridge | 145:64910690c574 | 30 | |
AnnaBridge | 145:64910690c574 | 31 | #ifndef _FSL_COMMON_H_ |
AnnaBridge | 145:64910690c574 | 32 | #define _FSL_COMMON_H_ |
AnnaBridge | 145:64910690c574 | 33 | |
AnnaBridge | 145:64910690c574 | 34 | #include <assert.h> |
AnnaBridge | 145:64910690c574 | 35 | #include <stdbool.h> |
AnnaBridge | 145:64910690c574 | 36 | #include <stdint.h> |
AnnaBridge | 145:64910690c574 | 37 | #include <stddef.h> |
AnnaBridge | 145:64910690c574 | 38 | #include <string.h> |
AnnaBridge | 145:64910690c574 | 39 | #include "fsl_device_registers.h" |
AnnaBridge | 145:64910690c574 | 40 | |
AnnaBridge | 145:64910690c574 | 41 | /*! |
AnnaBridge | 145:64910690c574 | 42 | * @addtogroup ksdk_common |
AnnaBridge | 145:64910690c574 | 43 | * @{ |
AnnaBridge | 145:64910690c574 | 44 | */ |
AnnaBridge | 145:64910690c574 | 45 | |
AnnaBridge | 145:64910690c574 | 46 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 47 | * Definitions |
AnnaBridge | 145:64910690c574 | 48 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 49 | |
AnnaBridge | 145:64910690c574 | 50 | /*! @brief Construct a status code value from a group and code number. */ |
AnnaBridge | 145:64910690c574 | 51 | #define MAKE_STATUS(group, code) ((((group)*100) + (code))) |
AnnaBridge | 145:64910690c574 | 52 | |
AnnaBridge | 145:64910690c574 | 53 | /*! @brief Construct the version number for drivers. */ |
AnnaBridge | 145:64910690c574 | 54 | #define MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix)) |
AnnaBridge | 145:64910690c574 | 55 | |
AnnaBridge | 145:64910690c574 | 56 | /* Debug console type definition. */ |
AnnaBridge | 145:64910690c574 | 57 | #define DEBUG_CONSOLE_DEVICE_TYPE_NONE 0U /*!< No debug console. */ |
AnnaBridge | 145:64910690c574 | 58 | #define DEBUG_CONSOLE_DEVICE_TYPE_UART 1U /*!< Debug console base on UART. */ |
AnnaBridge | 145:64910690c574 | 59 | #define DEBUG_CONSOLE_DEVICE_TYPE_LPUART 2U /*!< Debug console base on LPUART. */ |
AnnaBridge | 145:64910690c574 | 60 | #define DEBUG_CONSOLE_DEVICE_TYPE_LPSCI 3U /*!< Debug console base on LPSCI. */ |
AnnaBridge | 145:64910690c574 | 61 | #define DEBUG_CONSOLE_DEVICE_TYPE_USBCDC 4U /*!< Debug console base on USBCDC. */ |
AnnaBridge | 145:64910690c574 | 62 | #define DEBUG_CONSOLE_DEVICE_TYPE_FLEXCOMM 5U /*!< Debug console base on USBCDC. */ |
AnnaBridge | 145:64910690c574 | 63 | |
AnnaBridge | 145:64910690c574 | 64 | /*! @brief Status group numbers. */ |
AnnaBridge | 145:64910690c574 | 65 | enum _status_groups |
AnnaBridge | 145:64910690c574 | 66 | { |
AnnaBridge | 145:64910690c574 | 67 | kStatusGroup_Generic = 0, /*!< Group number for generic status codes. */ |
AnnaBridge | 145:64910690c574 | 68 | kStatusGroup_FLASH = 1, /*!< Group number for FLASH status codes. */ |
AnnaBridge | 145:64910690c574 | 69 | kStatusGroup_LPSPI = 4, /*!< Group number for LPSPI status codes. */ |
AnnaBridge | 145:64910690c574 | 70 | kStatusGroup_FLEXIO_SPI = 5, /*!< Group number for FLEXIO SPI status codes. */ |
AnnaBridge | 145:64910690c574 | 71 | kStatusGroup_DSPI = 6, /*!< Group number for DSPI status codes. */ |
AnnaBridge | 145:64910690c574 | 72 | kStatusGroup_FLEXIO_UART = 7, /*!< Group number for FLEXIO UART status codes. */ |
AnnaBridge | 145:64910690c574 | 73 | kStatusGroup_FLEXIO_I2C = 8, /*!< Group number for FLEXIO I2C status codes. */ |
AnnaBridge | 145:64910690c574 | 74 | kStatusGroup_LPI2C = 9, /*!< Group number for LPI2C status codes. */ |
AnnaBridge | 145:64910690c574 | 75 | kStatusGroup_UART = 10, /*!< Group number for UART status codes. */ |
AnnaBridge | 145:64910690c574 | 76 | kStatusGroup_I2C = 11, /*!< Group number for UART status codes. */ |
AnnaBridge | 145:64910690c574 | 77 | kStatusGroup_LPSCI = 12, /*!< Group number for LPSCI status codes. */ |
AnnaBridge | 145:64910690c574 | 78 | kStatusGroup_LPUART = 13, /*!< Group number for LPUART status codes. */ |
AnnaBridge | 145:64910690c574 | 79 | kStatusGroup_SPI = 14, /*!< Group number for SPI status code.*/ |
AnnaBridge | 145:64910690c574 | 80 | kStatusGroup_XRDC = 15, /*!< Group number for XRDC status code.*/ |
AnnaBridge | 145:64910690c574 | 81 | kStatusGroup_SEMA42 = 16, /*!< Group number for SEMA42 status code.*/ |
AnnaBridge | 145:64910690c574 | 82 | kStatusGroup_SDHC = 17, /*!< Group number for SDHC status code */ |
AnnaBridge | 145:64910690c574 | 83 | kStatusGroup_SDMMC = 18, /*!< Group number for SDMMC status code */ |
AnnaBridge | 145:64910690c574 | 84 | kStatusGroup_SAI = 19, /*!< Group number for SAI status code */ |
AnnaBridge | 145:64910690c574 | 85 | kStatusGroup_MCG = 20, /*!< Group number for MCG status codes. */ |
AnnaBridge | 145:64910690c574 | 86 | kStatusGroup_SCG = 21, /*!< Group number for SCG status codes. */ |
AnnaBridge | 145:64910690c574 | 87 | kStatusGroup_SDSPI = 22, /*!< Group number for SDSPI status codes. */ |
AnnaBridge | 145:64910690c574 | 88 | kStatusGroup_FLEXIO_I2S = 23, /*!< Group number for FLEXIO I2S status codes */ |
AnnaBridge | 145:64910690c574 | 89 | kStatusGroup_FLASHIAP = 25, /*!< Group number for FLASHIAP status codes */ |
AnnaBridge | 145:64910690c574 | 90 | kStatusGroup_FLEXCOMM_I2C = 26, /*!< Group number for FLEXCOMM I2C status codes */ |
AnnaBridge | 145:64910690c574 | 91 | kStatusGroup_I2S = 27, /*!< Group number for I2S status codes */ |
AnnaBridge | 145:64910690c574 | 92 | kStatusGroup_SDRAMC = 35, /*!< Group number for SDRAMC status codes. */ |
AnnaBridge | 145:64910690c574 | 93 | kStatusGroup_POWER = 39, /*!< Group number for POWER status codes. */ |
AnnaBridge | 145:64910690c574 | 94 | kStatusGroup_ENET = 40, /*!< Group number for ENET status codes. */ |
AnnaBridge | 145:64910690c574 | 95 | kStatusGroup_PHY = 41, /*!< Group number for PHY status codes. */ |
AnnaBridge | 145:64910690c574 | 96 | kStatusGroup_TRGMUX = 42, /*!< Group number for TRGMUX status codes. */ |
AnnaBridge | 145:64910690c574 | 97 | kStatusGroup_SMARTCARD = 43, /*!< Group number for SMARTCARD status codes. */ |
AnnaBridge | 145:64910690c574 | 98 | kStatusGroup_LMEM = 44, /*!< Group number for LMEM status codes. */ |
AnnaBridge | 145:64910690c574 | 99 | kStatusGroup_QSPI = 45, /*!< Group number for QSPI status codes. */ |
AnnaBridge | 145:64910690c574 | 100 | kStatusGroup_DMA = 50, /*!< Group number for DMA status codes. */ |
AnnaBridge | 145:64910690c574 | 101 | kStatusGroup_EDMA = 51, /*!< Group number for EDMA status codes. */ |
AnnaBridge | 145:64910690c574 | 102 | kStatusGroup_DMAMGR = 52, /*!< Group number for DMAMGR status codes. */ |
AnnaBridge | 145:64910690c574 | 103 | kStatusGroup_FLEXCAN = 53, /*!< Group number for FlexCAN status codes. */ |
AnnaBridge | 145:64910690c574 | 104 | kStatusGroup_LTC = 54, /*!< Group number for LTC status codes. */ |
AnnaBridge | 145:64910690c574 | 105 | kStatusGroup_FLEXIO_CAMERA = 55, /*!< Group number for FLEXIO CAMERA status codes. */ |
AnnaBridge | 145:64910690c574 | 106 | kStatusGroup_LPC_SPI = 56, /*!< Group number for LPC_SPI status codes. */ |
AnnaBridge | 145:64910690c574 | 107 | kStatusGroup_LPC_USART = 57, /*!< Group number for LPC_USART status codes. */ |
AnnaBridge | 145:64910690c574 | 108 | kStatusGroup_NOTIFIER = 98, /*!< Group number for NOTIFIER status codes. */ |
AnnaBridge | 145:64910690c574 | 109 | kStatusGroup_DebugConsole = 99, /*!< Group number for debug console status codes. */ |
AnnaBridge | 145:64910690c574 | 110 | kStatusGroup_ApplicationRangeStart = 100, /*!< Starting number for application groups. */ |
AnnaBridge | 145:64910690c574 | 111 | }; |
AnnaBridge | 145:64910690c574 | 112 | |
AnnaBridge | 145:64910690c574 | 113 | /*! @brief Generic status return codes. */ |
AnnaBridge | 145:64910690c574 | 114 | enum _generic_status |
AnnaBridge | 145:64910690c574 | 115 | { |
AnnaBridge | 145:64910690c574 | 116 | kStatus_Success = MAKE_STATUS(kStatusGroup_Generic, 0), |
AnnaBridge | 145:64910690c574 | 117 | kStatus_Fail = MAKE_STATUS(kStatusGroup_Generic, 1), |
AnnaBridge | 145:64910690c574 | 118 | kStatus_ReadOnly = MAKE_STATUS(kStatusGroup_Generic, 2), |
AnnaBridge | 145:64910690c574 | 119 | kStatus_OutOfRange = MAKE_STATUS(kStatusGroup_Generic, 3), |
AnnaBridge | 145:64910690c574 | 120 | kStatus_InvalidArgument = MAKE_STATUS(kStatusGroup_Generic, 4), |
AnnaBridge | 145:64910690c574 | 121 | kStatus_Timeout = MAKE_STATUS(kStatusGroup_Generic, 5), |
AnnaBridge | 145:64910690c574 | 122 | kStatus_NoTransferInProgress = MAKE_STATUS(kStatusGroup_Generic, 6), |
AnnaBridge | 145:64910690c574 | 123 | }; |
AnnaBridge | 145:64910690c574 | 124 | |
AnnaBridge | 145:64910690c574 | 125 | /*! @brief Type used for all status and error return values. */ |
AnnaBridge | 145:64910690c574 | 126 | typedef int32_t status_t; |
AnnaBridge | 145:64910690c574 | 127 | |
AnnaBridge | 145:64910690c574 | 128 | /* |
AnnaBridge | 145:64910690c574 | 129 | * The fsl_clock.h is included here because it needs MAKE_VERSION/MAKE_STATUS/status_t |
AnnaBridge | 145:64910690c574 | 130 | * defined in previous of this file. |
AnnaBridge | 145:64910690c574 | 131 | */ |
AnnaBridge | 145:64910690c574 | 132 | #include "fsl_clock.h" |
AnnaBridge | 145:64910690c574 | 133 | |
AnnaBridge | 145:64910690c574 | 134 | /* |
AnnaBridge | 145:64910690c574 | 135 | * Chip level peripheral reset API, for MCUs that implement peripheral reset control external to a peripheral |
AnnaBridge | 145:64910690c574 | 136 | */ |
AnnaBridge | 145:64910690c574 | 137 | #if ((defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0)) || \ |
AnnaBridge | 145:64910690c574 | 138 | (defined(FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT) && (FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT > 0))) |
AnnaBridge | 145:64910690c574 | 139 | #include "fsl_reset.h" |
AnnaBridge | 145:64910690c574 | 140 | #endif |
AnnaBridge | 145:64910690c574 | 141 | |
AnnaBridge | 145:64910690c574 | 142 | /*! @name Min/max macros */ |
AnnaBridge | 145:64910690c574 | 143 | /* @{ */ |
AnnaBridge | 145:64910690c574 | 144 | #if !defined(MIN) |
AnnaBridge | 145:64910690c574 | 145 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) |
AnnaBridge | 145:64910690c574 | 146 | #endif |
AnnaBridge | 145:64910690c574 | 147 | |
AnnaBridge | 145:64910690c574 | 148 | #if !defined(MAX) |
AnnaBridge | 145:64910690c574 | 149 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) |
AnnaBridge | 145:64910690c574 | 150 | #endif |
AnnaBridge | 145:64910690c574 | 151 | /* @} */ |
AnnaBridge | 145:64910690c574 | 152 | |
AnnaBridge | 145:64910690c574 | 153 | /*! @brief Computes the number of elements in an array. */ |
AnnaBridge | 145:64910690c574 | 154 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
AnnaBridge | 145:64910690c574 | 155 | |
AnnaBridge | 145:64910690c574 | 156 | /*! @name UINT16_MAX/UINT32_MAX value */ |
AnnaBridge | 145:64910690c574 | 157 | /* @{ */ |
AnnaBridge | 145:64910690c574 | 158 | #if !defined(UINT16_MAX) |
AnnaBridge | 145:64910690c574 | 159 | #define UINT16_MAX ((uint16_t)-1) |
AnnaBridge | 145:64910690c574 | 160 | #endif |
AnnaBridge | 145:64910690c574 | 161 | |
AnnaBridge | 145:64910690c574 | 162 | #if !defined(UINT32_MAX) |
AnnaBridge | 145:64910690c574 | 163 | #define UINT32_MAX ((uint32_t)-1) |
AnnaBridge | 145:64910690c574 | 164 | #endif |
AnnaBridge | 145:64910690c574 | 165 | /* @} */ |
AnnaBridge | 145:64910690c574 | 166 | |
AnnaBridge | 145:64910690c574 | 167 | /*! @name Timer utilities */ |
AnnaBridge | 145:64910690c574 | 168 | /* @{ */ |
AnnaBridge | 145:64910690c574 | 169 | /*! Macro to convert a microsecond period to raw count value */ |
AnnaBridge | 145:64910690c574 | 170 | #define USEC_TO_COUNT(us, clockFreqInHz) (uint64_t)((uint64_t)us * clockFreqInHz / 1000000U) |
AnnaBridge | 145:64910690c574 | 171 | /*! Macro to convert a raw count value to microsecond */ |
AnnaBridge | 145:64910690c574 | 172 | #define COUNT_TO_USEC(count, clockFreqInHz) (uint64_t)((uint64_t)count * 1000000U / clockFreqInHz) |
AnnaBridge | 145:64910690c574 | 173 | |
AnnaBridge | 145:64910690c574 | 174 | /*! Macro to convert a millisecond period to raw count value */ |
AnnaBridge | 145:64910690c574 | 175 | #define MSEC_TO_COUNT(ms, clockFreqInHz) (uint64_t)((uint64_t)ms * clockFreqInHz / 1000U) |
AnnaBridge | 145:64910690c574 | 176 | /*! Macro to convert a raw count value to millisecond */ |
AnnaBridge | 145:64910690c574 | 177 | #define COUNT_TO_MSEC(count, clockFreqInHz) (uint64_t)((uint64_t)count * 1000U / clockFreqInHz) |
AnnaBridge | 145:64910690c574 | 178 | /* @} */ |
AnnaBridge | 145:64910690c574 | 179 | |
AnnaBridge | 145:64910690c574 | 180 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 181 | * API |
AnnaBridge | 145:64910690c574 | 182 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 183 | |
AnnaBridge | 145:64910690c574 | 184 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 185 | extern "C" { |
AnnaBridge | 145:64910690c574 | 186 | #endif |
AnnaBridge | 145:64910690c574 | 187 | |
AnnaBridge | 145:64910690c574 | 188 | /*! |
AnnaBridge | 145:64910690c574 | 189 | * @brief Enable specific interrupt. |
AnnaBridge | 145:64910690c574 | 190 | * |
AnnaBridge | 145:64910690c574 | 191 | * Enable the interrupt not routed from intmux. |
AnnaBridge | 145:64910690c574 | 192 | * |
AnnaBridge | 145:64910690c574 | 193 | * @param interrupt The IRQ number. |
AnnaBridge | 145:64910690c574 | 194 | */ |
AnnaBridge | 145:64910690c574 | 195 | static inline void EnableIRQ(IRQn_Type interrupt) |
AnnaBridge | 145:64910690c574 | 196 | { |
AnnaBridge | 145:64910690c574 | 197 | if (NotAvail_IRQn == interrupt) |
AnnaBridge | 145:64910690c574 | 198 | { |
AnnaBridge | 145:64910690c574 | 199 | return; |
AnnaBridge | 145:64910690c574 | 200 | } |
AnnaBridge | 145:64910690c574 | 201 | |
AnnaBridge | 145:64910690c574 | 202 | #if defined(FSL_FEATURE_SOC_INTMUX_COUNT) && (FSL_FEATURE_SOC_INTMUX_COUNT > 0) |
AnnaBridge | 145:64910690c574 | 203 | if (interrupt < FSL_FEATURE_INTMUX_IRQ_START_INDEX) |
AnnaBridge | 145:64910690c574 | 204 | #endif |
AnnaBridge | 145:64910690c574 | 205 | { |
AnnaBridge | 145:64910690c574 | 206 | NVIC_EnableIRQ(interrupt); |
AnnaBridge | 145:64910690c574 | 207 | } |
AnnaBridge | 145:64910690c574 | 208 | } |
AnnaBridge | 145:64910690c574 | 209 | |
AnnaBridge | 145:64910690c574 | 210 | /*! |
AnnaBridge | 145:64910690c574 | 211 | * @brief Disable specific interrupt. |
AnnaBridge | 145:64910690c574 | 212 | * |
AnnaBridge | 145:64910690c574 | 213 | * Disable the interrupt not routed from intmux. |
AnnaBridge | 145:64910690c574 | 214 | * |
AnnaBridge | 145:64910690c574 | 215 | * @param interrupt The IRQ number. |
AnnaBridge | 145:64910690c574 | 216 | */ |
AnnaBridge | 145:64910690c574 | 217 | static inline void DisableIRQ(IRQn_Type interrupt) |
AnnaBridge | 145:64910690c574 | 218 | { |
AnnaBridge | 145:64910690c574 | 219 | if (NotAvail_IRQn == interrupt) |
AnnaBridge | 145:64910690c574 | 220 | { |
AnnaBridge | 145:64910690c574 | 221 | return; |
AnnaBridge | 145:64910690c574 | 222 | } |
AnnaBridge | 145:64910690c574 | 223 | |
AnnaBridge | 145:64910690c574 | 224 | #if defined(FSL_FEATURE_SOC_INTMUX_COUNT) && (FSL_FEATURE_SOC_INTMUX_COUNT > 0) |
AnnaBridge | 145:64910690c574 | 225 | if (interrupt < FSL_FEATURE_INTMUX_IRQ_START_INDEX) |
AnnaBridge | 145:64910690c574 | 226 | #endif |
AnnaBridge | 145:64910690c574 | 227 | { |
AnnaBridge | 145:64910690c574 | 228 | NVIC_DisableIRQ(interrupt); |
AnnaBridge | 145:64910690c574 | 229 | } |
AnnaBridge | 145:64910690c574 | 230 | } |
AnnaBridge | 145:64910690c574 | 231 | |
AnnaBridge | 145:64910690c574 | 232 | /*! |
AnnaBridge | 145:64910690c574 | 233 | * @brief Disable the global IRQ |
AnnaBridge | 145:64910690c574 | 234 | * |
AnnaBridge | 145:64910690c574 | 235 | * Disable the global interrupt and return the current primask register. User is required to provided the primask |
AnnaBridge | 145:64910690c574 | 236 | * register for the EnableGlobalIRQ(). |
AnnaBridge | 145:64910690c574 | 237 | * |
AnnaBridge | 145:64910690c574 | 238 | * @return Current primask value. |
AnnaBridge | 145:64910690c574 | 239 | */ |
AnnaBridge | 145:64910690c574 | 240 | static inline uint32_t DisableGlobalIRQ(void) |
AnnaBridge | 145:64910690c574 | 241 | { |
AnnaBridge | 145:64910690c574 | 242 | uint32_t regPrimask = __get_PRIMASK(); |
AnnaBridge | 145:64910690c574 | 243 | |
AnnaBridge | 145:64910690c574 | 244 | __disable_irq(); |
AnnaBridge | 145:64910690c574 | 245 | |
AnnaBridge | 145:64910690c574 | 246 | return regPrimask; |
AnnaBridge | 145:64910690c574 | 247 | } |
AnnaBridge | 145:64910690c574 | 248 | |
AnnaBridge | 145:64910690c574 | 249 | /*! |
AnnaBridge | 145:64910690c574 | 250 | * @brief Enaable the global IRQ |
AnnaBridge | 145:64910690c574 | 251 | * |
AnnaBridge | 145:64910690c574 | 252 | * Set the primask register with the provided primask value but not just enable the primask. The idea is for the |
AnnaBridge | 145:64910690c574 | 253 | * convinience of integration of RTOS. some RTOS get its own management mechanism of primask. User is required to |
AnnaBridge | 145:64910690c574 | 254 | * use the EnableGlobalIRQ() and DisableGlobalIRQ() in pair. |
AnnaBridge | 145:64910690c574 | 255 | * |
AnnaBridge | 145:64910690c574 | 256 | * @param primask value of primask register to be restored. The primask value is supposed to be provided by the |
AnnaBridge | 145:64910690c574 | 257 | * DisableGlobalIRQ(). |
AnnaBridge | 145:64910690c574 | 258 | */ |
AnnaBridge | 145:64910690c574 | 259 | static inline void EnableGlobalIRQ(uint32_t primask) |
AnnaBridge | 145:64910690c574 | 260 | { |
AnnaBridge | 145:64910690c574 | 261 | __set_PRIMASK(primask); |
AnnaBridge | 145:64910690c574 | 262 | } |
AnnaBridge | 145:64910690c574 | 263 | |
AnnaBridge | 145:64910690c574 | 264 | /*! |
AnnaBridge | 145:64910690c574 | 265 | * @brief install IRQ handler |
AnnaBridge | 145:64910690c574 | 266 | * |
AnnaBridge | 145:64910690c574 | 267 | * @param irq IRQ number |
AnnaBridge | 145:64910690c574 | 268 | * @param irqHandler IRQ handler address |
AnnaBridge | 145:64910690c574 | 269 | */ |
AnnaBridge | 145:64910690c574 | 270 | void InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler); |
AnnaBridge | 145:64910690c574 | 271 | |
AnnaBridge | 145:64910690c574 | 272 | #if (defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0)) |
AnnaBridge | 145:64910690c574 | 273 | /*! |
AnnaBridge | 145:64910690c574 | 274 | * @brief Enable specific interrupt for wake-up from deep-sleep mode. |
AnnaBridge | 145:64910690c574 | 275 | * |
AnnaBridge | 145:64910690c574 | 276 | * Enable the interrupt for wake-up from deep sleep mode. |
AnnaBridge | 145:64910690c574 | 277 | * Some interrupts are typically used in sleep mode only and will not occur during |
AnnaBridge | 145:64910690c574 | 278 | * deep-sleep mode because relevant clocks are stopped. However, it is possible to enable |
AnnaBridge | 145:64910690c574 | 279 | * those clocks (significantly increasing power consumption in the reduced power mode), |
AnnaBridge | 145:64910690c574 | 280 | * making these wake-ups possible. |
AnnaBridge | 145:64910690c574 | 281 | * |
AnnaBridge | 145:64910690c574 | 282 | * @note This function also enables the interrupt in the NVIC (EnableIRQ() is called internally). |
AnnaBridge | 145:64910690c574 | 283 | * |
AnnaBridge | 145:64910690c574 | 284 | * @param interrupt The IRQ number. |
AnnaBridge | 145:64910690c574 | 285 | */ |
AnnaBridge | 145:64910690c574 | 286 | void EnableDeepSleepIRQ(IRQn_Type interrupt); |
AnnaBridge | 145:64910690c574 | 287 | |
AnnaBridge | 145:64910690c574 | 288 | /*! |
AnnaBridge | 145:64910690c574 | 289 | * @brief Disable specific interrupt for wake-up from deep-sleep mode. |
AnnaBridge | 145:64910690c574 | 290 | * |
AnnaBridge | 145:64910690c574 | 291 | * Disable the interrupt for wake-up from deep sleep mode. |
AnnaBridge | 145:64910690c574 | 292 | * Some interrupts are typically used in sleep mode only and will not occur during |
AnnaBridge | 145:64910690c574 | 293 | * deep-sleep mode because relevant clocks are stopped. However, it is possible to enable |
AnnaBridge | 145:64910690c574 | 294 | * those clocks (significantly increasing power consumption in the reduced power mode), |
AnnaBridge | 145:64910690c574 | 295 | * making these wake-ups possible. |
AnnaBridge | 145:64910690c574 | 296 | * |
AnnaBridge | 145:64910690c574 | 297 | * @note This function also disables the interrupt in the NVIC (DisableIRQ() is called internally). |
AnnaBridge | 145:64910690c574 | 298 | * |
AnnaBridge | 145:64910690c574 | 299 | * @param interrupt The IRQ number. |
AnnaBridge | 145:64910690c574 | 300 | */ |
AnnaBridge | 145:64910690c574 | 301 | void DisableDeepSleepIRQ(IRQn_Type interrupt); |
AnnaBridge | 145:64910690c574 | 302 | #endif /* FSL_FEATURE_SOC_SYSCON_COUNT */ |
AnnaBridge | 145:64910690c574 | 303 | |
AnnaBridge | 145:64910690c574 | 304 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 305 | } |
AnnaBridge | 145:64910690c574 | 306 | #endif |
AnnaBridge | 145:64910690c574 | 307 | |
AnnaBridge | 145:64910690c574 | 308 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 309 | |
AnnaBridge | 145:64910690c574 | 310 | #endif /* _FSL_COMMON_H_ */ |