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