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