mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Thu Sep 18 14:00:17 2014 +0100
Revision:
324:406fd2029f23
Parent:
149:1fb5f62b92bd
Synchronized with git revision a73f28e6fbca9559fbed2726410eeb4c0534a4a5

Full URL: https://github.com/mbedmicro/mbed/commit/a73f28e6fbca9559fbed2726410eeb4c0534a4a5/

Extended #476, which does not break ethernet for K64F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 146:f64d43ff0c18 30 #ifndef __FSL_PORT_HAL_H__
mbed_official 146:f64d43ff0c18 31 #define __FSL_PORT_HAL_H__
mbed_official 146:f64d43ff0c18 32
mbed_official 146:f64d43ff0c18 33 #include <assert.h>
mbed_official 146:f64d43ff0c18 34 #include <stdint.h>
mbed_official 146:f64d43ff0c18 35 #include <stdbool.h>
mbed_official 146:f64d43ff0c18 36 #include "fsl_port_features.h"
mbed_official 146:f64d43ff0c18 37 #include "fsl_device_registers.h"
mbed_official 146:f64d43ff0c18 38
mbed_official 146:f64d43ff0c18 39 /*!
mbed_official 146:f64d43ff0c18 40 * @addtogroup port_hal
mbed_official 146:f64d43ff0c18 41 * @{
mbed_official 146:f64d43ff0c18 42 */
mbed_official 146:f64d43ff0c18 43
mbed_official 146:f64d43ff0c18 44 /*******************************************************************************
mbed_official 146:f64d43ff0c18 45 * Definitions
mbed_official 146:f64d43ff0c18 46 ******************************************************************************/
mbed_official 146:f64d43ff0c18 47 /*! @brief Internal resistor pull feature selection*/
mbed_official 146:f64d43ff0c18 48 typedef enum _port_pull {
mbed_official 146:f64d43ff0c18 49 kPortPullDown = 0U, /*!< internal pull-down resistor is enabled.*/
mbed_official 146:f64d43ff0c18 50 kPortPullUp = 1U /*!< internal pull-up resistor is enabled.*/
mbed_official 146:f64d43ff0c18 51 } port_pull_t;
mbed_official 146:f64d43ff0c18 52
mbed_official 146:f64d43ff0c18 53 /*! @brief Slew rate selection*/
mbed_official 146:f64d43ff0c18 54 typedef enum _port_slew_rate {
mbed_official 146:f64d43ff0c18 55 kPortFastSlewRate = 0U, /*!< fast slew rate is configured.*/
mbed_official 146:f64d43ff0c18 56 kPortSlowSlewRate = 1U /*!< slow slew rate is configured.*/
mbed_official 146:f64d43ff0c18 57 } port_slew_rate_t;
mbed_official 146:f64d43ff0c18 58
mbed_official 146:f64d43ff0c18 59 /*! @brief Configures the drive strength.*/
mbed_official 146:f64d43ff0c18 60 typedef enum _port_drive_strength {
mbed_official 146:f64d43ff0c18 61 kPortLowDriveStrength = 0U, /*!< low drive strength is configured.*/
mbed_official 146:f64d43ff0c18 62 kPortHighDriveStrength = 1U /*!< high drive strength is configured.*/
mbed_official 146:f64d43ff0c18 63 } port_drive_strength_t;
mbed_official 146:f64d43ff0c18 64
mbed_official 146:f64d43ff0c18 65 /*! @brief Pin mux selection*/
mbed_official 146:f64d43ff0c18 66 typedef enum _port_mux {
mbed_official 146:f64d43ff0c18 67 kPortPinDisabled = 0U, /*!< corresponding pin is disabled as analog.*/
mbed_official 146:f64d43ff0c18 68 kPortMuxAsGpio = 1U, /*!< corresponding pin is configured as GPIO.*/
mbed_official 146:f64d43ff0c18 69 kPortMuxAlt2 = 2U, /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 70 kPortMuxAlt3 = 3U, /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 71 kPortMuxAlt4 = 4U, /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 72 kPortMuxAlt5 = 5U, /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 73 kPortMuxAlt6 = 6U, /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 74 kPortMuxAlt7 = 7U /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 75 } port_mux_t;
mbed_official 146:f64d43ff0c18 76
mbed_official 146:f64d43ff0c18 77 /*! @brief Digital filter clock source selection*/
mbed_official 146:f64d43ff0c18 78 #if FSL_FEATURE_PORT_HAS_DIGITAL_FILTER
mbed_official 146:f64d43ff0c18 79 typedef enum _port_digital_filter_clock_source {
mbed_official 146:f64d43ff0c18 80 kPortBusClock = 0U, /*!< Digital filters are clocked by the bus clock.*/
mbed_official 146:f64d43ff0c18 81 kPortLPOClock = 1U /*!< Digital filters are clocked by the 1 kHz LPO clock.*/
mbed_official 146:f64d43ff0c18 82 } port_digital_filter_clock_source_t;
mbed_official 146:f64d43ff0c18 83 #endif
mbed_official 146:f64d43ff0c18 84
mbed_official 146:f64d43ff0c18 85 /*! @brief Configures the interrupt generation condition.*/
mbed_official 146:f64d43ff0c18 86 typedef enum _port_interrupt_config {
mbed_official 146:f64d43ff0c18 87 kPortIntDisabled = 0x0U, /*!< Interrupt/DMA request is disabled.*/
mbed_official 146:f64d43ff0c18 88 kPortDmaRisingEdge = 0x1U, /*!< DMA request on rising edge.*/
mbed_official 146:f64d43ff0c18 89 kPortDmaFallingEdge = 0x2U, /*!< DMA request on falling edge.*/
mbed_official 146:f64d43ff0c18 90 kPortDmaEitherEdge = 0x3U, /*!< DMA request on either edge.*/
mbed_official 146:f64d43ff0c18 91 kPortIntLogicZero = 0x8U, /*!< Interrupt when logic zero. */
mbed_official 146:f64d43ff0c18 92 kPortIntRisingEdge = 0x9U, /*!< Interrupt on rising edge. */
mbed_official 146:f64d43ff0c18 93 kPortIntFallingEdge = 0xAU, /*!< Interrupt on falling edge. */
mbed_official 146:f64d43ff0c18 94 kPortIntEitherEdge = 0xBU, /*!< Interrupt on either edge. */
mbed_official 146:f64d43ff0c18 95 kPortIntLogicOne = 0xCU /*!< Interrupt when logic one. */
mbed_official 146:f64d43ff0c18 96 } port_interrupt_config_t;
mbed_official 146:f64d43ff0c18 97
mbed_official 146:f64d43ff0c18 98 /*******************************************************************************
mbed_official 146:f64d43ff0c18 99 * API
mbed_official 146:f64d43ff0c18 100 ******************************************************************************/
mbed_official 146:f64d43ff0c18 101
mbed_official 146:f64d43ff0c18 102 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 103 extern "C" {
mbed_official 146:f64d43ff0c18 104 #endif
mbed_official 146:f64d43ff0c18 105
mbed_official 146:f64d43ff0c18 106 /*!
mbed_official 146:f64d43ff0c18 107 * @name Configuration
mbed_official 146:f64d43ff0c18 108 * @{
mbed_official 146:f64d43ff0c18 109 */
mbed_official 146:f64d43ff0c18 110
mbed_official 146:f64d43ff0c18 111 /*!
mbed_official 146:f64d43ff0c18 112 * @brief Selects the internal resistor as pull-down or pull-up.
mbed_official 146:f64d43ff0c18 113 *
mbed_official 146:f64d43ff0c18 114 * Pull configuration is valid in all digital pin muxing modes.
mbed_official 146:f64d43ff0c18 115 *
mbed_official 324:406fd2029f23 116 * @param baseAddr port base address.
mbed_official 146:f64d43ff0c18 117 * @param pin port pin number
mbed_official 146:f64d43ff0c18 118 * @param pullSelect internal resistor pull feature selection
mbed_official 146:f64d43ff0c18 119 * - kPortPullDown: internal pull-down resistor is enabled.
mbed_official 146:f64d43ff0c18 120 * - kPortPullUp : internal pull-up resistor is enabled.
mbed_official 146:f64d43ff0c18 121 */
mbed_official 324:406fd2029f23 122 static inline void PORT_HAL_SetPullMode(uint32_t baseAddr,
mbed_official 146:f64d43ff0c18 123 uint32_t pin,
mbed_official 146:f64d43ff0c18 124 port_pull_t pullSelect)
mbed_official 146:f64d43ff0c18 125 {
mbed_official 146:f64d43ff0c18 126 assert(pin < 32U);
mbed_official 324:406fd2029f23 127 BW_PORT_PCRn_PS(baseAddr, pin, pullSelect);
mbed_official 146:f64d43ff0c18 128 }
mbed_official 146:f64d43ff0c18 129
mbed_official 146:f64d43ff0c18 130 /*!
mbed_official 146:f64d43ff0c18 131 * @brief Enables or disables the internal pull resistor.
mbed_official 146:f64d43ff0c18 132 *
mbed_official 324:406fd2029f23 133 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 134 * @param pin port pin number
mbed_official 146:f64d43ff0c18 135 * @param isPullEnabled internal pull resistor enable or disable
mbed_official 146:f64d43ff0c18 136 * - true : internal pull resistor is enabled.
mbed_official 146:f64d43ff0c18 137 * - false: internal pull resistor is disabled.
mbed_official 146:f64d43ff0c18 138 */
mbed_official 324:406fd2029f23 139 static inline void PORT_HAL_SetPullCmd(uint32_t baseAddr, uint32_t pin, bool isPullEnabled)
mbed_official 146:f64d43ff0c18 140 {
mbed_official 146:f64d43ff0c18 141 assert(pin < 32U);
mbed_official 324:406fd2029f23 142 BW_PORT_PCRn_PE(baseAddr, pin, isPullEnabled);
mbed_official 146:f64d43ff0c18 143 }
mbed_official 146:f64d43ff0c18 144
mbed_official 146:f64d43ff0c18 145 /*!
mbed_official 146:f64d43ff0c18 146 * @brief Configures the fast/slow slew rate if the pin is used as a digital output.
mbed_official 146:f64d43ff0c18 147 *
mbed_official 324:406fd2029f23 148 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 149 * @param pin port pin number
mbed_official 146:f64d43ff0c18 150 * @param rateSelect slew rate selection
mbed_official 146:f64d43ff0c18 151 * - kPortFastSlewRate: fast slew rate is configured.
mbed_official 146:f64d43ff0c18 152 * - kPortSlowSlewRate: slow slew rate is configured.
mbed_official 146:f64d43ff0c18 153 */
mbed_official 324:406fd2029f23 154 static inline void PORT_HAL_SetSlewRateMode(uint32_t baseAddr,
mbed_official 146:f64d43ff0c18 155 uint32_t pin,
mbed_official 146:f64d43ff0c18 156 port_slew_rate_t rateSelect)
mbed_official 146:f64d43ff0c18 157 {
mbed_official 146:f64d43ff0c18 158 assert(pin < 32U);
mbed_official 324:406fd2029f23 159 BW_PORT_PCRn_SRE(baseAddr, pin, rateSelect);
mbed_official 146:f64d43ff0c18 160 }
mbed_official 146:f64d43ff0c18 161
mbed_official 146:f64d43ff0c18 162 /*!
mbed_official 146:f64d43ff0c18 163 * @brief Configures the passive filter if the pin is used as a digital input.
mbed_official 146:f64d43ff0c18 164 *
mbed_official 146:f64d43ff0c18 165 * If enabled, a low pass filter (10 MHz to 30 MHz bandwidth) is enabled
mbed_official 146:f64d43ff0c18 166 * on the digital input path. Disable the Passive Input Filter when supporting
mbed_official 146:f64d43ff0c18 167 * high speed interfaces (> 2 MHz) on the pin.
mbed_official 146:f64d43ff0c18 168 *
mbed_official 324:406fd2029f23 169 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 170 * @param pin port pin number
mbed_official 146:f64d43ff0c18 171 * @param isPassiveFilterEnabled passive filter configuration
mbed_official 146:f64d43ff0c18 172 * - false: passive filter is disabled.
mbed_official 146:f64d43ff0c18 173 * - true : passive filter is enabled.
mbed_official 146:f64d43ff0c18 174 */
mbed_official 324:406fd2029f23 175 static inline void PORT_HAL_SetPassiveFilterCmd(uint32_t baseAddr,
mbed_official 146:f64d43ff0c18 176 uint32_t pin,
mbed_official 146:f64d43ff0c18 177 bool isPassiveFilterEnabled)
mbed_official 146:f64d43ff0c18 178 {
mbed_official 146:f64d43ff0c18 179 assert(pin < 32U);
mbed_official 324:406fd2029f23 180 BW_PORT_PCRn_PFE(baseAddr, pin, isPassiveFilterEnabled);
mbed_official 146:f64d43ff0c18 181 }
mbed_official 146:f64d43ff0c18 182
mbed_official 146:f64d43ff0c18 183 #if FSL_FEATURE_PORT_HAS_OPEN_DRAIN
mbed_official 146:f64d43ff0c18 184 /*!
mbed_official 146:f64d43ff0c18 185 * @brief Enables or disables the open drain.
mbed_official 146:f64d43ff0c18 186 *
mbed_official 324:406fd2029f23 187 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 188 * @param pin port pin number
mbed_official 146:f64d43ff0c18 189 * @param isOpenDrainEnabled enable open drain or not
mbed_official 146:f64d43ff0c18 190 * - false: Open Drain output is disabled on the corresponding pin.
mbed_official 146:f64d43ff0c18 191 * - true : Open Drain output is disabled on the corresponding pin.
mbed_official 146:f64d43ff0c18 192 */
mbed_official 324:406fd2029f23 193 static inline void PORT_HAL_SetOpenDrainCmd(uint32_t baseAddr,
mbed_official 146:f64d43ff0c18 194 uint32_t pin,
mbed_official 146:f64d43ff0c18 195 bool isOpenDrainEnabled)
mbed_official 146:f64d43ff0c18 196 {
mbed_official 146:f64d43ff0c18 197 assert(pin < 32U);
mbed_official 324:406fd2029f23 198 BW_PORT_PCRn_ODE(baseAddr, pin, isOpenDrainEnabled);
mbed_official 146:f64d43ff0c18 199 }
mbed_official 146:f64d43ff0c18 200 #endif /*FSL_FEATURE_PORT_HAS_OPEN_DRAIN*/
mbed_official 146:f64d43ff0c18 201
mbed_official 146:f64d43ff0c18 202 /*!
mbed_official 146:f64d43ff0c18 203 * @brief Configures the drive strength if the pin is used as a digital output.
mbed_official 146:f64d43ff0c18 204 *
mbed_official 324:406fd2029f23 205 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 206 * @param pin port pin number
mbed_official 146:f64d43ff0c18 207 * @param driveSelect drive strength selection
mbed_official 146:f64d43ff0c18 208 * - kLowDriveStrength : low drive strength is configured.
mbed_official 146:f64d43ff0c18 209 * - kHighDriveStrength: high drive strength is configured.
mbed_official 146:f64d43ff0c18 210 */
mbed_official 324:406fd2029f23 211 static inline void PORT_HAL_SetDriveStrengthMode(uint32_t baseAddr,
mbed_official 146:f64d43ff0c18 212 uint32_t pin,
mbed_official 146:f64d43ff0c18 213 port_drive_strength_t driveSelect)
mbed_official 146:f64d43ff0c18 214 {
mbed_official 146:f64d43ff0c18 215 assert(pin < 32U);
mbed_official 324:406fd2029f23 216 BW_PORT_PCRn_DSE(baseAddr, pin, driveSelect);
mbed_official 146:f64d43ff0c18 217 }
mbed_official 146:f64d43ff0c18 218
mbed_official 146:f64d43ff0c18 219 /*!
mbed_official 146:f64d43ff0c18 220 * @brief Configures the pin muxing.
mbed_official 146:f64d43ff0c18 221 *
mbed_official 324:406fd2029f23 222 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 223 * @param pin port pin number
mbed_official 146:f64d43ff0c18 224 * @param mux pin muxing slot selection
mbed_official 146:f64d43ff0c18 225 * - kPinDisabled: Pin disabled.
mbed_official 146:f64d43ff0c18 226 * - kMuxAsGpio : Set as GPIO.
mbed_official 146:f64d43ff0c18 227 * - others : chip-specific.
mbed_official 146:f64d43ff0c18 228 */
mbed_official 324:406fd2029f23 229 static inline void PORT_HAL_SetMuxMode(uint32_t baseAddr, uint32_t pin, port_mux_t mux)
mbed_official 146:f64d43ff0c18 230 {
mbed_official 146:f64d43ff0c18 231 assert(pin < 32U);
mbed_official 324:406fd2029f23 232 BW_PORT_PCRn_MUX(baseAddr, pin, mux);
mbed_official 146:f64d43ff0c18 233 }
mbed_official 146:f64d43ff0c18 234
mbed_official 146:f64d43ff0c18 235 #if FSL_FEATURE_PORT_HAS_PIN_CONTROL_LOCK
mbed_official 146:f64d43ff0c18 236 /*!
mbed_official 146:f64d43ff0c18 237 * @brief Locks or unlocks the pin control register bits[15:0].
mbed_official 146:f64d43ff0c18 238 *
mbed_official 324:406fd2029f23 239 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 240 * @param pin port pin number
mbed_official 146:f64d43ff0c18 241 * @param isPinLockEnabled lock pin control register or not
mbed_official 146:f64d43ff0c18 242 * - false: pin control register bit[15:0] are not locked.
mbed_official 146:f64d43ff0c18 243 * - true : pin control register bit[15:0] are locked, cannot be updated till system reset.
mbed_official 146:f64d43ff0c18 244 */
mbed_official 324:406fd2029f23 245 static inline void PORT_HAL_SetPinCtrlLockCmd(uint32_t baseAddr,
mbed_official 146:f64d43ff0c18 246 uint32_t pin,
mbed_official 146:f64d43ff0c18 247 bool isPinLockEnabled)
mbed_official 146:f64d43ff0c18 248 {
mbed_official 146:f64d43ff0c18 249 assert(pin < 32U);
mbed_official 324:406fd2029f23 250 BW_PORT_PCRn_LK(baseAddr, pin, isPinLockEnabled);
mbed_official 146:f64d43ff0c18 251 }
mbed_official 146:f64d43ff0c18 252 #endif /* FSL_FEATURE_PORT_HAS_PIN_CONTROL_LOCK*/
mbed_official 146:f64d43ff0c18 253
mbed_official 146:f64d43ff0c18 254 #if FSL_FEATURE_PORT_HAS_DIGITAL_FILTER
mbed_official 146:f64d43ff0c18 255 /*!
mbed_official 146:f64d43ff0c18 256 * @brief Enables or disables the digital filter in one single port.
mbed_official 146:f64d43ff0c18 257 * Each bit of the 32-bit register represents one pin.
mbed_official 146:f64d43ff0c18 258 *
mbed_official 324:406fd2029f23 259 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 260 * @param pin port pin number
mbed_official 146:f64d43ff0c18 261 * @param isDigitalFilterEnabled digital filter enable/disable
mbed_official 146:f64d43ff0c18 262 * - false: digital filter is disabled on the corresponding pin.
mbed_official 146:f64d43ff0c18 263 * - true : digital filter is enabled on the corresponding pin.
mbed_official 146:f64d43ff0c18 264 */
mbed_official 324:406fd2029f23 265 static inline void PORT_HAL_SetDigitalFilterCmd(uint32_t baseAddr,
mbed_official 146:f64d43ff0c18 266 uint32_t pin,
mbed_official 146:f64d43ff0c18 267 bool isDigitalFilterEnabled)
mbed_official 146:f64d43ff0c18 268 {
mbed_official 146:f64d43ff0c18 269 assert(pin < 32U);
mbed_official 324:406fd2029f23 270 HW_PORT_DFER_SET(baseAddr, (uint32_t)isDigitalFilterEnabled << pin);
mbed_official 146:f64d43ff0c18 271 }
mbed_official 146:f64d43ff0c18 272
mbed_official 146:f64d43ff0c18 273 /*!
mbed_official 146:f64d43ff0c18 274 * @brief Configures the clock source for the digital input filters. Changing the filter clock source should
mbed_official 146:f64d43ff0c18 275 * only be done after disabling all enabled filters. Every pin in one port uses the same
mbed_official 146:f64d43ff0c18 276 * clock source.
mbed_official 146:f64d43ff0c18 277 *
mbed_official 324:406fd2029f23 278 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 279 * @param clockSource chose which clock source to use for current port
mbed_official 146:f64d43ff0c18 280 * - kBusClock: digital filters are clocked by the bus clock.
mbed_official 146:f64d43ff0c18 281 * - kLPOClock: digital filters are clocked by the 1 kHz LPO clock.
mbed_official 146:f64d43ff0c18 282 */
mbed_official 324:406fd2029f23 283 static inline void PORT_HAL_SetDigitalFilterClock(uint32_t baseAddr,
mbed_official 146:f64d43ff0c18 284 port_digital_filter_clock_source_t clockSource)
mbed_official 146:f64d43ff0c18 285 {
mbed_official 324:406fd2029f23 286 HW_PORT_DFCR_WR(baseAddr, clockSource);
mbed_official 146:f64d43ff0c18 287 }
mbed_official 146:f64d43ff0c18 288
mbed_official 146:f64d43ff0c18 289 /*!
mbed_official 324:406fd2029f23 290 * @brief Configures the maximum size of the glitches (in clock cycles) that the digital filter absorbs
mbed_official 146:f64d43ff0c18 291 * for enabled digital filters. Glitches that are longer than this register setting
mbed_official 146:f64d43ff0c18 292 * (in clock cycles) pass through the digital filter, while glitches that are equal
mbed_official 146:f64d43ff0c18 293 * to or less than this register setting (in clock cycles) are filtered. Changing the
mbed_official 146:f64d43ff0c18 294 * filter length should only be done after disabling all enabled filters.
mbed_official 146:f64d43ff0c18 295 *
mbed_official 324:406fd2029f23 296 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 297 * @param width configure digital filter width (should be less than 5 bits).
mbed_official 146:f64d43ff0c18 298 */
mbed_official 324:406fd2029f23 299 static inline void PORT_HAL_SetDigitalFilterWidth(uint32_t baseAddr, uint8_t width)
mbed_official 146:f64d43ff0c18 300 {
mbed_official 324:406fd2029f23 301 HW_PORT_DFWR_WR(baseAddr, width);
mbed_official 146:f64d43ff0c18 302 }
mbed_official 146:f64d43ff0c18 303 #endif /* FSL_FEATURE_PORT_HAS_DIGITAL_FILTER*/
mbed_official 146:f64d43ff0c18 304
mbed_official 146:f64d43ff0c18 305 /*!
mbed_official 324:406fd2029f23 306 * @brief Configures the low half of the pin control register for the same settings.
mbed_official 146:f64d43ff0c18 307 * This function operates pin 0 -15 of one specific port.
mbed_official 146:f64d43ff0c18 308 *
mbed_official 324:406fd2029f23 309 * @param baseAddr port base address
mbed_official 324:406fd2029f23 310 * @param lowPinSelect update corresponding pin control register or not. For a specific bit:
mbed_official 146:f64d43ff0c18 311 * - 0: corresponding low half of pin control register won't be updated according to configuration.
mbed_official 146:f64d43ff0c18 312 * - 1: corresponding low half of pin control register will be updated according to configuration.
mbed_official 146:f64d43ff0c18 313 * @param config value is written to a low half port control register bits[15:0].
mbed_official 146:f64d43ff0c18 314 */
mbed_official 324:406fd2029f23 315 void PORT_HAL_SetLowGlobalPinCtrl(uint32_t baseAddr, uint16_t lowPinSelect, uint16_t config);
mbed_official 146:f64d43ff0c18 316
mbed_official 146:f64d43ff0c18 317 /*!
mbed_official 146:f64d43ff0c18 318 * @brief Configures the high half of pin control register for the same settings.
mbed_official 146:f64d43ff0c18 319 * This function operates pin 16 -31 of one specific port.
mbed_official 146:f64d43ff0c18 320 *
mbed_official 324:406fd2029f23 321 * @param baseAddr port base address
mbed_official 324:406fd2029f23 322 * @param highPinSelect update corresponding pin control register or not. For a specific bit:
mbed_official 146:f64d43ff0c18 323 * - 0: corresponding high half of pin control register won't be updated according to configuration.
mbed_official 146:f64d43ff0c18 324 * - 1: corresponding high half of pin control register will be updated according to configuration.
mbed_official 146:f64d43ff0c18 325 * @param config value is written to a high half port control register bits[15:0].
mbed_official 146:f64d43ff0c18 326 */
mbed_official 324:406fd2029f23 327 void PORT_HAL_SetHighGlobalPinCtrl(uint32_t baseAddr, uint16_t highPinSelect, uint16_t config);
mbed_official 146:f64d43ff0c18 328
mbed_official 146:f64d43ff0c18 329 /*@}*/
mbed_official 146:f64d43ff0c18 330
mbed_official 146:f64d43ff0c18 331 /*!
mbed_official 146:f64d43ff0c18 332 * @name Interrupt
mbed_official 146:f64d43ff0c18 333 * @{
mbed_official 146:f64d43ff0c18 334 */
mbed_official 146:f64d43ff0c18 335
mbed_official 146:f64d43ff0c18 336 /*!
mbed_official 146:f64d43ff0c18 337 * @brief Configures the port pin interrupt/DMA request.
mbed_official 146:f64d43ff0c18 338 *
mbed_official 324:406fd2029f23 339 * @param baseAddr port base address.
mbed_official 146:f64d43ff0c18 340 * @param pin port pin number
mbed_official 146:f64d43ff0c18 341 * @param intConfig interrupt configuration
mbed_official 146:f64d43ff0c18 342 * - kIntDisabled : Interrupt/DMA request disabled.
mbed_official 146:f64d43ff0c18 343 * - kDmaRisingEdge : DMA request on rising edge.
mbed_official 146:f64d43ff0c18 344 * - kDmaFallingEdge: DMA request on falling edge.
mbed_official 146:f64d43ff0c18 345 * - kDmaEitherEdge : DMA request on either edge.
mbed_official 146:f64d43ff0c18 346 * - KIntLogicZero : Interrupt when logic zero.
mbed_official 146:f64d43ff0c18 347 * - KIntRisingEdge : Interrupt on rising edge.
mbed_official 146:f64d43ff0c18 348 * - KIntFallingEdge: Interrupt on falling edge.
mbed_official 146:f64d43ff0c18 349 * - KIntEitherEdge : Interrupt on either edge.
mbed_official 146:f64d43ff0c18 350 * - KIntLogicOne : Interrupt when logic one.
mbed_official 146:f64d43ff0c18 351 */
mbed_official 324:406fd2029f23 352 static inline void PORT_HAL_SetPinIntMode(uint32_t baseAddr,
mbed_official 324:406fd2029f23 353 uint32_t pin,
mbed_official 324:406fd2029f23 354 port_interrupt_config_t intConfig)
mbed_official 146:f64d43ff0c18 355 {
mbed_official 146:f64d43ff0c18 356 assert(pin < 32U);
mbed_official 324:406fd2029f23 357 BW_PORT_PCRn_IRQC(baseAddr, pin, intConfig);
mbed_official 146:f64d43ff0c18 358 }
mbed_official 146:f64d43ff0c18 359
mbed_official 146:f64d43ff0c18 360 /*!
mbed_official 146:f64d43ff0c18 361 * @brief Gets the current port pin interrupt/DMA request configuration.
mbed_official 146:f64d43ff0c18 362 *
mbed_official 324:406fd2029f23 363 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 364 * @param pin port pin number
mbed_official 146:f64d43ff0c18 365 * @return interrupt configuration
mbed_official 146:f64d43ff0c18 366 * - kIntDisabled : Interrupt/DMA request disabled.
mbed_official 146:f64d43ff0c18 367 * - kDmaRisingEdge : DMA request on rising edge.
mbed_official 146:f64d43ff0c18 368 * - kDmaFallingEdge: DMA request on falling edge.
mbed_official 146:f64d43ff0c18 369 * - kDmaEitherEdge : DMA request on either edge.
mbed_official 146:f64d43ff0c18 370 * - KIntLogicZero : Interrupt when logic zero.
mbed_official 146:f64d43ff0c18 371 * - KIntRisingEdge : Interrupt on rising edge.
mbed_official 146:f64d43ff0c18 372 * - KIntFallingEdge: Interrupt on falling edge.
mbed_official 146:f64d43ff0c18 373 * - KIntEitherEdge : Interrupt on either edge.
mbed_official 146:f64d43ff0c18 374 * - KIntLogicOne : Interrupt when logic one.
mbed_official 146:f64d43ff0c18 375 */
mbed_official 324:406fd2029f23 376 static inline port_interrupt_config_t PORT_HAL_GetPinIntMode(uint32_t baseAddr, uint32_t pin)
mbed_official 146:f64d43ff0c18 377 {
mbed_official 146:f64d43ff0c18 378 assert(pin < 32U);
mbed_official 324:406fd2029f23 379 return (port_interrupt_config_t)BR_PORT_PCRn_IRQC(baseAddr, pin);
mbed_official 146:f64d43ff0c18 380 }
mbed_official 146:f64d43ff0c18 381
mbed_official 146:f64d43ff0c18 382 /*!
mbed_official 146:f64d43ff0c18 383 * @brief Reads the individual pin-interrupt status flag.
mbed_official 146:f64d43ff0c18 384 *
mbed_official 146:f64d43ff0c18 385 * If a pin is configured to generate the DMA request, the corresponding flag
mbed_official 146:f64d43ff0c18 386 * is cleared automatically at the completion of the requested DMA transfer.
mbed_official 146:f64d43ff0c18 387 * Otherwise, the flag remains set until a logic one is written to that flag.
mbed_official 146:f64d43ff0c18 388 * If configured for a level sensitive interrupt that remains asserted, the flag
mbed_official 146:f64d43ff0c18 389 * is set again immediately.
mbed_official 146:f64d43ff0c18 390 *
mbed_official 324:406fd2029f23 391 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 392 * @param pin port pin number
mbed_official 146:f64d43ff0c18 393 * @return current pin interrupt status flag
mbed_official 146:f64d43ff0c18 394 * - 0: interrupt is not detected.
mbed_official 146:f64d43ff0c18 395 * - 1: interrupt is detected.
mbed_official 146:f64d43ff0c18 396 */
mbed_official 324:406fd2029f23 397 static inline bool PORT_HAL_IsPinIntPending(uint32_t baseAddr, uint32_t pin)
mbed_official 146:f64d43ff0c18 398 {
mbed_official 146:f64d43ff0c18 399 assert(pin < 32U);
mbed_official 324:406fd2029f23 400 return BR_PORT_PCRn_ISF(baseAddr, pin);
mbed_official 146:f64d43ff0c18 401 }
mbed_official 146:f64d43ff0c18 402
mbed_official 146:f64d43ff0c18 403 /*!
mbed_official 146:f64d43ff0c18 404 * @brief Clears the individual pin-interrupt status flag.
mbed_official 146:f64d43ff0c18 405 *
mbed_official 324:406fd2029f23 406 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 407 * @param pin port pin number
mbed_official 146:f64d43ff0c18 408 */
mbed_official 324:406fd2029f23 409 static inline void PORT_HAL_ClearPinIntFlag(uint32_t baseAddr, uint32_t pin)
mbed_official 146:f64d43ff0c18 410 {
mbed_official 146:f64d43ff0c18 411 assert(pin < 32U);
mbed_official 324:406fd2029f23 412 BW_PORT_PCRn_ISF(baseAddr, pin, 1U);
mbed_official 146:f64d43ff0c18 413 }
mbed_official 146:f64d43ff0c18 414
mbed_official 146:f64d43ff0c18 415 /*!
mbed_official 146:f64d43ff0c18 416 * @brief Reads the entire port interrupt status flag.
mbed_official 146:f64d43ff0c18 417 *
mbed_official 324:406fd2029f23 418 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 419 * @return all 32 pin interrupt status flags. For specific bit:
mbed_official 146:f64d43ff0c18 420 * - 0: interrupt is not detected.
mbed_official 146:f64d43ff0c18 421 * - 1: interrupt is detected.
mbed_official 146:f64d43ff0c18 422 */
mbed_official 324:406fd2029f23 423 static inline uint32_t PORT_HAL_GetPortIntFlag(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 424 {
mbed_official 324:406fd2029f23 425 return HW_PORT_ISFR_RD(baseAddr);
mbed_official 146:f64d43ff0c18 426 }
mbed_official 146:f64d43ff0c18 427
mbed_official 146:f64d43ff0c18 428 /*!
mbed_official 146:f64d43ff0c18 429 * @brief Clears the entire port interrupt status flag.
mbed_official 146:f64d43ff0c18 430 *
mbed_official 324:406fd2029f23 431 * @param baseAddr port base address
mbed_official 146:f64d43ff0c18 432 */
mbed_official 324:406fd2029f23 433 static inline void PORT_HAL_ClearPortIntFlag(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 434 {
mbed_official 324:406fd2029f23 435 HW_PORT_ISFR_WR(baseAddr, ~0U);
mbed_official 146:f64d43ff0c18 436 }
mbed_official 146:f64d43ff0c18 437
mbed_official 146:f64d43ff0c18 438 /*@}*/
mbed_official 146:f64d43ff0c18 439
mbed_official 146:f64d43ff0c18 440 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 441 }
mbed_official 146:f64d43ff0c18 442 #endif
mbed_official 146:f64d43ff0c18 443
mbed_official 146:f64d43ff0c18 444 /*! @}*/
mbed_official 146:f64d43ff0c18 445
mbed_official 146:f64d43ff0c18 446 #endif /* __FSL_PORT_HAL_H__*/
mbed_official 146:f64d43ff0c18 447 /*******************************************************************************
mbed_official 146:f64d43ff0c18 448 * EOF
mbed_official 146:f64d43ff0c18 449 ******************************************************************************/
mbed_official 146:f64d43ff0c18 450