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 Apr 03 11:45:06 2014 +0100
Revision:
149:1fb5f62b92bd
Parent:
targets/hal/TARGET_Freescale/TARGET_KSDK_MCUS/TARGET_KSDK_CODE/hal/port/fsl_port_hal.h@146:f64d43ff0c18
Child:
324:406fd2029f23
Synchronized with git revision 220c0bb39ceee40016e1e86350c058963d01ed42

Full URL: https://github.com/mbedmicro/mbed/commit/220c0bb39ceee40016e1e86350c058963d01ed42/

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
mbed_official 146:f64d43ff0c18 48 /*! @brief Internal resistor pull feature selection*/
mbed_official 146:f64d43ff0c18 49 typedef enum _port_pull {
mbed_official 146:f64d43ff0c18 50 kPortPullDown = 0U, /*!< internal pull-down resistor is enabled.*/
mbed_official 146:f64d43ff0c18 51 kPortPullUp = 1U /*!< internal pull-up resistor is enabled.*/
mbed_official 146:f64d43ff0c18 52 } port_pull_t;
mbed_official 146:f64d43ff0c18 53
mbed_official 146:f64d43ff0c18 54 /*! @brief Slew rate selection*/
mbed_official 146:f64d43ff0c18 55 typedef enum _port_slew_rate {
mbed_official 146:f64d43ff0c18 56 kPortFastSlewRate = 0U, /*!< fast slew rate is configured.*/
mbed_official 146:f64d43ff0c18 57 kPortSlowSlewRate = 1U /*!< slow slew rate is configured.*/
mbed_official 146:f64d43ff0c18 58 } port_slew_rate_t;
mbed_official 146:f64d43ff0c18 59
mbed_official 146:f64d43ff0c18 60 /*! @brief Configures the drive strength.*/
mbed_official 146:f64d43ff0c18 61 typedef enum _port_drive_strength {
mbed_official 146:f64d43ff0c18 62 kPortLowDriveStrength = 0U, /*!< low drive strength is configured.*/
mbed_official 146:f64d43ff0c18 63 kPortHighDriveStrength = 1U /*!< high drive strength is configured.*/
mbed_official 146:f64d43ff0c18 64 } port_drive_strength_t;
mbed_official 146:f64d43ff0c18 65
mbed_official 146:f64d43ff0c18 66 /*! @brief Pin mux selection*/
mbed_official 146:f64d43ff0c18 67 typedef enum _port_mux {
mbed_official 146:f64d43ff0c18 68 kPortPinDisabled = 0U, /*!< corresponding pin is disabled as analog.*/
mbed_official 146:f64d43ff0c18 69 kPortMuxAsGpio = 1U, /*!< corresponding pin is configured as GPIO.*/
mbed_official 146:f64d43ff0c18 70 kPortMuxAlt2 = 2U, /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 71 kPortMuxAlt3 = 3U, /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 72 kPortMuxAlt4 = 4U, /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 73 kPortMuxAlt5 = 5U, /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 74 kPortMuxAlt6 = 6U, /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 75 kPortMuxAlt7 = 7U /*!< chip-specific*/
mbed_official 146:f64d43ff0c18 76 } port_mux_t;
mbed_official 146:f64d43ff0c18 77
mbed_official 146:f64d43ff0c18 78 /*! @brief Digital filter clock source selection*/
mbed_official 146:f64d43ff0c18 79 #if FSL_FEATURE_PORT_HAS_DIGITAL_FILTER
mbed_official 146:f64d43ff0c18 80 typedef enum _port_digital_filter_clock_source {
mbed_official 146:f64d43ff0c18 81 kPortBusClock = 0U, /*!< Digital filters are clocked by the bus clock.*/
mbed_official 146:f64d43ff0c18 82 kPortLPOClock = 1U /*!< Digital filters are clocked by the 1 kHz LPO clock.*/
mbed_official 146:f64d43ff0c18 83 } port_digital_filter_clock_source_t;
mbed_official 146:f64d43ff0c18 84 #endif
mbed_official 146:f64d43ff0c18 85
mbed_official 146:f64d43ff0c18 86 /*! @brief Configures the interrupt generation condition.*/
mbed_official 146:f64d43ff0c18 87 typedef enum _port_interrupt_config {
mbed_official 146:f64d43ff0c18 88 kPortIntDisabled = 0x0U, /*!< Interrupt/DMA request is disabled.*/
mbed_official 146:f64d43ff0c18 89 kPortDmaRisingEdge = 0x1U, /*!< DMA request on rising edge.*/
mbed_official 146:f64d43ff0c18 90 kPortDmaFallingEdge = 0x2U, /*!< DMA request on falling edge.*/
mbed_official 146:f64d43ff0c18 91 kPortDmaEitherEdge = 0x3U, /*!< DMA request on either edge.*/
mbed_official 146:f64d43ff0c18 92 kPortIntLogicZero = 0x8U, /*!< Interrupt when logic zero. */
mbed_official 146:f64d43ff0c18 93 kPortIntRisingEdge = 0x9U, /*!< Interrupt on rising edge. */
mbed_official 146:f64d43ff0c18 94 kPortIntFallingEdge = 0xAU, /*!< Interrupt on falling edge. */
mbed_official 146:f64d43ff0c18 95 kPortIntEitherEdge = 0xBU, /*!< Interrupt on either edge. */
mbed_official 146:f64d43ff0c18 96 kPortIntLogicOne = 0xCU /*!< Interrupt when logic one. */
mbed_official 146:f64d43ff0c18 97 } port_interrupt_config_t;
mbed_official 146:f64d43ff0c18 98
mbed_official 146:f64d43ff0c18 99 /*******************************************************************************
mbed_official 146:f64d43ff0c18 100 * API
mbed_official 146:f64d43ff0c18 101 ******************************************************************************/
mbed_official 146:f64d43ff0c18 102
mbed_official 146:f64d43ff0c18 103 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 104 extern "C" {
mbed_official 146:f64d43ff0c18 105 #endif
mbed_official 146:f64d43ff0c18 106
mbed_official 146:f64d43ff0c18 107 /*!
mbed_official 146:f64d43ff0c18 108 * @name Configuration
mbed_official 146:f64d43ff0c18 109 * @{
mbed_official 146:f64d43ff0c18 110 */
mbed_official 146:f64d43ff0c18 111
mbed_official 146:f64d43ff0c18 112 /*!
mbed_official 146:f64d43ff0c18 113 * @brief Selects the internal resistor as pull-down or pull-up.
mbed_official 146:f64d43ff0c18 114 *
mbed_official 146:f64d43ff0c18 115 * Pull configuration is valid in all digital pin muxing modes.
mbed_official 146:f64d43ff0c18 116 *
mbed_official 146:f64d43ff0c18 117 * @param instance port instance number.
mbed_official 146:f64d43ff0c18 118 * @param pin port pin number
mbed_official 146:f64d43ff0c18 119 * @param pullSelect internal resistor pull feature selection
mbed_official 146:f64d43ff0c18 120 * - kPortPullDown: internal pull-down resistor is enabled.
mbed_official 146:f64d43ff0c18 121 * - kPortPullUp : internal pull-up resistor is enabled.
mbed_official 146:f64d43ff0c18 122 */
mbed_official 146:f64d43ff0c18 123 static inline void port_hal_pull_select(uint32_t instance,
mbed_official 146:f64d43ff0c18 124 uint32_t pin,
mbed_official 146:f64d43ff0c18 125 port_pull_t pullSelect)
mbed_official 146:f64d43ff0c18 126 {
mbed_official 146:f64d43ff0c18 127 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 128 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 129 BW_PORT_PCRn_PS(instance, pin, pullSelect);
mbed_official 146:f64d43ff0c18 130 }
mbed_official 146:f64d43ff0c18 131
mbed_official 146:f64d43ff0c18 132 /*!
mbed_official 146:f64d43ff0c18 133 * @brief Enables or disables the internal pull resistor.
mbed_official 146:f64d43ff0c18 134 *
mbed_official 146:f64d43ff0c18 135 * @param instance port instance number
mbed_official 146:f64d43ff0c18 136 * @param pin port pin number
mbed_official 146:f64d43ff0c18 137 * @param isPullEnabled internal pull resistor enable or disable
mbed_official 146:f64d43ff0c18 138 * - true : internal pull resistor is enabled.
mbed_official 146:f64d43ff0c18 139 * - false: internal pull resistor is disabled.
mbed_official 146:f64d43ff0c18 140 */
mbed_official 146:f64d43ff0c18 141 static inline void port_hal_configure_pull(uint32_t instance, uint32_t pin, bool isPullEnabled)
mbed_official 146:f64d43ff0c18 142 {
mbed_official 146:f64d43ff0c18 143 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 144 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 145 BW_PORT_PCRn_PE(instance, pin, isPullEnabled);
mbed_official 146:f64d43ff0c18 146 }
mbed_official 146:f64d43ff0c18 147
mbed_official 146:f64d43ff0c18 148 /*!
mbed_official 146:f64d43ff0c18 149 * @brief Configures the fast/slow slew rate if the pin is used as a digital output.
mbed_official 146:f64d43ff0c18 150 *
mbed_official 146:f64d43ff0c18 151 * @param instance port instance number
mbed_official 146:f64d43ff0c18 152 * @param pin port pin number
mbed_official 146:f64d43ff0c18 153 * @param rateSelect slew rate selection
mbed_official 146:f64d43ff0c18 154 * - kPortFastSlewRate: fast slew rate is configured.
mbed_official 146:f64d43ff0c18 155 * - kPortSlowSlewRate: slow slew rate is configured.
mbed_official 146:f64d43ff0c18 156 */
mbed_official 146:f64d43ff0c18 157 static inline void port_hal_configure_slew_rate(uint32_t instance,
mbed_official 146:f64d43ff0c18 158 uint32_t pin,
mbed_official 146:f64d43ff0c18 159 port_slew_rate_t rateSelect)
mbed_official 146:f64d43ff0c18 160 {
mbed_official 146:f64d43ff0c18 161 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 162 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 163 BW_PORT_PCRn_SRE(instance, pin, rateSelect);
mbed_official 146:f64d43ff0c18 164 }
mbed_official 146:f64d43ff0c18 165
mbed_official 146:f64d43ff0c18 166 /*!
mbed_official 146:f64d43ff0c18 167 * @brief Configures the passive filter if the pin is used as a digital input.
mbed_official 146:f64d43ff0c18 168 *
mbed_official 146:f64d43ff0c18 169 * If enabled, a low pass filter (10 MHz to 30 MHz bandwidth) is enabled
mbed_official 146:f64d43ff0c18 170 * on the digital input path. Disable the Passive Input Filter when supporting
mbed_official 146:f64d43ff0c18 171 * high speed interfaces (> 2 MHz) on the pin.
mbed_official 146:f64d43ff0c18 172 *
mbed_official 146:f64d43ff0c18 173 * @param instance port instance number
mbed_official 146:f64d43ff0c18 174 * @param pin port pin number
mbed_official 146:f64d43ff0c18 175 * @param isPassiveFilterEnabled passive filter configuration
mbed_official 146:f64d43ff0c18 176 * - false: passive filter is disabled.
mbed_official 146:f64d43ff0c18 177 * - true : passive filter is enabled.
mbed_official 146:f64d43ff0c18 178 */
mbed_official 146:f64d43ff0c18 179 static inline void port_hal_configure_passive_filter(uint32_t instance,
mbed_official 146:f64d43ff0c18 180 uint32_t pin,
mbed_official 146:f64d43ff0c18 181 bool isPassiveFilterEnabled)
mbed_official 146:f64d43ff0c18 182 {
mbed_official 146:f64d43ff0c18 183 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 184 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 185 BW_PORT_PCRn_PFE(instance, pin, isPassiveFilterEnabled);
mbed_official 146:f64d43ff0c18 186 }
mbed_official 146:f64d43ff0c18 187
mbed_official 146:f64d43ff0c18 188 #if FSL_FEATURE_PORT_HAS_OPEN_DRAIN
mbed_official 146:f64d43ff0c18 189 /*!
mbed_official 146:f64d43ff0c18 190 * @brief Enables or disables the open drain.
mbed_official 146:f64d43ff0c18 191 *
mbed_official 146:f64d43ff0c18 192 * @param instance port instance number
mbed_official 146:f64d43ff0c18 193 * @param pin port pin number
mbed_official 146:f64d43ff0c18 194 * @param isOpenDrainEnabled enable open drain or not
mbed_official 146:f64d43ff0c18 195 * - false: Open Drain output is disabled on the corresponding pin.
mbed_official 146:f64d43ff0c18 196 * - true : Open Drain output is disabled on the corresponding pin.
mbed_official 146:f64d43ff0c18 197 */
mbed_official 146:f64d43ff0c18 198 static inline void port_hal_configure_open_drain(uint32_t instance,
mbed_official 146:f64d43ff0c18 199 uint32_t pin,
mbed_official 146:f64d43ff0c18 200 bool isOpenDrainEnabled)
mbed_official 146:f64d43ff0c18 201 {
mbed_official 146:f64d43ff0c18 202 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 203 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 204 BW_PORT_PCRn_ODE(instance, pin, isOpenDrainEnabled);
mbed_official 146:f64d43ff0c18 205 }
mbed_official 146:f64d43ff0c18 206 #endif /*FSL_FEATURE_PORT_HAS_OPEN_DRAIN*/
mbed_official 146:f64d43ff0c18 207
mbed_official 146:f64d43ff0c18 208 /*!
mbed_official 146:f64d43ff0c18 209 * @brief Configures the drive strength if the pin is used as a digital output.
mbed_official 146:f64d43ff0c18 210 *
mbed_official 146:f64d43ff0c18 211 * @param instance port instance number
mbed_official 146:f64d43ff0c18 212 * @param pin port pin number
mbed_official 146:f64d43ff0c18 213 * @param driveSelect drive strength selection
mbed_official 146:f64d43ff0c18 214 * - kLowDriveStrength : low drive strength is configured.
mbed_official 146:f64d43ff0c18 215 * - kHighDriveStrength: high drive strength is configured.
mbed_official 146:f64d43ff0c18 216 */
mbed_official 146:f64d43ff0c18 217 static inline void port_hal_configure_drive_strength(uint32_t instance,
mbed_official 146:f64d43ff0c18 218 uint32_t pin,
mbed_official 146:f64d43ff0c18 219 port_drive_strength_t driveSelect)
mbed_official 146:f64d43ff0c18 220 {
mbed_official 146:f64d43ff0c18 221 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 222 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 223 BW_PORT_PCRn_DSE(instance, pin, driveSelect);
mbed_official 146:f64d43ff0c18 224 }
mbed_official 146:f64d43ff0c18 225
mbed_official 146:f64d43ff0c18 226 /*!
mbed_official 146:f64d43ff0c18 227 * @brief Configures the pin muxing.
mbed_official 146:f64d43ff0c18 228 *
mbed_official 146:f64d43ff0c18 229 * @param instance port instance number
mbed_official 146:f64d43ff0c18 230 * @param pin port pin number
mbed_official 146:f64d43ff0c18 231 * @param mux pin muxing slot selection
mbed_official 146:f64d43ff0c18 232 * - kPinDisabled: Pin disabled.
mbed_official 146:f64d43ff0c18 233 * - kMuxAsGpio : Set as GPIO.
mbed_official 146:f64d43ff0c18 234 * - others : chip-specific.
mbed_official 146:f64d43ff0c18 235 */
mbed_official 146:f64d43ff0c18 236 static inline void port_hal_mux_control(uint32_t instance, uint32_t pin, port_mux_t mux)
mbed_official 146:f64d43ff0c18 237 {
mbed_official 146:f64d43ff0c18 238 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 239 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 240 BW_PORT_PCRn_MUX(instance, pin, mux);
mbed_official 146:f64d43ff0c18 241 }
mbed_official 146:f64d43ff0c18 242
mbed_official 146:f64d43ff0c18 243 #if FSL_FEATURE_PORT_HAS_PIN_CONTROL_LOCK
mbed_official 146:f64d43ff0c18 244 /*!
mbed_official 146:f64d43ff0c18 245 * @brief Locks or unlocks the pin control register bits[15:0].
mbed_official 146:f64d43ff0c18 246 *
mbed_official 146:f64d43ff0c18 247 * @param instance port instance number
mbed_official 146:f64d43ff0c18 248 * @param pin port pin number
mbed_official 146:f64d43ff0c18 249 * @param isPinLockEnabled lock pin control register or not
mbed_official 146:f64d43ff0c18 250 * - false: pin control register bit[15:0] are not locked.
mbed_official 146:f64d43ff0c18 251 * - true : pin control register bit[15:0] are locked, cannot be updated till system reset.
mbed_official 146:f64d43ff0c18 252 */
mbed_official 146:f64d43ff0c18 253 static inline void port_hal_configure_pin_control_lock(uint32_t instance,
mbed_official 146:f64d43ff0c18 254 uint32_t pin,
mbed_official 146:f64d43ff0c18 255 bool isPinLockEnabled)
mbed_official 146:f64d43ff0c18 256 {
mbed_official 146:f64d43ff0c18 257 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 258 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 259 BW_PORT_PCRn_LK(instance, pin, isPinLockEnabled);
mbed_official 146:f64d43ff0c18 260 }
mbed_official 146:f64d43ff0c18 261 #endif /* FSL_FEATURE_PORT_HAS_PIN_CONTROL_LOCK*/
mbed_official 146:f64d43ff0c18 262
mbed_official 146:f64d43ff0c18 263 #if FSL_FEATURE_PORT_HAS_DIGITAL_FILTER
mbed_official 146:f64d43ff0c18 264 /*!
mbed_official 146:f64d43ff0c18 265 * @brief Enables or disables the digital filter in one single port.
mbed_official 146:f64d43ff0c18 266 * Each bit of the 32-bit register represents one pin.
mbed_official 146:f64d43ff0c18 267 *
mbed_official 146:f64d43ff0c18 268 * @param instance port instance number
mbed_official 146:f64d43ff0c18 269 * @param pin port pin number
mbed_official 146:f64d43ff0c18 270 * @param isDigitalFilterEnabled digital filter enable/disable
mbed_official 146:f64d43ff0c18 271 * - false: digital filter is disabled on the corresponding pin.
mbed_official 146:f64d43ff0c18 272 * - true : digital filter is enabled on the corresponding pin.
mbed_official 146:f64d43ff0c18 273 */
mbed_official 146:f64d43ff0c18 274 static inline void port_hal_configure_digital_filter(uint32_t instance,
mbed_official 146:f64d43ff0c18 275 uint32_t pin,
mbed_official 146:f64d43ff0c18 276 bool isDigitalFilterEnabled)
mbed_official 146:f64d43ff0c18 277 {
mbed_official 146:f64d43ff0c18 278 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 279 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 280 HW_PORT_DFER_SET(instance, (uint32_t)isDigitalFilterEnabled << pin);
mbed_official 146:f64d43ff0c18 281 }
mbed_official 146:f64d43ff0c18 282
mbed_official 146:f64d43ff0c18 283 /*!
mbed_official 146:f64d43ff0c18 284 * @brief Configures the clock source for the digital input filters. Changing the filter clock source should
mbed_official 146:f64d43ff0c18 285 * only be done after disabling all enabled filters. Every pin in one port uses the same
mbed_official 146:f64d43ff0c18 286 * clock source.
mbed_official 146:f64d43ff0c18 287 *
mbed_official 146:f64d43ff0c18 288 * @param instance port instance number
mbed_official 146:f64d43ff0c18 289 * @param clockSource chose which clock source to use for current port
mbed_official 146:f64d43ff0c18 290 * - kBusClock: digital filters are clocked by the bus clock.
mbed_official 146:f64d43ff0c18 291 * - kLPOClock: digital filters are clocked by the 1 kHz LPO clock.
mbed_official 146:f64d43ff0c18 292 */
mbed_official 146:f64d43ff0c18 293 static inline void port_hal_configure_digital_filter_clock(uint32_t instance,
mbed_official 146:f64d43ff0c18 294 port_digital_filter_clock_source_t clockSource)
mbed_official 146:f64d43ff0c18 295 {
mbed_official 146:f64d43ff0c18 296 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 297 HW_PORT_DFCR_WR(instance, clockSource);
mbed_official 146:f64d43ff0c18 298 }
mbed_official 146:f64d43ff0c18 299
mbed_official 146:f64d43ff0c18 300 /*!
mbed_official 146:f64d43ff0c18 301 * @brief Configures the maximum size of the glitches(in clock cycles) the digital filter absorbs
mbed_official 146:f64d43ff0c18 302 * for enabled digital filters. Glitches that are longer than this register setting
mbed_official 146:f64d43ff0c18 303 * (in clock cycles) pass through the digital filter, while glitches that are equal
mbed_official 146:f64d43ff0c18 304 * to or less than this register setting (in clock cycles) are filtered. Changing the
mbed_official 146:f64d43ff0c18 305 * filter length should only be done after disabling all enabled filters.
mbed_official 146:f64d43ff0c18 306 *
mbed_official 146:f64d43ff0c18 307 * @param instance port instance number
mbed_official 146:f64d43ff0c18 308 * @param width configure digital filter width (should be less than 5 bits).
mbed_official 146:f64d43ff0c18 309 */
mbed_official 146:f64d43ff0c18 310 static inline void port_hal_configure_digital_filter_width(uint32_t instance, uint8_t width)
mbed_official 146:f64d43ff0c18 311 {
mbed_official 146:f64d43ff0c18 312 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 313 HW_PORT_DFWR_WR(instance, width);
mbed_official 146:f64d43ff0c18 314 }
mbed_official 146:f64d43ff0c18 315 #endif /* FSL_FEATURE_PORT_HAS_DIGITAL_FILTER*/
mbed_official 146:f64d43ff0c18 316
mbed_official 146:f64d43ff0c18 317 /*!
mbed_official 146:f64d43ff0c18 318 * @brief Configures the low half of pin control register for the same settings.
mbed_official 146:f64d43ff0c18 319 * This function operates pin 0 -15 of one specific port.
mbed_official 146:f64d43ff0c18 320 *
mbed_official 146:f64d43ff0c18 321 * @param instance port instance number
mbed_official 146:f64d43ff0c18 322 * @param pinSelect update corresponding pin control register or not. For a specific bit:
mbed_official 146:f64d43ff0c18 323 * - 0: corresponding low half of pin control register won't be updated according to configuration.
mbed_official 146:f64d43ff0c18 324 * - 1: corresponding low half of pin control register will be updated according to configuration.
mbed_official 146:f64d43ff0c18 325 * @param config value is written to a low half port control register bits[15:0].
mbed_official 146:f64d43ff0c18 326 */
mbed_official 146:f64d43ff0c18 327 void port_hal_global_pin_control_low(uint32_t instance, uint16_t lowPinSelect, uint16_t config);
mbed_official 146:f64d43ff0c18 328
mbed_official 146:f64d43ff0c18 329 /*!
mbed_official 146:f64d43ff0c18 330 * @brief Configures the high half of pin control register for the same settings.
mbed_official 146:f64d43ff0c18 331 * This function operates pin 16 -31 of one specific port.
mbed_official 146:f64d43ff0c18 332 *
mbed_official 146:f64d43ff0c18 333 * @param instance port instance number
mbed_official 146:f64d43ff0c18 334 * @param pinSelect update corresponding pin control register or not. For a specific bit:
mbed_official 146:f64d43ff0c18 335 * - 0: corresponding high half of pin control register won't be updated according to configuration.
mbed_official 146:f64d43ff0c18 336 * - 1: corresponding high half of pin control register will be updated according to configuration.
mbed_official 146:f64d43ff0c18 337 * @param config value is written to a high half port control register bits[15:0].
mbed_official 146:f64d43ff0c18 338 */
mbed_official 146:f64d43ff0c18 339 void port_hal_global_pin_control_high(uint32_t instance, uint16_t highPinSelect, uint16_t config);
mbed_official 146:f64d43ff0c18 340
mbed_official 146:f64d43ff0c18 341 /*@}*/
mbed_official 146:f64d43ff0c18 342
mbed_official 146:f64d43ff0c18 343 /*!
mbed_official 146:f64d43ff0c18 344 * @name Interrupt
mbed_official 146:f64d43ff0c18 345 * @{
mbed_official 146:f64d43ff0c18 346 */
mbed_official 146:f64d43ff0c18 347
mbed_official 146:f64d43ff0c18 348 /*!
mbed_official 146:f64d43ff0c18 349 * @brief Configures the port pin interrupt/DMA request.
mbed_official 146:f64d43ff0c18 350 *
mbed_official 146:f64d43ff0c18 351 * @param instance port instance number.
mbed_official 146:f64d43ff0c18 352 * @param pin port pin number
mbed_official 146:f64d43ff0c18 353 * @param intConfig interrupt configuration
mbed_official 146:f64d43ff0c18 354 * - kIntDisabled : Interrupt/DMA request disabled.
mbed_official 146:f64d43ff0c18 355 * - kDmaRisingEdge : DMA request on rising edge.
mbed_official 146:f64d43ff0c18 356 * - kDmaFallingEdge: DMA request on falling edge.
mbed_official 146:f64d43ff0c18 357 * - kDmaEitherEdge : DMA request on either edge.
mbed_official 146:f64d43ff0c18 358 * - KIntLogicZero : Interrupt when logic zero.
mbed_official 146:f64d43ff0c18 359 * - KIntRisingEdge : Interrupt on rising edge.
mbed_official 146:f64d43ff0c18 360 * - KIntFallingEdge: Interrupt on falling edge.
mbed_official 146:f64d43ff0c18 361 * - KIntEitherEdge : Interrupt on either edge.
mbed_official 146:f64d43ff0c18 362 * - KIntLogicOne : Interrupt when logic one.
mbed_official 146:f64d43ff0c18 363 */
mbed_official 146:f64d43ff0c18 364 static inline void port_hal_configure_pin_interrupt(uint32_t instance,
mbed_official 146:f64d43ff0c18 365 uint32_t pin,
mbed_official 146:f64d43ff0c18 366 port_interrupt_config_t intConfig)
mbed_official 146:f64d43ff0c18 367 {
mbed_official 146:f64d43ff0c18 368 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 369 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 370 BW_PORT_PCRn_IRQC(instance, pin, intConfig);
mbed_official 146:f64d43ff0c18 371 }
mbed_official 146:f64d43ff0c18 372
mbed_official 146:f64d43ff0c18 373 /*!
mbed_official 146:f64d43ff0c18 374 * @brief Gets the current port pin interrupt/DMA request configuration.
mbed_official 146:f64d43ff0c18 375 *
mbed_official 146:f64d43ff0c18 376 * @param instance port instance number
mbed_official 146:f64d43ff0c18 377 * @param pin port pin number
mbed_official 146:f64d43ff0c18 378 * @return interrupt configuration
mbed_official 146:f64d43ff0c18 379 * - kIntDisabled : Interrupt/DMA request disabled.
mbed_official 146:f64d43ff0c18 380 * - kDmaRisingEdge : DMA request on rising edge.
mbed_official 146:f64d43ff0c18 381 * - kDmaFallingEdge: DMA request on falling edge.
mbed_official 146:f64d43ff0c18 382 * - kDmaEitherEdge : DMA request on either edge.
mbed_official 146:f64d43ff0c18 383 * - KIntLogicZero : Interrupt when logic zero.
mbed_official 146:f64d43ff0c18 384 * - KIntRisingEdge : Interrupt on rising edge.
mbed_official 146:f64d43ff0c18 385 * - KIntFallingEdge: Interrupt on falling edge.
mbed_official 146:f64d43ff0c18 386 * - KIntEitherEdge : Interrupt on either edge.
mbed_official 146:f64d43ff0c18 387 * - KIntLogicOne : Interrupt when logic one.
mbed_official 146:f64d43ff0c18 388 */
mbed_official 146:f64d43ff0c18 389 static inline port_interrupt_config_t port_hal_get_pin_interrupt_config(uint32_t instance,
mbed_official 146:f64d43ff0c18 390 uint32_t pin)
mbed_official 146:f64d43ff0c18 391 {
mbed_official 146:f64d43ff0c18 392 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 393 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 394 return (port_interrupt_config_t)BR_PORT_PCRn_IRQC(instance, pin);
mbed_official 146:f64d43ff0c18 395 }
mbed_official 146:f64d43ff0c18 396
mbed_official 146:f64d43ff0c18 397 /*!
mbed_official 146:f64d43ff0c18 398 * @brief Reads the individual pin-interrupt status flag.
mbed_official 146:f64d43ff0c18 399 *
mbed_official 146:f64d43ff0c18 400 * If a pin is configured to generate the DMA request, the corresponding flag
mbed_official 146:f64d43ff0c18 401 * is cleared automatically at the completion of the requested DMA transfer.
mbed_official 146:f64d43ff0c18 402 * Otherwise, the flag remains set until a logic one is written to that flag.
mbed_official 146:f64d43ff0c18 403 * If configured for a level sensitive interrupt that remains asserted, the flag
mbed_official 146:f64d43ff0c18 404 * is set again immediately.
mbed_official 146:f64d43ff0c18 405 *
mbed_official 146:f64d43ff0c18 406 * @param instance port instance number
mbed_official 146:f64d43ff0c18 407 * @param pin port pin number
mbed_official 146:f64d43ff0c18 408 * @return current pin interrupt status flag
mbed_official 146:f64d43ff0c18 409 * - 0: interrupt is not detected.
mbed_official 146:f64d43ff0c18 410 * - 1: interrupt is detected.
mbed_official 146:f64d43ff0c18 411 */
mbed_official 146:f64d43ff0c18 412 static inline bool port_hal_read_pin_interrupt_flag(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 413 {
mbed_official 146:f64d43ff0c18 414 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 415 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 416 return BR_PORT_PCRn_ISF(instance, pin);
mbed_official 146:f64d43ff0c18 417 }
mbed_official 146:f64d43ff0c18 418
mbed_official 146:f64d43ff0c18 419 /*!
mbed_official 146:f64d43ff0c18 420 * @brief Clears the individual pin-interrupt status flag.
mbed_official 146:f64d43ff0c18 421 *
mbed_official 146:f64d43ff0c18 422 * @param instance port instance number
mbed_official 146:f64d43ff0c18 423 * @param pin port pin number
mbed_official 146:f64d43ff0c18 424 */
mbed_official 146:f64d43ff0c18 425 static inline void port_hal_clear_pin_interrupt_flag(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 426 {
mbed_official 146:f64d43ff0c18 427 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 428 assert(pin < 32U);
mbed_official 146:f64d43ff0c18 429 BW_PORT_PCRn_ISF(instance, pin, 1U);
mbed_official 146:f64d43ff0c18 430 }
mbed_official 146:f64d43ff0c18 431
mbed_official 146:f64d43ff0c18 432 /*!
mbed_official 146:f64d43ff0c18 433 * @brief Reads the entire port interrupt status flag.
mbed_official 146:f64d43ff0c18 434 *
mbed_official 146:f64d43ff0c18 435 * @param instance port instance number
mbed_official 146:f64d43ff0c18 436 * @return all 32 pin interrupt status flags. For specific bit:
mbed_official 146:f64d43ff0c18 437 * - 0: interrupt is not detected.
mbed_official 146:f64d43ff0c18 438 * - 1: interrupt is detected.
mbed_official 146:f64d43ff0c18 439 */
mbed_official 146:f64d43ff0c18 440 static inline uint32_t port_hal_read_port_interrupt_flag(uint32_t instance)
mbed_official 146:f64d43ff0c18 441 {
mbed_official 146:f64d43ff0c18 442 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 443 return HW_PORT_ISFR_RD(instance);
mbed_official 146:f64d43ff0c18 444 }
mbed_official 146:f64d43ff0c18 445
mbed_official 146:f64d43ff0c18 446 /*!
mbed_official 146:f64d43ff0c18 447 * @brief Clears the entire port interrupt status flag.
mbed_official 146:f64d43ff0c18 448 *
mbed_official 146:f64d43ff0c18 449 * @param instance port instance number
mbed_official 146:f64d43ff0c18 450 */
mbed_official 146:f64d43ff0c18 451 static inline void port_hal_clear_port_interrupt_flag(uint32_t instance)
mbed_official 146:f64d43ff0c18 452 {
mbed_official 146:f64d43ff0c18 453 assert(instance < HW_PORT_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 454 HW_PORT_ISFR_WR(instance, ~0U);
mbed_official 146:f64d43ff0c18 455 }
mbed_official 146:f64d43ff0c18 456
mbed_official 146:f64d43ff0c18 457 /*@}*/
mbed_official 146:f64d43ff0c18 458
mbed_official 146:f64d43ff0c18 459 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 460 }
mbed_official 146:f64d43ff0c18 461 #endif
mbed_official 146:f64d43ff0c18 462
mbed_official 146:f64d43ff0c18 463 /*! @}*/
mbed_official 146:f64d43ff0c18 464
mbed_official 146:f64d43ff0c18 465 #endif /* __FSL_PORT_HAL_H__*/
mbed_official 146:f64d43ff0c18 466 /*******************************************************************************
mbed_official 146:f64d43ff0c18 467 * EOF
mbed_official 146:f64d43ff0c18 468 ******************************************************************************/
mbed_official 146:f64d43ff0c18 469