![](/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_flexio.c@3:f3764f852aa8, 2018-10-11 (annotated)
- Committer:
- kadonotakashi
- Date:
- Thu Oct 11 02:27:46 2018 +0000
- Revision:
- 3:f3764f852aa8
- Parent:
- 0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;
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, 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 | #include "fsl_flexio.h" |
kadonotakashi | 0:8fdf9a60065b | 32 | |
kadonotakashi | 0:8fdf9a60065b | 33 | /******************************************************************************* |
kadonotakashi | 0:8fdf9a60065b | 34 | * Definitions |
kadonotakashi | 0:8fdf9a60065b | 35 | ******************************************************************************/ |
kadonotakashi | 0:8fdf9a60065b | 36 | |
kadonotakashi | 0:8fdf9a60065b | 37 | /*< @brief user configurable flexio handle count. */ |
kadonotakashi | 0:8fdf9a60065b | 38 | #define FLEXIO_HANDLE_COUNT 2 |
kadonotakashi | 0:8fdf9a60065b | 39 | |
kadonotakashi | 0:8fdf9a60065b | 40 | /******************************************************************************* |
kadonotakashi | 0:8fdf9a60065b | 41 | * Variables |
kadonotakashi | 0:8fdf9a60065b | 42 | ******************************************************************************/ |
kadonotakashi | 0:8fdf9a60065b | 43 | |
kadonotakashi | 0:8fdf9a60065b | 44 | /*< @brief pointer to array of FLEXIO handle. */ |
kadonotakashi | 0:8fdf9a60065b | 45 | static void *s_flexioHandle[FLEXIO_HANDLE_COUNT]; |
kadonotakashi | 0:8fdf9a60065b | 46 | |
kadonotakashi | 0:8fdf9a60065b | 47 | /*< @brief pointer to array of FLEXIO IP types. */ |
kadonotakashi | 0:8fdf9a60065b | 48 | static void *s_flexioType[FLEXIO_HANDLE_COUNT]; |
kadonotakashi | 0:8fdf9a60065b | 49 | |
kadonotakashi | 0:8fdf9a60065b | 50 | /*< @brief pointer to array of FLEXIO Isr. */ |
kadonotakashi | 0:8fdf9a60065b | 51 | static flexio_isr_t s_flexioIsr[FLEXIO_HANDLE_COUNT]; |
kadonotakashi | 0:8fdf9a60065b | 52 | |
kadonotakashi | 0:8fdf9a60065b | 53 | #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) |
kadonotakashi | 0:8fdf9a60065b | 54 | /*! @brief Pointers to flexio clocks for each instance. */ |
kadonotakashi | 0:8fdf9a60065b | 55 | const clock_ip_name_t s_flexioClocks[] = FLEXIO_CLOCKS; |
kadonotakashi | 0:8fdf9a60065b | 56 | #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */ |
kadonotakashi | 0:8fdf9a60065b | 57 | |
kadonotakashi | 0:8fdf9a60065b | 58 | /*! @brief Pointers to flexio bases for each instance. */ |
kadonotakashi | 0:8fdf9a60065b | 59 | FLEXIO_Type *const s_flexioBases[] = FLEXIO_BASE_PTRS; |
kadonotakashi | 0:8fdf9a60065b | 60 | |
kadonotakashi | 0:8fdf9a60065b | 61 | /******************************************************************************* |
kadonotakashi | 0:8fdf9a60065b | 62 | * Codes |
kadonotakashi | 0:8fdf9a60065b | 63 | ******************************************************************************/ |
kadonotakashi | 0:8fdf9a60065b | 64 | |
kadonotakashi | 0:8fdf9a60065b | 65 | uint32_t FLEXIO_GetInstance(FLEXIO_Type *base) |
kadonotakashi | 0:8fdf9a60065b | 66 | { |
kadonotakashi | 0:8fdf9a60065b | 67 | uint32_t instance; |
kadonotakashi | 0:8fdf9a60065b | 68 | |
kadonotakashi | 0:8fdf9a60065b | 69 | /* Find the instance index from base address mappings. */ |
kadonotakashi | 0:8fdf9a60065b | 70 | for (instance = 0; instance < FSL_FEATURE_SOC_FLEXIO_COUNT; instance++) |
kadonotakashi | 0:8fdf9a60065b | 71 | { |
kadonotakashi | 0:8fdf9a60065b | 72 | if (s_flexioBases[instance] == base) |
kadonotakashi | 0:8fdf9a60065b | 73 | { |
kadonotakashi | 0:8fdf9a60065b | 74 | break; |
kadonotakashi | 0:8fdf9a60065b | 75 | } |
kadonotakashi | 0:8fdf9a60065b | 76 | } |
kadonotakashi | 0:8fdf9a60065b | 77 | |
kadonotakashi | 0:8fdf9a60065b | 78 | assert(instance < FSL_FEATURE_SOC_FLEXIO_COUNT); |
kadonotakashi | 0:8fdf9a60065b | 79 | |
kadonotakashi | 0:8fdf9a60065b | 80 | return instance; |
kadonotakashi | 0:8fdf9a60065b | 81 | } |
kadonotakashi | 0:8fdf9a60065b | 82 | |
kadonotakashi | 0:8fdf9a60065b | 83 | void FLEXIO_Init(FLEXIO_Type *base, const flexio_config_t *userConfig) |
kadonotakashi | 0:8fdf9a60065b | 84 | { |
kadonotakashi | 0:8fdf9a60065b | 85 | uint32_t ctrlReg = 0; |
kadonotakashi | 0:8fdf9a60065b | 86 | |
kadonotakashi | 0:8fdf9a60065b | 87 | #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) |
kadonotakashi | 0:8fdf9a60065b | 88 | CLOCK_EnableClock(s_flexioClocks[FLEXIO_GetInstance(base)]); |
kadonotakashi | 0:8fdf9a60065b | 89 | #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */ |
kadonotakashi | 0:8fdf9a60065b | 90 | |
kadonotakashi | 0:8fdf9a60065b | 91 | FLEXIO_Reset(base); |
kadonotakashi | 0:8fdf9a60065b | 92 | |
kadonotakashi | 0:8fdf9a60065b | 93 | ctrlReg = base->CTRL; |
kadonotakashi | 0:8fdf9a60065b | 94 | ctrlReg &= ~(FLEXIO_CTRL_DOZEN_MASK | FLEXIO_CTRL_DBGE_MASK | FLEXIO_CTRL_FASTACC_MASK | FLEXIO_CTRL_FLEXEN_MASK); |
kadonotakashi | 0:8fdf9a60065b | 95 | ctrlReg |= (FLEXIO_CTRL_DBGE(userConfig->enableInDebug) | FLEXIO_CTRL_FASTACC(userConfig->enableFastAccess) | |
kadonotakashi | 0:8fdf9a60065b | 96 | FLEXIO_CTRL_FLEXEN(userConfig->enableFlexio)); |
kadonotakashi | 0:8fdf9a60065b | 97 | if (!userConfig->enableInDoze) |
kadonotakashi | 0:8fdf9a60065b | 98 | { |
kadonotakashi | 0:8fdf9a60065b | 99 | ctrlReg |= FLEXIO_CTRL_DOZEN_MASK; |
kadonotakashi | 0:8fdf9a60065b | 100 | } |
kadonotakashi | 0:8fdf9a60065b | 101 | |
kadonotakashi | 0:8fdf9a60065b | 102 | base->CTRL = ctrlReg; |
kadonotakashi | 0:8fdf9a60065b | 103 | } |
kadonotakashi | 0:8fdf9a60065b | 104 | |
kadonotakashi | 0:8fdf9a60065b | 105 | void FLEXIO_Deinit(FLEXIO_Type *base) |
kadonotakashi | 0:8fdf9a60065b | 106 | { |
kadonotakashi | 0:8fdf9a60065b | 107 | FLEXIO_Enable(base, false); |
kadonotakashi | 0:8fdf9a60065b | 108 | #if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) |
kadonotakashi | 0:8fdf9a60065b | 109 | CLOCK_DisableClock(s_flexioClocks[FLEXIO_GetInstance(base)]); |
kadonotakashi | 0:8fdf9a60065b | 110 | #endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */ |
kadonotakashi | 0:8fdf9a60065b | 111 | } |
kadonotakashi | 0:8fdf9a60065b | 112 | |
kadonotakashi | 0:8fdf9a60065b | 113 | void FLEXIO_GetDefaultConfig(flexio_config_t *userConfig) |
kadonotakashi | 0:8fdf9a60065b | 114 | { |
kadonotakashi | 0:8fdf9a60065b | 115 | assert(userConfig); |
kadonotakashi | 0:8fdf9a60065b | 116 | |
kadonotakashi | 0:8fdf9a60065b | 117 | userConfig->enableFlexio = true; |
kadonotakashi | 0:8fdf9a60065b | 118 | userConfig->enableInDoze = false; |
kadonotakashi | 0:8fdf9a60065b | 119 | userConfig->enableInDebug = true; |
kadonotakashi | 0:8fdf9a60065b | 120 | userConfig->enableFastAccess = false; |
kadonotakashi | 0:8fdf9a60065b | 121 | } |
kadonotakashi | 0:8fdf9a60065b | 122 | |
kadonotakashi | 0:8fdf9a60065b | 123 | void FLEXIO_Reset(FLEXIO_Type *base) |
kadonotakashi | 0:8fdf9a60065b | 124 | { |
kadonotakashi | 0:8fdf9a60065b | 125 | /*do software reset, software reset operation affect all other FLEXIO registers except CTRL*/ |
kadonotakashi | 0:8fdf9a60065b | 126 | base->CTRL |= FLEXIO_CTRL_SWRST_MASK; |
kadonotakashi | 0:8fdf9a60065b | 127 | base->CTRL = 0; |
kadonotakashi | 0:8fdf9a60065b | 128 | } |
kadonotakashi | 0:8fdf9a60065b | 129 | |
kadonotakashi | 0:8fdf9a60065b | 130 | uint32_t FLEXIO_GetShifterBufferAddress(FLEXIO_Type *base, flexio_shifter_buffer_type_t type, uint8_t index) |
kadonotakashi | 0:8fdf9a60065b | 131 | { |
kadonotakashi | 0:8fdf9a60065b | 132 | assert(index < FLEXIO_SHIFTBUF_COUNT); |
kadonotakashi | 0:8fdf9a60065b | 133 | |
kadonotakashi | 0:8fdf9a60065b | 134 | uint32_t address = 0; |
kadonotakashi | 0:8fdf9a60065b | 135 | |
kadonotakashi | 0:8fdf9a60065b | 136 | switch (type) |
kadonotakashi | 0:8fdf9a60065b | 137 | { |
kadonotakashi | 0:8fdf9a60065b | 138 | case kFLEXIO_ShifterBuffer: |
kadonotakashi | 0:8fdf9a60065b | 139 | address = (uint32_t) & (base->SHIFTBUF[index]); |
kadonotakashi | 0:8fdf9a60065b | 140 | break; |
kadonotakashi | 0:8fdf9a60065b | 141 | |
kadonotakashi | 0:8fdf9a60065b | 142 | case kFLEXIO_ShifterBufferBitSwapped: |
kadonotakashi | 0:8fdf9a60065b | 143 | address = (uint32_t) & (base->SHIFTBUFBIS[index]); |
kadonotakashi | 0:8fdf9a60065b | 144 | break; |
kadonotakashi | 0:8fdf9a60065b | 145 | |
kadonotakashi | 0:8fdf9a60065b | 146 | case kFLEXIO_ShifterBufferByteSwapped: |
kadonotakashi | 0:8fdf9a60065b | 147 | address = (uint32_t) & (base->SHIFTBUFBYS[index]); |
kadonotakashi | 0:8fdf9a60065b | 148 | break; |
kadonotakashi | 0:8fdf9a60065b | 149 | |
kadonotakashi | 0:8fdf9a60065b | 150 | case kFLEXIO_ShifterBufferBitByteSwapped: |
kadonotakashi | 0:8fdf9a60065b | 151 | address = (uint32_t) & (base->SHIFTBUFBBS[index]); |
kadonotakashi | 0:8fdf9a60065b | 152 | break; |
kadonotakashi | 0:8fdf9a60065b | 153 | |
kadonotakashi | 0:8fdf9a60065b | 154 | #if defined(FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_BYTE_SWAP) && FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_BYTE_SWAP |
kadonotakashi | 0:8fdf9a60065b | 155 | case kFLEXIO_ShifterBufferNibbleByteSwapped: |
kadonotakashi | 0:8fdf9a60065b | 156 | address = (uint32_t) & (base->SHIFTBUFNBS[index]); |
kadonotakashi | 0:8fdf9a60065b | 157 | break; |
kadonotakashi | 0:8fdf9a60065b | 158 | |
kadonotakashi | 0:8fdf9a60065b | 159 | #endif |
kadonotakashi | 0:8fdf9a60065b | 160 | #if defined(FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_HALF_WORD_SWAP) && FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_HALF_WORD_SWAP |
kadonotakashi | 0:8fdf9a60065b | 161 | case kFLEXIO_ShifterBufferHalfWordSwapped: |
kadonotakashi | 0:8fdf9a60065b | 162 | address = (uint32_t) & (base->SHIFTBUFHWS[index]); |
kadonotakashi | 0:8fdf9a60065b | 163 | break; |
kadonotakashi | 0:8fdf9a60065b | 164 | |
kadonotakashi | 0:8fdf9a60065b | 165 | #endif |
kadonotakashi | 0:8fdf9a60065b | 166 | #if defined(FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_SWAP) && FSL_FEATURE_FLEXIO_HAS_SHFT_BUFFER_NIBBLE_SWAP |
kadonotakashi | 0:8fdf9a60065b | 167 | case kFLEXIO_ShifterBufferNibbleSwapped: |
kadonotakashi | 0:8fdf9a60065b | 168 | address = (uint32_t) & (base->SHIFTBUFNIS[index]); |
kadonotakashi | 0:8fdf9a60065b | 169 | break; |
kadonotakashi | 0:8fdf9a60065b | 170 | |
kadonotakashi | 0:8fdf9a60065b | 171 | #endif |
kadonotakashi | 0:8fdf9a60065b | 172 | default: |
kadonotakashi | 0:8fdf9a60065b | 173 | break; |
kadonotakashi | 0:8fdf9a60065b | 174 | } |
kadonotakashi | 0:8fdf9a60065b | 175 | return address; |
kadonotakashi | 0:8fdf9a60065b | 176 | } |
kadonotakashi | 0:8fdf9a60065b | 177 | |
kadonotakashi | 0:8fdf9a60065b | 178 | void FLEXIO_SetShifterConfig(FLEXIO_Type *base, uint8_t index, const flexio_shifter_config_t *shifterConfig) |
kadonotakashi | 0:8fdf9a60065b | 179 | { |
kadonotakashi | 0:8fdf9a60065b | 180 | base->SHIFTCFG[index] = FLEXIO_SHIFTCFG_INSRC(shifterConfig->inputSource) |
kadonotakashi | 0:8fdf9a60065b | 181 | #if FSL_FEATURE_FLEXIO_HAS_PARALLEL_WIDTH |
kadonotakashi | 0:8fdf9a60065b | 182 | | FLEXIO_SHIFTCFG_PWIDTH(shifterConfig->parallelWidth) |
kadonotakashi | 0:8fdf9a60065b | 183 | #endif /* FSL_FEATURE_FLEXIO_HAS_PARALLEL_WIDTH */ |
kadonotakashi | 0:8fdf9a60065b | 184 | | FLEXIO_SHIFTCFG_SSTOP(shifterConfig->shifterStop) | |
kadonotakashi | 0:8fdf9a60065b | 185 | FLEXIO_SHIFTCFG_SSTART(shifterConfig->shifterStart); |
kadonotakashi | 0:8fdf9a60065b | 186 | |
kadonotakashi | 0:8fdf9a60065b | 187 | base->SHIFTCTL[index] = |
kadonotakashi | 0:8fdf9a60065b | 188 | FLEXIO_SHIFTCTL_TIMSEL(shifterConfig->timerSelect) | FLEXIO_SHIFTCTL_TIMPOL(shifterConfig->timerPolarity) | |
kadonotakashi | 0:8fdf9a60065b | 189 | FLEXIO_SHIFTCTL_PINCFG(shifterConfig->pinConfig) | FLEXIO_SHIFTCTL_PINSEL(shifterConfig->pinSelect) | |
kadonotakashi | 0:8fdf9a60065b | 190 | FLEXIO_SHIFTCTL_PINPOL(shifterConfig->pinPolarity) | FLEXIO_SHIFTCTL_SMOD(shifterConfig->shifterMode); |
kadonotakashi | 0:8fdf9a60065b | 191 | } |
kadonotakashi | 0:8fdf9a60065b | 192 | |
kadonotakashi | 0:8fdf9a60065b | 193 | void FLEXIO_SetTimerConfig(FLEXIO_Type *base, uint8_t index, const flexio_timer_config_t *timerConfig) |
kadonotakashi | 0:8fdf9a60065b | 194 | { |
kadonotakashi | 0:8fdf9a60065b | 195 | base->TIMCFG[index] = |
kadonotakashi | 0:8fdf9a60065b | 196 | FLEXIO_TIMCFG_TIMOUT(timerConfig->timerOutput) | FLEXIO_TIMCFG_TIMDEC(timerConfig->timerDecrement) | |
kadonotakashi | 0:8fdf9a60065b | 197 | FLEXIO_TIMCFG_TIMRST(timerConfig->timerReset) | FLEXIO_TIMCFG_TIMDIS(timerConfig->timerDisable) | |
kadonotakashi | 0:8fdf9a60065b | 198 | FLEXIO_TIMCFG_TIMENA(timerConfig->timerEnable) | FLEXIO_TIMCFG_TSTOP(timerConfig->timerStop) | |
kadonotakashi | 0:8fdf9a60065b | 199 | FLEXIO_TIMCFG_TSTART(timerConfig->timerStart); |
kadonotakashi | 0:8fdf9a60065b | 200 | |
kadonotakashi | 0:8fdf9a60065b | 201 | base->TIMCMP[index] = FLEXIO_TIMCMP_CMP(timerConfig->timerCompare); |
kadonotakashi | 0:8fdf9a60065b | 202 | |
kadonotakashi | 0:8fdf9a60065b | 203 | base->TIMCTL[index] = FLEXIO_TIMCTL_TRGSEL(timerConfig->triggerSelect) | |
kadonotakashi | 0:8fdf9a60065b | 204 | FLEXIO_TIMCTL_TRGPOL(timerConfig->triggerPolarity) | |
kadonotakashi | 0:8fdf9a60065b | 205 | FLEXIO_TIMCTL_TRGSRC(timerConfig->triggerSource) | |
kadonotakashi | 0:8fdf9a60065b | 206 | FLEXIO_TIMCTL_PINCFG(timerConfig->pinConfig) | FLEXIO_TIMCTL_PINSEL(timerConfig->pinSelect) | |
kadonotakashi | 0:8fdf9a60065b | 207 | FLEXIO_TIMCTL_PINPOL(timerConfig->pinPolarity) | FLEXIO_TIMCTL_TIMOD(timerConfig->timerMode); |
kadonotakashi | 0:8fdf9a60065b | 208 | } |
kadonotakashi | 0:8fdf9a60065b | 209 | |
kadonotakashi | 0:8fdf9a60065b | 210 | status_t FLEXIO_RegisterHandleIRQ(void *base, void *handle, flexio_isr_t isr) |
kadonotakashi | 0:8fdf9a60065b | 211 | { |
kadonotakashi | 0:8fdf9a60065b | 212 | assert(base); |
kadonotakashi | 0:8fdf9a60065b | 213 | assert(handle); |
kadonotakashi | 0:8fdf9a60065b | 214 | assert(isr); |
kadonotakashi | 0:8fdf9a60065b | 215 | |
kadonotakashi | 0:8fdf9a60065b | 216 | uint8_t index = 0; |
kadonotakashi | 0:8fdf9a60065b | 217 | |
kadonotakashi | 0:8fdf9a60065b | 218 | /* Find the an empty handle pointer to store the handle. */ |
kadonotakashi | 0:8fdf9a60065b | 219 | for (index = 0; index < FLEXIO_HANDLE_COUNT; index++) |
kadonotakashi | 0:8fdf9a60065b | 220 | { |
kadonotakashi | 0:8fdf9a60065b | 221 | if (s_flexioHandle[index] == NULL) |
kadonotakashi | 0:8fdf9a60065b | 222 | { |
kadonotakashi | 0:8fdf9a60065b | 223 | /* Register FLEXIO simulated driver base, handle and isr. */ |
kadonotakashi | 0:8fdf9a60065b | 224 | s_flexioType[index] = base; |
kadonotakashi | 0:8fdf9a60065b | 225 | s_flexioHandle[index] = handle; |
kadonotakashi | 0:8fdf9a60065b | 226 | s_flexioIsr[index] = isr; |
kadonotakashi | 0:8fdf9a60065b | 227 | break; |
kadonotakashi | 0:8fdf9a60065b | 228 | } |
kadonotakashi | 0:8fdf9a60065b | 229 | } |
kadonotakashi | 0:8fdf9a60065b | 230 | |
kadonotakashi | 0:8fdf9a60065b | 231 | if (index == FLEXIO_HANDLE_COUNT) |
kadonotakashi | 0:8fdf9a60065b | 232 | { |
kadonotakashi | 0:8fdf9a60065b | 233 | return kStatus_OutOfRange; |
kadonotakashi | 0:8fdf9a60065b | 234 | } |
kadonotakashi | 0:8fdf9a60065b | 235 | else |
kadonotakashi | 0:8fdf9a60065b | 236 | { |
kadonotakashi | 0:8fdf9a60065b | 237 | return kStatus_Success; |
kadonotakashi | 0:8fdf9a60065b | 238 | } |
kadonotakashi | 0:8fdf9a60065b | 239 | } |
kadonotakashi | 0:8fdf9a60065b | 240 | |
kadonotakashi | 0:8fdf9a60065b | 241 | status_t FLEXIO_UnregisterHandleIRQ(void *base) |
kadonotakashi | 0:8fdf9a60065b | 242 | { |
kadonotakashi | 0:8fdf9a60065b | 243 | assert(base); |
kadonotakashi | 0:8fdf9a60065b | 244 | |
kadonotakashi | 0:8fdf9a60065b | 245 | uint8_t index = 0; |
kadonotakashi | 0:8fdf9a60065b | 246 | |
kadonotakashi | 0:8fdf9a60065b | 247 | /* Find the index from base address mappings. */ |
kadonotakashi | 0:8fdf9a60065b | 248 | for (index = 0; index < FLEXIO_HANDLE_COUNT; index++) |
kadonotakashi | 0:8fdf9a60065b | 249 | { |
kadonotakashi | 0:8fdf9a60065b | 250 | if (s_flexioType[index] == base) |
kadonotakashi | 0:8fdf9a60065b | 251 | { |
kadonotakashi | 0:8fdf9a60065b | 252 | /* Unregister FLEXIO simulated driver handle and isr. */ |
kadonotakashi | 0:8fdf9a60065b | 253 | s_flexioType[index] = NULL; |
kadonotakashi | 0:8fdf9a60065b | 254 | s_flexioHandle[index] = NULL; |
kadonotakashi | 0:8fdf9a60065b | 255 | s_flexioIsr[index] = NULL; |
kadonotakashi | 0:8fdf9a60065b | 256 | break; |
kadonotakashi | 0:8fdf9a60065b | 257 | } |
kadonotakashi | 0:8fdf9a60065b | 258 | } |
kadonotakashi | 0:8fdf9a60065b | 259 | |
kadonotakashi | 0:8fdf9a60065b | 260 | if (index == FLEXIO_HANDLE_COUNT) |
kadonotakashi | 0:8fdf9a60065b | 261 | { |
kadonotakashi | 0:8fdf9a60065b | 262 | return kStatus_OutOfRange; |
kadonotakashi | 0:8fdf9a60065b | 263 | } |
kadonotakashi | 0:8fdf9a60065b | 264 | else |
kadonotakashi | 0:8fdf9a60065b | 265 | { |
kadonotakashi | 0:8fdf9a60065b | 266 | return kStatus_Success; |
kadonotakashi | 0:8fdf9a60065b | 267 | } |
kadonotakashi | 0:8fdf9a60065b | 268 | } |
kadonotakashi | 0:8fdf9a60065b | 269 | |
kadonotakashi | 0:8fdf9a60065b | 270 | void FLEXIO_CommonIRQHandler(void) |
kadonotakashi | 0:8fdf9a60065b | 271 | { |
kadonotakashi | 0:8fdf9a60065b | 272 | uint8_t index; |
kadonotakashi | 0:8fdf9a60065b | 273 | |
kadonotakashi | 0:8fdf9a60065b | 274 | for (index = 0; index < FLEXIO_HANDLE_COUNT; index++) |
kadonotakashi | 0:8fdf9a60065b | 275 | { |
kadonotakashi | 0:8fdf9a60065b | 276 | if (s_flexioHandle[index]) |
kadonotakashi | 0:8fdf9a60065b | 277 | { |
kadonotakashi | 0:8fdf9a60065b | 278 | s_flexioIsr[index](s_flexioType[index], s_flexioHandle[index]); |
kadonotakashi | 0:8fdf9a60065b | 279 | } |
kadonotakashi | 0:8fdf9a60065b | 280 | } |
kadonotakashi | 0:8fdf9a60065b | 281 | } |
kadonotakashi | 0:8fdf9a60065b | 282 | |
kadonotakashi | 0:8fdf9a60065b | 283 | void FLEXIO_DriverIRQHandler(void) |
kadonotakashi | 0:8fdf9a60065b | 284 | { |
kadonotakashi | 0:8fdf9a60065b | 285 | FLEXIO_CommonIRQHandler(); |
kadonotakashi | 0:8fdf9a60065b | 286 | } |
kadonotakashi | 0:8fdf9a60065b | 287 | |
kadonotakashi | 0:8fdf9a60065b | 288 | void FLEXIO0_DriverIRQHandler(void) |
kadonotakashi | 0:8fdf9a60065b | 289 | { |
kadonotakashi | 0:8fdf9a60065b | 290 | FLEXIO_CommonIRQHandler(); |
kadonotakashi | 0:8fdf9a60065b | 291 | } |
kadonotakashi | 0:8fdf9a60065b | 292 | |
kadonotakashi | 0:8fdf9a60065b | 293 | void UART2_FLEXIO_DriverIRQHandler(void) |
kadonotakashi | 0:8fdf9a60065b | 294 | { |
kadonotakashi | 0:8fdf9a60065b | 295 | FLEXIO_CommonIRQHandler(); |
kadonotakashi | 0:8fdf9a60065b | 296 | } |