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