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