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/gpio/fsl_gpio_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_GPIO_HAL_H__
mbed_official 146:f64d43ff0c18 31 #define __FSL_GPIO_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_gpio_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 gpio_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 * @file fsl_gpio_hal.h
mbed_official 146:f64d43ff0c18 46 *
mbed_official 146:f64d43ff0c18 47 * @brief GPIO hardware driver configuration. Use these functions to set the GPIO input/output,
mbed_official 146:f64d43ff0c18 48 * set output logic or get input logic. Check the GPIO header file for instance numbers. Each
mbed_official 146:f64d43ff0c18 49 * GPIO instance has 32 pins with numbers from 0 to 31.
mbed_official 146:f64d43ff0c18 50 */
mbed_official 146:f64d43ff0c18 51
mbed_official 146:f64d43ff0c18 52 /*******************************************************************************
mbed_official 146:f64d43ff0c18 53 * Definitions
mbed_official 146:f64d43ff0c18 54 ******************************************************************************/
mbed_official 146:f64d43ff0c18 55
mbed_official 146:f64d43ff0c18 56 /*! @brief GPIO direction definition*/
mbed_official 146:f64d43ff0c18 57 typedef enum _gpio_pin_direction {
mbed_official 146:f64d43ff0c18 58 kGpioDigitalInput = 0, /*!< Set current pin as digital input*/
mbed_official 146:f64d43ff0c18 59 kGpioDigitalOutput = 1 /*!< Set current pin as digital output*/
mbed_official 146:f64d43ff0c18 60 } gpio_pin_direction_t;
mbed_official 146:f64d43ff0c18 61
mbed_official 146:f64d43ff0c18 62 /*******************************************************************************
mbed_official 146:f64d43ff0c18 63 * API
mbed_official 146:f64d43ff0c18 64 ******************************************************************************/
mbed_official 146:f64d43ff0c18 65
mbed_official 146:f64d43ff0c18 66 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 67 extern "C" {
mbed_official 146:f64d43ff0c18 68 #endif
mbed_official 146:f64d43ff0c18 69
mbed_official 146:f64d43ff0c18 70 /*!
mbed_official 146:f64d43ff0c18 71 * @name Configuration
mbed_official 146:f64d43ff0c18 72 * @{
mbed_official 146:f64d43ff0c18 73 */
mbed_official 146:f64d43ff0c18 74
mbed_official 146:f64d43ff0c18 75 /*!
mbed_official 146:f64d43ff0c18 76 * @brief Sets the individual GPIO pin to general input or output.
mbed_official 146:f64d43ff0c18 77 *
mbed_official 146:f64d43ff0c18 78 * @param instance GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 79 * @param pin GPIO port pin number
mbed_official 146:f64d43ff0c18 80 * @param direction GPIO directions
mbed_official 146:f64d43ff0c18 81 * - kGpioDigitalInput: set to input
mbed_official 146:f64d43ff0c18 82 * - kGpioDigitalOutput: set to output
mbed_official 146:f64d43ff0c18 83 */
mbed_official 146:f64d43ff0c18 84 void gpio_hal_set_pin_direction(uint32_t instance, uint32_t pin,
mbed_official 146:f64d43ff0c18 85 gpio_pin_direction_t direction);
mbed_official 146:f64d43ff0c18 86
mbed_official 146:f64d43ff0c18 87 /*!
mbed_official 146:f64d43ff0c18 88 * @brief Sets the GPIO port pins to general input or output.
mbed_official 146:f64d43ff0c18 89 *
mbed_official 146:f64d43ff0c18 90 * This function operates all 32 port pins.
mbed_official 146:f64d43ff0c18 91 *
mbed_official 146:f64d43ff0c18 92 * @param instance GPIO instance number (HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 93 * @param direction GPIO directions
mbed_official 146:f64d43ff0c18 94 * - 0: set to input
mbed_official 146:f64d43ff0c18 95 * - 1: set to output
mbed_official 146:f64d43ff0c18 96 * - LSB: pin 0
mbed_official 146:f64d43ff0c18 97 * - MSB: pin 31
mbed_official 146:f64d43ff0c18 98 */
mbed_official 146:f64d43ff0c18 99 static inline void gpio_hal_set_port_direction(uint32_t instance, uint32_t direction)
mbed_official 146:f64d43ff0c18 100 {
mbed_official 146:f64d43ff0c18 101 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 102 HW_GPIO_PDDR_SET(instance, direction);
mbed_official 146:f64d43ff0c18 103 }
mbed_official 146:f64d43ff0c18 104
mbed_official 146:f64d43ff0c18 105 /* @} */
mbed_official 146:f64d43ff0c18 106
mbed_official 146:f64d43ff0c18 107 /*!
mbed_official 146:f64d43ff0c18 108 * @name Status
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 Gets the current direction of the individual GPIO pin.
mbed_official 146:f64d43ff0c18 114 *
mbed_official 146:f64d43ff0c18 115 * @param instance GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 116 * @param pin GPIO port pin number
mbed_official 146:f64d43ff0c18 117 * @return GPIO directions
mbed_official 146:f64d43ff0c18 118 * - 0: corresponding pin is set to input.
mbed_official 146:f64d43ff0c18 119 * - 1: corresponding pin is set to output.
mbed_official 146:f64d43ff0c18 120 */
mbed_official 146:f64d43ff0c18 121 static inline uint32_t gpio_hal_get_pin_direction(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 122 {
mbed_official 146:f64d43ff0c18 123 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 124 assert(pin < 32);
mbed_official 146:f64d43ff0c18 125 return (HW_GPIO_PDDR_RD(instance) >> pin) & 1U;
mbed_official 146:f64d43ff0c18 126 }
mbed_official 146:f64d43ff0c18 127
mbed_official 146:f64d43ff0c18 128 /*!
mbed_official 146:f64d43ff0c18 129 * @brief Gets the GPIO port pins direction.
mbed_official 146:f64d43ff0c18 130 *
mbed_official 146:f64d43ff0c18 131 * This function gets all 32-pin directions as a 32-bit integer.
mbed_official 146:f64d43ff0c18 132 *
mbed_official 146:f64d43ff0c18 133 * @param instance GPIO instance number (HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 134 * @return GPIO directions. Each bit represents one pin. For each bit:
mbed_official 146:f64d43ff0c18 135 * - 0: corresponding pin is set to input
mbed_official 146:f64d43ff0c18 136 * - 1: corresponding pin is set to output
mbed_official 146:f64d43ff0c18 137 * - LSB: pin 0
mbed_official 146:f64d43ff0c18 138 * - MSB: pin 31
mbed_official 146:f64d43ff0c18 139 */
mbed_official 146:f64d43ff0c18 140 static inline uint32_t gpio_hal_get_port_direction(uint32_t instance)
mbed_official 146:f64d43ff0c18 141 {
mbed_official 146:f64d43ff0c18 142 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 143 return HW_GPIO_PDDR_RD(instance);
mbed_official 146:f64d43ff0c18 144 }
mbed_official 146:f64d43ff0c18 145
mbed_official 146:f64d43ff0c18 146 /* @} */
mbed_official 146:f64d43ff0c18 147
mbed_official 146:f64d43ff0c18 148 /*!
mbed_official 146:f64d43ff0c18 149 * @name Output Operation
mbed_official 146:f64d43ff0c18 150 * @{
mbed_official 146:f64d43ff0c18 151 */
mbed_official 146:f64d43ff0c18 152
mbed_official 146:f64d43ff0c18 153 /*!
mbed_official 146:f64d43ff0c18 154 * @brief Sets the output level of the individual GPIO pin to logic 1 or 0.
mbed_official 146:f64d43ff0c18 155 *
mbed_official 146:f64d43ff0c18 156 * @param instance GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 157 * @param pin GPIO port pin number
mbed_official 146:f64d43ff0c18 158 * @param output pin output logic level
mbed_official 146:f64d43ff0c18 159 */
mbed_official 146:f64d43ff0c18 160 void gpio_hal_write_pin_output(uint32_t instance, uint32_t pin, uint32_t output);
mbed_official 146:f64d43ff0c18 161
mbed_official 146:f64d43ff0c18 162 /*!
mbed_official 146:f64d43ff0c18 163 * @brief Reads the current pin output.
mbed_official 146:f64d43ff0c18 164 *
mbed_official 146:f64d43ff0c18 165 * @param instance GPIO instance number (HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 166 * @param pin GPIO port pin number
mbed_official 146:f64d43ff0c18 167 * @return current pin output status. 0 - Low logic, 1 - High logic
mbed_official 146:f64d43ff0c18 168 */
mbed_official 146:f64d43ff0c18 169 static inline uint32_t gpio_hal_read_pin_output(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 170 {
mbed_official 146:f64d43ff0c18 171 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 172 assert(pin < 32);
mbed_official 146:f64d43ff0c18 173 return ((HW_GPIO_PDOR_RD(instance) >> pin) && 0x1U);
mbed_official 146:f64d43ff0c18 174 }
mbed_official 146:f64d43ff0c18 175
mbed_official 146:f64d43ff0c18 176 /*!
mbed_official 146:f64d43ff0c18 177 * @brief Sets the output level of the individual GPIO pin to logic 1.
mbed_official 146:f64d43ff0c18 178 *
mbed_official 146:f64d43ff0c18 179 * @param instance GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 180 * @param pin GPIO port pin number
mbed_official 146:f64d43ff0c18 181 */
mbed_official 146:f64d43ff0c18 182 static inline void gpio_hal_set_pin_output(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 183 {
mbed_official 146:f64d43ff0c18 184 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 185 assert(pin < 32);
mbed_official 146:f64d43ff0c18 186 HW_GPIO_PSOR_WR(instance, 1U << pin);
mbed_official 146:f64d43ff0c18 187 }
mbed_official 146:f64d43ff0c18 188
mbed_official 146:f64d43ff0c18 189 /*!
mbed_official 146:f64d43ff0c18 190 * @brief Clears the output level of the individual GPIO pin to logic 0.
mbed_official 146:f64d43ff0c18 191 *
mbed_official 146:f64d43ff0c18 192 * @param instance GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 193 * @param pin GPIO port pin number
mbed_official 146:f64d43ff0c18 194 */
mbed_official 146:f64d43ff0c18 195 static inline void gpio_hal_clear_pin_output(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 196 {
mbed_official 146:f64d43ff0c18 197 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 198 assert(pin < 32);
mbed_official 146:f64d43ff0c18 199 HW_GPIO_PCOR_WR(instance, 1U << pin);
mbed_official 146:f64d43ff0c18 200 }
mbed_official 146:f64d43ff0c18 201
mbed_official 146:f64d43ff0c18 202 /*!
mbed_official 146:f64d43ff0c18 203 * @brief Reverses the current output logic of the individual GPIO pin.
mbed_official 146:f64d43ff0c18 204 *
mbed_official 146:f64d43ff0c18 205 * @param instance GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 206 * @param pin GPIO port pin number
mbed_official 146:f64d43ff0c18 207 */
mbed_official 146:f64d43ff0c18 208 static inline void gpio_hal_toggle_pin_output(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 209 {
mbed_official 146:f64d43ff0c18 210 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 211 assert(pin < 32);
mbed_official 146:f64d43ff0c18 212 HW_GPIO_PTOR_WR(instance, 1U << pin);
mbed_official 146:f64d43ff0c18 213 }
mbed_official 146:f64d43ff0c18 214
mbed_official 146:f64d43ff0c18 215 /*!
mbed_official 146:f64d43ff0c18 216 * @brief Sets the output of the GPIO port to a specific logic value.
mbed_official 146:f64d43ff0c18 217 *
mbed_official 146:f64d43ff0c18 218 * This function operates all 32 port pins.
mbed_official 146:f64d43ff0c18 219 *
mbed_official 146:f64d43ff0c18 220 * @param instance GPIO instance number (HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 221 * @param portOutput data to configure the GPIO output. Each bit represents one pin. For each bit:
mbed_official 146:f64d43ff0c18 222 * - 0: set logic level 0 to pin
mbed_official 146:f64d43ff0c18 223 * - 1: set logic level 1 to pin
mbed_official 146:f64d43ff0c18 224 * - LSB: pin 0
mbed_official 146:f64d43ff0c18 225 * - MSB: pin 31
mbed_official 146:f64d43ff0c18 226 */
mbed_official 146:f64d43ff0c18 227 static inline void gpio_hal_write_port_output(uint32_t instance, uint32_t portOutput)
mbed_official 146:f64d43ff0c18 228 {
mbed_official 146:f64d43ff0c18 229 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 230 HW_GPIO_PDOR_WR(instance, portOutput);
mbed_official 146:f64d43ff0c18 231 }
mbed_official 146:f64d43ff0c18 232
mbed_official 146:f64d43ff0c18 233 /*!
mbed_official 146:f64d43ff0c18 234 * @brief Reads out all pin output status of the current port.
mbed_official 146:f64d43ff0c18 235 *
mbed_official 146:f64d43ff0c18 236 * This function operates all 32 port pins.
mbed_official 146:f64d43ff0c18 237 *
mbed_official 146:f64d43ff0c18 238 * @param instance GPIO instance number (HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 239 * @return current port output status. Each bit represents one pin. For each bit:
mbed_official 146:f64d43ff0c18 240 * - 0: corresponding pin is outputting logic level 0
mbed_official 146:f64d43ff0c18 241 * - 1: corresponding pin is outputting logic level 1
mbed_official 146:f64d43ff0c18 242 * - LSB: pin 0
mbed_official 146:f64d43ff0c18 243 * - MSB: pin 31
mbed_official 146:f64d43ff0c18 244 */
mbed_official 146:f64d43ff0c18 245 static inline uint32_t gpio_hal_read_port_output(uint32_t instance)
mbed_official 146:f64d43ff0c18 246 {
mbed_official 146:f64d43ff0c18 247 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 248 return HW_GPIO_PDOR_RD(instance);
mbed_official 146:f64d43ff0c18 249 }
mbed_official 146:f64d43ff0c18 250
mbed_official 146:f64d43ff0c18 251 /* @} */
mbed_official 146:f64d43ff0c18 252
mbed_official 146:f64d43ff0c18 253 /*!
mbed_official 146:f64d43ff0c18 254 * @name Input Operation
mbed_official 146:f64d43ff0c18 255 * @{
mbed_official 146:f64d43ff0c18 256 */
mbed_official 146:f64d43ff0c18 257
mbed_official 146:f64d43ff0c18 258 /*!
mbed_official 146:f64d43ff0c18 259 * @brief Reads the current input value of the individual GPIO pin.
mbed_official 146:f64d43ff0c18 260 *
mbed_official 146:f64d43ff0c18 261 * @param instance GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 262 * @param pin GPIO port pin number
mbed_official 146:f64d43ff0c18 263 * @return GPIO port input value
mbed_official 146:f64d43ff0c18 264 * - 0: Pin logic level is 0, or is not configured for use by digital function.
mbed_official 146:f64d43ff0c18 265 * - 1: Pin logic level is 1
mbed_official 146:f64d43ff0c18 266 */
mbed_official 146:f64d43ff0c18 267 static inline uint32_t gpio_hal_read_pin_input(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 268 {
mbed_official 146:f64d43ff0c18 269 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 270 assert(pin < 32);
mbed_official 146:f64d43ff0c18 271 return (HW_GPIO_PDIR_RD(instance) >> pin) & 1U;
mbed_official 146:f64d43ff0c18 272 }
mbed_official 146:f64d43ff0c18 273
mbed_official 146:f64d43ff0c18 274 /*!
mbed_official 146:f64d43ff0c18 275 * @brief Reads the current input value of a specific GPIO port.
mbed_official 146:f64d43ff0c18 276 *
mbed_official 146:f64d43ff0c18 277 * This function gets all 32-pin input as a 32-bit integer.
mbed_official 146:f64d43ff0c18 278 *
mbed_official 146:f64d43ff0c18 279 * @param instance GPIO instance number(HW_GPIOA, HW_GPIOB, HW_GPIOC, etc.)
mbed_official 146:f64d43ff0c18 280 * @return GPIO port input data. Each bit represents one pin. For each bit:
mbed_official 146:f64d43ff0c18 281 * - 0: Pin logic level is 0, or is not configured for use by digital function.
mbed_official 146:f64d43ff0c18 282 * - 1: Pin logic level is 1.
mbed_official 146:f64d43ff0c18 283 * - LSB: pin 0
mbed_official 146:f64d43ff0c18 284 * - MSB: pin 31
mbed_official 146:f64d43ff0c18 285 */
mbed_official 146:f64d43ff0c18 286 static inline uint32_t gpio_hal_read_port_input(uint32_t instance)
mbed_official 146:f64d43ff0c18 287 {
mbed_official 146:f64d43ff0c18 288 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 289 return HW_GPIO_PDIR_RD(instance);
mbed_official 146:f64d43ff0c18 290 }
mbed_official 146:f64d43ff0c18 291
mbed_official 146:f64d43ff0c18 292 /* @} */
mbed_official 146:f64d43ff0c18 293
mbed_official 146:f64d43ff0c18 294 /*!
mbed_official 146:f64d43ff0c18 295 * @name FGPIO Operation
mbed_official 146:f64d43ff0c18 296 *
mbed_official 146:f64d43ff0c18 297 * @note FGPIO (Fast GPIO) is only available in a few MCUs. FGPIO and GPIO share the same
mbed_official 146:f64d43ff0c18 298 * peripheral but use different registers. FGPIO is closer to the core than the regular GPIO
mbed_official 146:f64d43ff0c18 299 * and it's faster to read and write.
mbed_official 146:f64d43ff0c18 300 * @{
mbed_official 146:f64d43ff0c18 301 */
mbed_official 146:f64d43ff0c18 302
mbed_official 146:f64d43ff0c18 303 #if FSL_FEATURE_GPIO_HAS_FAST_GPIO
mbed_official 146:f64d43ff0c18 304
mbed_official 146:f64d43ff0c18 305 /*!
mbed_official 146:f64d43ff0c18 306 * @name Output Operation
mbed_official 146:f64d43ff0c18 307 * @{
mbed_official 146:f64d43ff0c18 308 */
mbed_official 146:f64d43ff0c18 309
mbed_official 146:f64d43ff0c18 310 /*!
mbed_official 146:f64d43ff0c18 311 * @brief Sets the output level of an individual FGPIO pin to logic 1.
mbed_official 146:f64d43ff0c18 312 *
mbed_official 146:f64d43ff0c18 313 * @param instance GPIO instance number(HW_FPTA, HW_FPTB, HW_FPTC, etc.)
mbed_official 146:f64d43ff0c18 314 * @param pin FGPIO port pin number
mbed_official 146:f64d43ff0c18 315 */
mbed_official 146:f64d43ff0c18 316 static inline void fgpio_hal_set_pin_output(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 317 {
mbed_official 146:f64d43ff0c18 318 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 319 assert(pin < 32);
mbed_official 146:f64d43ff0c18 320 HW_FGPIO_PSOR_WR(instance, 1U << pin);
mbed_official 146:f64d43ff0c18 321 }
mbed_official 146:f64d43ff0c18 322
mbed_official 146:f64d43ff0c18 323 /*!
mbed_official 146:f64d43ff0c18 324 * @brief Clears the output level of an individual FGPIO pin to logic 0.
mbed_official 146:f64d43ff0c18 325 *
mbed_official 146:f64d43ff0c18 326 * @param instance GPIO instance number(HW_FPTA, HW_FPTB, HW_FPTC, etc.)
mbed_official 146:f64d43ff0c18 327 * @param pin FGPIO port pin number
mbed_official 146:f64d43ff0c18 328 */
mbed_official 146:f64d43ff0c18 329 static inline void fgpio_hal_clear_pin_output(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 330 {
mbed_official 146:f64d43ff0c18 331 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 332 assert(pin < 32);
mbed_official 146:f64d43ff0c18 333 HW_FGPIO_PCOR_WR(instance, 1U << pin);
mbed_official 146:f64d43ff0c18 334 }
mbed_official 146:f64d43ff0c18 335
mbed_official 146:f64d43ff0c18 336 /*!
mbed_official 146:f64d43ff0c18 337 * @brief Reverses the current output logic of an individual FGPIO pin.
mbed_official 146:f64d43ff0c18 338 *
mbed_official 146:f64d43ff0c18 339 * @param instance GPIO instance number(HW_FPTA, HW_FPTB, HW_FPTC, etc.)
mbed_official 146:f64d43ff0c18 340 * @param pin FGPIO port pin number
mbed_official 146:f64d43ff0c18 341 */
mbed_official 146:f64d43ff0c18 342 static inline void fgpio_hal_toggle_pin_output(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 343 {
mbed_official 146:f64d43ff0c18 344 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 345 assert(pin < 32);
mbed_official 146:f64d43ff0c18 346 HW_FGPIO_PTOR_WR(instance, 1U << pin);
mbed_official 146:f64d43ff0c18 347 }
mbed_official 146:f64d43ff0c18 348
mbed_official 146:f64d43ff0c18 349 /*!
mbed_official 146:f64d43ff0c18 350 * @brief Sets the output of the FGPIO port to a specific logic value.
mbed_official 146:f64d43ff0c18 351 *
mbed_official 146:f64d43ff0c18 352 * This function affects all 32 port pins.
mbed_official 146:f64d43ff0c18 353 *
mbed_official 146:f64d43ff0c18 354 * @param instance GPIO instance number(HW_FPTA, HW_FPTB, HW_FPTC, etc.)
mbed_official 146:f64d43ff0c18 355 * @param portOutput data to configure the GPIO output. Each bit represents one pin. For each bit:
mbed_official 146:f64d43ff0c18 356 * - 0: set logic level 0 to pin.
mbed_official 146:f64d43ff0c18 357 * - 1: set logic level 1 to pin.
mbed_official 146:f64d43ff0c18 358 * - LSB: pin 0
mbed_official 146:f64d43ff0c18 359 * - MSB: pin 31
mbed_official 146:f64d43ff0c18 360 */
mbed_official 146:f64d43ff0c18 361 static inline void fgpio_hal_write_port_output(uint32_t instance, uint32_t portOutput)
mbed_official 146:f64d43ff0c18 362 {
mbed_official 146:f64d43ff0c18 363 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 364 HW_FGPIO_PDOR_WR(instance, portOutput);
mbed_official 146:f64d43ff0c18 365 }
mbed_official 146:f64d43ff0c18 366
mbed_official 146:f64d43ff0c18 367 /* @} */
mbed_official 146:f64d43ff0c18 368
mbed_official 146:f64d43ff0c18 369 /*!
mbed_official 146:f64d43ff0c18 370 * @name Input Operation
mbed_official 146:f64d43ff0c18 371 * @{
mbed_official 146:f64d43ff0c18 372 */
mbed_official 146:f64d43ff0c18 373
mbed_official 146:f64d43ff0c18 374 /*!
mbed_official 146:f64d43ff0c18 375 * @brief Gets the current input value of an individual FGPIO pin.
mbed_official 146:f64d43ff0c18 376 *
mbed_official 146:f64d43ff0c18 377 * @param instance GPIO instance number(HW_FPTA, HW_FPTB, HW_FPTC, etc.)
mbed_official 146:f64d43ff0c18 378 * @param pin FGPIO port pin number
mbed_official 146:f64d43ff0c18 379 * @return FGPIO port input data
mbed_official 146:f64d43ff0c18 380 * - 0: Pin logic level is 0, or is not configured for use by digital function.
mbed_official 146:f64d43ff0c18 381 * - 1: Pin logic level is 1.
mbed_official 146:f64d43ff0c18 382 */
mbed_official 146:f64d43ff0c18 383 static inline uint32_t fgpio_hal_read_pin_input(uint32_t instance, uint32_t pin)
mbed_official 146:f64d43ff0c18 384 {
mbed_official 146:f64d43ff0c18 385 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 386 assert(pin < 32);
mbed_official 146:f64d43ff0c18 387 return (HW_FGPIO_PDIR_RD(instance) >> pin) & 1U;
mbed_official 146:f64d43ff0c18 388 }
mbed_official 146:f64d43ff0c18 389
mbed_official 146:f64d43ff0c18 390 /*!
mbed_official 146:f64d43ff0c18 391 * @brief Gets the current input value of a specific FGPIO port.
mbed_official 146:f64d43ff0c18 392 *
mbed_official 146:f64d43ff0c18 393 * This function gets all 32-pin input as a 32-bit integer.
mbed_official 146:f64d43ff0c18 394 *
mbed_official 146:f64d43ff0c18 395 * @param instance GPIO instance number(HW_FPTA, HW_FPTB, HW_FPTC, etc.).
mbed_official 146:f64d43ff0c18 396 * @return FGPIO port input data. Each bit represents one pin. For each bit:
mbed_official 146:f64d43ff0c18 397 * - 0: Pin logic level is 0, or is not configured for use by digital function.
mbed_official 146:f64d43ff0c18 398 * - 1: Pin logic level is 1.
mbed_official 146:f64d43ff0c18 399 * - LSB: pin 0
mbed_official 146:f64d43ff0c18 400 * - MSB: pin 31
mbed_official 146:f64d43ff0c18 401 */
mbed_official 146:f64d43ff0c18 402 static inline uint32_t fgpio_hal_read_port_input(uint32_t instance)
mbed_official 146:f64d43ff0c18 403 {
mbed_official 146:f64d43ff0c18 404 assert(instance < HW_GPIO_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 405 return HW_FGPIO_PDIR_RD(instance);
mbed_official 146:f64d43ff0c18 406 }
mbed_official 146:f64d43ff0c18 407
mbed_official 146:f64d43ff0c18 408 /* @} */
mbed_official 146:f64d43ff0c18 409
mbed_official 146:f64d43ff0c18 410 #endif /* FSL_FEATURE_GPIO_HAS_FAST_GPIO*/
mbed_official 146:f64d43ff0c18 411
mbed_official 146:f64d43ff0c18 412 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 413 }
mbed_official 146:f64d43ff0c18 414 #endif
mbed_official 146:f64d43ff0c18 415
mbed_official 146:f64d43ff0c18 416 /*! @} */
mbed_official 146:f64d43ff0c18 417
mbed_official 146:f64d43ff0c18 418 #endif /* __FSL_GPIO_HAL_H__*/
mbed_official 146:f64d43ff0c18 419 /*******************************************************************************
mbed_official 146:f64d43ff0c18 420 * EOF
mbed_official 146:f64d43ff0c18 421 ******************************************************************************/
mbed_official 146:f64d43ff0c18 422