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

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_NRF51_DK/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_11/drivers_nrf/hal/nrf_gpio.h@169:a7c7b631e539
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 146:22da6e220af6 1 /*
AnnaBridge 146:22da6e220af6 2 * Copyright (c) 2015 Nordic Semiconductor ASA
AnnaBridge 146:22da6e220af6 3 * All rights reserved.
AnnaBridge 146:22da6e220af6 4 *
AnnaBridge 146:22da6e220af6 5 * Redistribution and use in source and binary forms, with or without modification,
AnnaBridge 146:22da6e220af6 6 * are permitted provided that the following conditions are met:
AnnaBridge 146:22da6e220af6 7 *
AnnaBridge 146:22da6e220af6 8 * 1. Redistributions of source code must retain the above copyright notice, this list
AnnaBridge 146:22da6e220af6 9 * of conditions and the following disclaimer.
AnnaBridge 146:22da6e220af6 10 *
AnnaBridge 146:22da6e220af6 11 * 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA
AnnaBridge 146:22da6e220af6 12 * integrated circuit in a product or a software update for such product, must reproduce
AnnaBridge 146:22da6e220af6 13 * the above copyright notice, this list of conditions and the following disclaimer in
AnnaBridge 146:22da6e220af6 14 * the documentation and/or other materials provided with the distribution.
AnnaBridge 146:22da6e220af6 15 *
AnnaBridge 146:22da6e220af6 16 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be
AnnaBridge 146:22da6e220af6 17 * used to endorse or promote products derived from this software without specific prior
AnnaBridge 146:22da6e220af6 18 * written permission.
AnnaBridge 146:22da6e220af6 19 *
AnnaBridge 146:22da6e220af6 20 * 4. This software, with or without modification, must only be used with a
AnnaBridge 146:22da6e220af6 21 * Nordic Semiconductor ASA integrated circuit.
AnnaBridge 146:22da6e220af6 22 *
AnnaBridge 146:22da6e220af6 23 * 5. Any software provided in binary or object form under this license must not be reverse
AnnaBridge 146:22da6e220af6 24 * engineered, decompiled, modified and/or disassembled.
AnnaBridge 146:22da6e220af6 25 *
AnnaBridge 146:22da6e220af6 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
AnnaBridge 146:22da6e220af6 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
AnnaBridge 146:22da6e220af6 28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
AnnaBridge 146:22da6e220af6 29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
AnnaBridge 146:22da6e220af6 30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
AnnaBridge 146:22da6e220af6 31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
AnnaBridge 146:22da6e220af6 32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
AnnaBridge 146:22da6e220af6 33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
AnnaBridge 146:22da6e220af6 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
AnnaBridge 146:22da6e220af6 35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AnnaBridge 146:22da6e220af6 36 *
AnnaBridge 146:22da6e220af6 37 */
AnnaBridge 146:22da6e220af6 38
AnnaBridge 146:22da6e220af6 39 #ifndef NRF_GPIO_H__
AnnaBridge 146:22da6e220af6 40 #define NRF_GPIO_H__
AnnaBridge 146:22da6e220af6 41
AnnaBridge 146:22da6e220af6 42 #include "nrf.h"
AnnaBridge 146:22da6e220af6 43 #include <stdbool.h>
AnnaBridge 146:22da6e220af6 44
AnnaBridge 146:22da6e220af6 45 /**
AnnaBridge 146:22da6e220af6 46 * @defgroup nrf_gpio GPIO abstraction
AnnaBridge 146:22da6e220af6 47 * @{
AnnaBridge 146:22da6e220af6 48 * @ingroup nrf_drivers
AnnaBridge 146:22da6e220af6 49 * @brief GPIO pin abstraction and port abstraction for reading and writing byte-wise to GPIO ports.
AnnaBridge 146:22da6e220af6 50 *
AnnaBridge 146:22da6e220af6 51 * Here, the GPIO ports are defined as follows:
AnnaBridge 146:22da6e220af6 52 * - Port 0 -> pin 0-7
AnnaBridge 146:22da6e220af6 53 * - Port 1 -> pin 8-15
AnnaBridge 146:22da6e220af6 54 * - Port 2 -> pin 16-23
AnnaBridge 146:22da6e220af6 55 * - Port 3 -> pin 24-31
AnnaBridge 146:22da6e220af6 56 */
AnnaBridge 146:22da6e220af6 57
AnnaBridge 146:22da6e220af6 58 #define NUMBER_OF_PINS 32
AnnaBridge 146:22da6e220af6 59
AnnaBridge 146:22da6e220af6 60 /**
AnnaBridge 146:22da6e220af6 61 * @brief Enumerator used for selecting between port 0 - 3.
AnnaBridge 146:22da6e220af6 62 */
AnnaBridge 146:22da6e220af6 63 typedef enum
AnnaBridge 146:22da6e220af6 64 {
AnnaBridge 146:22da6e220af6 65 NRF_GPIO_PORT_SELECT_PORT0 = 0, ///< Port 0 (GPIO pin 0-7)
AnnaBridge 146:22da6e220af6 66 NRF_GPIO_PORT_SELECT_PORT1, ///< Port 1 (GPIO pin 8-15)
AnnaBridge 146:22da6e220af6 67 NRF_GPIO_PORT_SELECT_PORT2, ///< Port 2 (GPIO pin 16-23)
AnnaBridge 146:22da6e220af6 68 NRF_GPIO_PORT_SELECT_PORT3, ///< Port 3 (GPIO pin 24-31)
AnnaBridge 146:22da6e220af6 69 } nrf_gpio_port_select_t;
AnnaBridge 146:22da6e220af6 70
AnnaBridge 146:22da6e220af6 71 /**
AnnaBridge 146:22da6e220af6 72 * @brief Enumerator used for setting the direction of a GPIO port.
AnnaBridge 146:22da6e220af6 73 */
AnnaBridge 146:22da6e220af6 74 typedef enum
AnnaBridge 146:22da6e220af6 75 {
AnnaBridge 146:22da6e220af6 76 NRF_GPIO_PORT_DIR_OUTPUT, ///< Output
AnnaBridge 146:22da6e220af6 77 NRF_GPIO_PORT_DIR_INPUT ///< Input
AnnaBridge 146:22da6e220af6 78 } nrf_gpio_port_dir_t;
AnnaBridge 146:22da6e220af6 79
AnnaBridge 146:22da6e220af6 80 /**
AnnaBridge 146:22da6e220af6 81 * @brief Pin direction definitions.
AnnaBridge 146:22da6e220af6 82 */
AnnaBridge 146:22da6e220af6 83 typedef enum
AnnaBridge 146:22da6e220af6 84 {
AnnaBridge 146:22da6e220af6 85 NRF_GPIO_PIN_DIR_INPUT = GPIO_PIN_CNF_DIR_Input, ///< Input
AnnaBridge 146:22da6e220af6 86 NRF_GPIO_PIN_DIR_OUTPUT = GPIO_PIN_CNF_DIR_Output ///< Output
AnnaBridge 146:22da6e220af6 87 } nrf_gpio_pin_dir_t;
AnnaBridge 146:22da6e220af6 88
AnnaBridge 146:22da6e220af6 89 /**
AnnaBridge 146:22da6e220af6 90 * @brief Connection of input buffer
AnnaBridge 146:22da6e220af6 91 */
AnnaBridge 146:22da6e220af6 92 typedef enum
AnnaBridge 146:22da6e220af6 93 {
AnnaBridge 146:22da6e220af6 94 NRF_GPIO_PIN_INPUT_CONNECT = GPIO_PIN_CNF_INPUT_Connect, ///< Connect input buffer
AnnaBridge 146:22da6e220af6 95 NRF_GPIO_PIN_INPUT_DISCONNECT = GPIO_PIN_CNF_INPUT_Disconnect ///< Disconnect input buffer
AnnaBridge 146:22da6e220af6 96 } nrf_gpio_pin_input_t;
AnnaBridge 146:22da6e220af6 97
AnnaBridge 146:22da6e220af6 98 /**
AnnaBridge 146:22da6e220af6 99 * @brief Enumerator used for selecting the pin to be pulled down or up at the time of pin configuration
AnnaBridge 146:22da6e220af6 100 */
AnnaBridge 146:22da6e220af6 101 typedef enum
AnnaBridge 146:22da6e220af6 102 {
AnnaBridge 146:22da6e220af6 103 NRF_GPIO_PIN_NOPULL = GPIO_PIN_CNF_PULL_Disabled, ///< Pin pullup resistor disabled
AnnaBridge 146:22da6e220af6 104 NRF_GPIO_PIN_PULLDOWN = GPIO_PIN_CNF_PULL_Pulldown, ///< Pin pulldown resistor enabled
AnnaBridge 146:22da6e220af6 105 NRF_GPIO_PIN_PULLUP = GPIO_PIN_CNF_PULL_Pullup, ///< Pin pullup resistor enabled
AnnaBridge 146:22da6e220af6 106 } nrf_gpio_pin_pull_t;
AnnaBridge 146:22da6e220af6 107
AnnaBridge 146:22da6e220af6 108 /**
AnnaBridge 146:22da6e220af6 109 * @brief Enumerator used for selecting output drive mode
AnnaBridge 146:22da6e220af6 110 */
AnnaBridge 146:22da6e220af6 111 typedef enum
AnnaBridge 146:22da6e220af6 112 {
AnnaBridge 146:22da6e220af6 113 NRF_GPIO_PIN_S0S1 = GPIO_PIN_CNF_DRIVE_S0S1, ///< !< Standard '0', standard '1'
AnnaBridge 146:22da6e220af6 114 NRF_GPIO_PIN_H0S1 = GPIO_PIN_CNF_DRIVE_H0S1, ///< !< High drive '0', standard '1'
AnnaBridge 146:22da6e220af6 115 NRF_GPIO_PIN_S0H1 = GPIO_PIN_CNF_DRIVE_S0H1, ///< !< Standard '0', high drive '1'
AnnaBridge 146:22da6e220af6 116 NRF_GPIO_PIN_H0H1 = GPIO_PIN_CNF_DRIVE_H0H1, ///< !< High drive '0', high 'drive '1''
AnnaBridge 146:22da6e220af6 117 NRF_GPIO_PIN_D0S1 = GPIO_PIN_CNF_DRIVE_D0S1, ///< !< Disconnect '0' standard '1'
AnnaBridge 146:22da6e220af6 118 NRF_GPIO_PIN_D0H1 = GPIO_PIN_CNF_DRIVE_D0H1, ///< !< Disconnect '0', high drive '1'
AnnaBridge 146:22da6e220af6 119 NRF_GPIO_PIN_S0D1 = GPIO_PIN_CNF_DRIVE_S0D1, ///< !< Standard '0'. disconnect '1'
AnnaBridge 146:22da6e220af6 120 NRF_GPIO_PIN_H0D1 = GPIO_PIN_CNF_DRIVE_H0D1, ///< !< High drive '0', disconnect '1'
AnnaBridge 146:22da6e220af6 121 } nrf_gpio_pin_drive_t;
AnnaBridge 146:22da6e220af6 122
AnnaBridge 146:22da6e220af6 123 /**
AnnaBridge 146:22da6e220af6 124 * @brief Enumerator used for selecting the pin to sense high or low level on the pin input.
AnnaBridge 146:22da6e220af6 125 */
AnnaBridge 146:22da6e220af6 126 typedef enum
AnnaBridge 146:22da6e220af6 127 {
AnnaBridge 146:22da6e220af6 128 NRF_GPIO_PIN_NOSENSE = GPIO_PIN_CNF_SENSE_Disabled, ///< Pin sense level disabled.
AnnaBridge 146:22da6e220af6 129 NRF_GPIO_PIN_SENSE_LOW = GPIO_PIN_CNF_SENSE_Low, ///< Pin sense low level.
AnnaBridge 146:22da6e220af6 130 NRF_GPIO_PIN_SENSE_HIGH = GPIO_PIN_CNF_SENSE_High, ///< Pin sense high level.
AnnaBridge 146:22da6e220af6 131 } nrf_gpio_pin_sense_t;
AnnaBridge 146:22da6e220af6 132
AnnaBridge 146:22da6e220af6 133
AnnaBridge 146:22da6e220af6 134 /**
AnnaBridge 146:22da6e220af6 135 * @brief Function for configuring the GPIO pin range as outputs with normal drive strength.
AnnaBridge 146:22da6e220af6 136 * This function can be used to configure pin range as simple output with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases).
AnnaBridge 146:22da6e220af6 137 *
AnnaBridge 146:22da6e220af6 138 * @param pin_range_start specifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30)
AnnaBridge 146:22da6e220af6 139 *
AnnaBridge 146:22da6e220af6 140 * @param pin_range_end specifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30)
AnnaBridge 146:22da6e220af6 141 *
AnnaBridge 146:22da6e220af6 142 * @note For configuring only one pin as output use @ref nrf_gpio_cfg_output
AnnaBridge 146:22da6e220af6 143 * Sense capability on the pin is disabled, and input is disconnected from the buffer as the pins are configured as output.
AnnaBridge 146:22da6e220af6 144 */
AnnaBridge 146:22da6e220af6 145 __STATIC_INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_t pin_range_end);
AnnaBridge 146:22da6e220af6 146
AnnaBridge 146:22da6e220af6 147 /**
AnnaBridge 146:22da6e220af6 148 * @brief Function for configuring the GPIO pin range as inputs with given initial value set, hiding inner details.
AnnaBridge 146:22da6e220af6 149 * This function can be used to configure pin range as simple input.
AnnaBridge 146:22da6e220af6 150 *
AnnaBridge 146:22da6e220af6 151 * @param pin_range_start specifies the start number (inclusive) in the range of pin numbers to be configured (allowed values 0-30)
AnnaBridge 146:22da6e220af6 152 *
AnnaBridge 146:22da6e220af6 153 * @param pin_range_end specifies the end number (inclusive) in the range of pin numbers to be configured (allowed values 0-30)
AnnaBridge 146:22da6e220af6 154 *
AnnaBridge 146:22da6e220af6 155 * @param pull_config State of the pin range pull resistor (no pull, pulled down or pulled high)
AnnaBridge 146:22da6e220af6 156 *
AnnaBridge 146:22da6e220af6 157 * @note For configuring only one pin as input use @ref nrf_gpio_cfg_input
AnnaBridge 146:22da6e220af6 158 * Sense capability on the pin is disabled, and input is connected to buffer so that the GPIO->IN register is readable
AnnaBridge 146:22da6e220af6 159 */
AnnaBridge 146:22da6e220af6 160 __STATIC_INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_start, uint32_t pin_range_end, nrf_gpio_pin_pull_t pull_config);
AnnaBridge 146:22da6e220af6 161
AnnaBridge 146:22da6e220af6 162 /**
AnnaBridge 146:22da6e220af6 163 * @brief Pin configuration function
AnnaBridge 146:22da6e220af6 164 *
AnnaBridge 146:22da6e220af6 165 * The main pin configuration function.
AnnaBridge 146:22da6e220af6 166 * This function allows to set any aspect in PIN_CNF register.
AnnaBridge 146:22da6e220af6 167 * @param pin_number Specifies the pin number (allowed values 0-31).
AnnaBridge 146:22da6e220af6 168 * @param dir Pin direction
AnnaBridge 146:22da6e220af6 169 * @param input Connect or disconnect input buffer
AnnaBridge 146:22da6e220af6 170 * @param pull Pull configuration
AnnaBridge 146:22da6e220af6 171 * @param drive Drive configuration
AnnaBridge 146:22da6e220af6 172 * @param sense Pin sensing mechanism
AnnaBridge 146:22da6e220af6 173 */
AnnaBridge 146:22da6e220af6 174 __STATIC_INLINE void nrf_gpio_cfg(
AnnaBridge 146:22da6e220af6 175 uint32_t pin_number,
AnnaBridge 146:22da6e220af6 176 nrf_gpio_pin_dir_t dir,
AnnaBridge 146:22da6e220af6 177 nrf_gpio_pin_input_t input,
AnnaBridge 146:22da6e220af6 178 nrf_gpio_pin_pull_t pull,
AnnaBridge 146:22da6e220af6 179 nrf_gpio_pin_drive_t drive,
AnnaBridge 146:22da6e220af6 180 nrf_gpio_pin_sense_t sense);
AnnaBridge 146:22da6e220af6 181
AnnaBridge 146:22da6e220af6 182 /**
AnnaBridge 146:22da6e220af6 183 * @brief Function for configuring the given GPIO pin number as output with given initial value set, hiding inner details.
AnnaBridge 146:22da6e220af6 184 * This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases).
AnnaBridge 146:22da6e220af6 185 *
AnnaBridge 146:22da6e220af6 186 * @param pin_number specifies the pin number (allowed values 0-31)
AnnaBridge 146:22da6e220af6 187 *
AnnaBridge 146:22da6e220af6 188 * @note Sense capability on the pin is disabled, and input is disconnected from the buffer as the pins are configured as output.
AnnaBridge 146:22da6e220af6 189 */
AnnaBridge 146:22da6e220af6 190 __STATIC_INLINE void nrf_gpio_cfg_output(uint32_t pin_number);
AnnaBridge 146:22da6e220af6 191
AnnaBridge 146:22da6e220af6 192 /**
AnnaBridge 146:22da6e220af6 193 * @brief Function for configuring the given GPIO pin number as input with given initial value set, hiding inner details.
AnnaBridge 146:22da6e220af6 194 * This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases).
AnnaBridge 146:22da6e220af6 195 *
AnnaBridge 146:22da6e220af6 196 * @param pin_number Specifies the pin number (allowed values 0-30).
AnnaBridge 146:22da6e220af6 197 * @param pull_config State of the pin range pull resistor (no pull, pulled down or pulled high).
AnnaBridge 146:22da6e220af6 198 *
AnnaBridge 146:22da6e220af6 199 * @note Sense capability on the pin is disabled, and input is connected to buffer so that the GPIO->IN register is readable
AnnaBridge 146:22da6e220af6 200 */
AnnaBridge 146:22da6e220af6 201 __STATIC_INLINE void nrf_gpio_cfg_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config);
AnnaBridge 146:22da6e220af6 202
AnnaBridge 146:22da6e220af6 203 /**
AnnaBridge 146:22da6e220af6 204 * @brief Function for reseting pin configuration to its default state.
AnnaBridge 146:22da6e220af6 205 *
AnnaBridge 146:22da6e220af6 206 * @param pin_number Specifies the pin number (allowed values 0-31).
AnnaBridge 146:22da6e220af6 207 */
AnnaBridge 146:22da6e220af6 208 __STATIC_INLINE void nrf_gpio_cfg_default(uint32_t pin_number);
AnnaBridge 146:22da6e220af6 209
AnnaBridge 146:22da6e220af6 210 /**
AnnaBridge 146:22da6e220af6 211 * @brief Function for configuring the given GPIO pin number as a watcher. Only input is connected.
AnnaBridge 146:22da6e220af6 212 *
AnnaBridge 146:22da6e220af6 213 * @param pin_number Specifies the pin number (allowed values 0-31).
AnnaBridge 146:22da6e220af6 214 *
AnnaBridge 146:22da6e220af6 215 */
AnnaBridge 146:22da6e220af6 216 __STATIC_INLINE void nrf_gpio_cfg_watcher(uint32_t pin_number);
AnnaBridge 146:22da6e220af6 217
AnnaBridge 146:22da6e220af6 218 /**
AnnaBridge 146:22da6e220af6 219 * @brief Function for disconnecting input for the given GPIO.
AnnaBridge 146:22da6e220af6 220 *
AnnaBridge 146:22da6e220af6 221 * @param pin_number Specifies the pin number (allowed values 0-31).
AnnaBridge 146:22da6e220af6 222 *
AnnaBridge 146:22da6e220af6 223 */
AnnaBridge 146:22da6e220af6 224 __STATIC_INLINE void nrf_gpio_input_disconnect(uint32_t pin_number);
AnnaBridge 146:22da6e220af6 225
AnnaBridge 146:22da6e220af6 226 /**
AnnaBridge 146:22da6e220af6 227 * @brief Function for configuring the given GPIO pin number as input with given initial value set, hiding inner details.
AnnaBridge 146:22da6e220af6 228 * This function can be used to configure pin range as simple input with gate driving GPIO_PIN_CNF_DRIVE_S0S1 (normal cases).
AnnaBridge 146:22da6e220af6 229 * Sense capability on the pin is configurable, and input is connected to buffer so that the GPIO->IN register is readable.
AnnaBridge 146:22da6e220af6 230 *
AnnaBridge 146:22da6e220af6 231 * @param pin_number Specifies the pin number (allowed values 0-30).
AnnaBridge 146:22da6e220af6 232 * @param pull_config State of the pin pull resistor (no pull, pulled down or pulled high).
AnnaBridge 146:22da6e220af6 233 * @param sense_config Sense level of the pin (no sense, sense low or sense high).
AnnaBridge 146:22da6e220af6 234 */
AnnaBridge 146:22da6e220af6 235 __STATIC_INLINE void nrf_gpio_cfg_sense_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config, nrf_gpio_pin_sense_t sense_config);
AnnaBridge 146:22da6e220af6 236
AnnaBridge 146:22da6e220af6 237 /**
AnnaBridge 146:22da6e220af6 238 * @brief Function for configuring sense level for the given GPIO.
AnnaBridge 146:22da6e220af6 239 *
AnnaBridge 146:22da6e220af6 240 * @param pin_number Specifies the pin number of gpio pin numbers to be configured (allowed values 0-30).
AnnaBridge 146:22da6e220af6 241 * @param sense_config Sense configuration.
AnnaBridge 146:22da6e220af6 242 *
AnnaBridge 146:22da6e220af6 243 */
AnnaBridge 146:22da6e220af6 244 __STATIC_INLINE void nrf_gpio_cfg_sense_set(uint32_t pin_number, nrf_gpio_pin_sense_t sense_config);
AnnaBridge 146:22da6e220af6 245
AnnaBridge 146:22da6e220af6 246 /**
AnnaBridge 146:22da6e220af6 247 * @brief Function for setting the direction for a GPIO pin.
AnnaBridge 146:22da6e220af6 248 *
AnnaBridge 146:22da6e220af6 249 * @param pin_number specifies the pin number (0-31) for which to
AnnaBridge 146:22da6e220af6 250 * set the direction.
AnnaBridge 146:22da6e220af6 251 *
AnnaBridge 146:22da6e220af6 252 * @param direction specifies the direction
AnnaBridge 146:22da6e220af6 253 */
AnnaBridge 146:22da6e220af6 254 __STATIC_INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_t direction);
AnnaBridge 146:22da6e220af6 255
AnnaBridge 146:22da6e220af6 256 /**
AnnaBridge 146:22da6e220af6 257 * @brief Function for setting a GPIO pin.
AnnaBridge 146:22da6e220af6 258 *
AnnaBridge 146:22da6e220af6 259 * Note that the pin must be configured as an output for this
AnnaBridge 146:22da6e220af6 260 * function to have any effect.
AnnaBridge 146:22da6e220af6 261 *
AnnaBridge 146:22da6e220af6 262 * @param pin_number Specifies the pin number (0-31) to set.
AnnaBridge 146:22da6e220af6 263 */
AnnaBridge 146:22da6e220af6 264 __STATIC_INLINE void nrf_gpio_pin_set(uint32_t pin_number);
AnnaBridge 146:22da6e220af6 265
AnnaBridge 146:22da6e220af6 266 /**
AnnaBridge 146:22da6e220af6 267 * @brief Function for setting GPIO pins.
AnnaBridge 146:22da6e220af6 268 *
AnnaBridge 146:22da6e220af6 269 * Note that the pins must be configured as outputs for this
AnnaBridge 146:22da6e220af6 270 * function to have any effect.
AnnaBridge 146:22da6e220af6 271 *
AnnaBridge 146:22da6e220af6 272 * @param pin_mask Specifies the pins to set.
AnnaBridge 146:22da6e220af6 273 */
AnnaBridge 146:22da6e220af6 274 __STATIC_INLINE void nrf_gpio_pins_set(uint32_t pin_mask);
AnnaBridge 146:22da6e220af6 275
AnnaBridge 146:22da6e220af6 276 /**
AnnaBridge 146:22da6e220af6 277 * @brief Function for clearing a GPIO pin.
AnnaBridge 146:22da6e220af6 278 *
AnnaBridge 146:22da6e220af6 279 * Note that the pin must be configured as an output for this
AnnaBridge 146:22da6e220af6 280 * function to have any effect.
AnnaBridge 146:22da6e220af6 281 *
AnnaBridge 146:22da6e220af6 282 * @param pin_number Specifies the pin number (0-31) to clear.
AnnaBridge 146:22da6e220af6 283 */
AnnaBridge 146:22da6e220af6 284 __STATIC_INLINE void nrf_gpio_pin_clear(uint32_t pin_number);
AnnaBridge 146:22da6e220af6 285
AnnaBridge 146:22da6e220af6 286 /**
AnnaBridge 146:22da6e220af6 287 * @brief Function for clearing GPIO pins.
AnnaBridge 146:22da6e220af6 288 *
AnnaBridge 146:22da6e220af6 289 * Note that the pins must be configured as outputs for this
AnnaBridge 146:22da6e220af6 290 * function to have any effect.
AnnaBridge 146:22da6e220af6 291 *
AnnaBridge 146:22da6e220af6 292 * @param pin_mask Specifies the pins to clear.
AnnaBridge 146:22da6e220af6 293 */
AnnaBridge 146:22da6e220af6 294 __STATIC_INLINE void nrf_gpio_pins_clear(uint32_t pin_mask);
AnnaBridge 146:22da6e220af6 295
AnnaBridge 146:22da6e220af6 296 /**
AnnaBridge 146:22da6e220af6 297 * @brief Function for toggling a GPIO pin.
AnnaBridge 146:22da6e220af6 298 *
AnnaBridge 146:22da6e220af6 299 * Note that the pin must be configured as an output for this
AnnaBridge 146:22da6e220af6 300 * function to have any effect.
AnnaBridge 146:22da6e220af6 301 *
AnnaBridge 146:22da6e220af6 302 * @param pin_number Specifies the pin number (0-31) to toggle.
AnnaBridge 146:22da6e220af6 303 */
AnnaBridge 146:22da6e220af6 304 __STATIC_INLINE void nrf_gpio_pin_toggle(uint32_t pin_number);
AnnaBridge 146:22da6e220af6 305
AnnaBridge 146:22da6e220af6 306 /**
AnnaBridge 146:22da6e220af6 307 * @brief Function for toggling GPIO pins.
AnnaBridge 146:22da6e220af6 308 *
AnnaBridge 146:22da6e220af6 309 * Note that the pins must be configured as outputs for this
AnnaBridge 146:22da6e220af6 310 * function to have any effect.
AnnaBridge 146:22da6e220af6 311 *
AnnaBridge 146:22da6e220af6 312 * @param pin_mask Specifies the pins to toggle.
AnnaBridge 146:22da6e220af6 313 */
AnnaBridge 146:22da6e220af6 314 __STATIC_INLINE void nrf_gpio_pins_toggle(uint32_t pin_mask);
AnnaBridge 146:22da6e220af6 315
AnnaBridge 146:22da6e220af6 316 /**
AnnaBridge 146:22da6e220af6 317 * @brief Function for writing a value to a GPIO pin.
AnnaBridge 146:22da6e220af6 318 *
AnnaBridge 146:22da6e220af6 319 * Note that the pin must be configured as an output for this
AnnaBridge 146:22da6e220af6 320 * function to have any effect.
AnnaBridge 146:22da6e220af6 321 *
AnnaBridge 146:22da6e220af6 322 * @param pin_number specifies the pin number (0-31) to
AnnaBridge 146:22da6e220af6 323 * write.
AnnaBridge 146:22da6e220af6 324 *
AnnaBridge 146:22da6e220af6 325 * @param value specifies the value to be written to the pin.
AnnaBridge 146:22da6e220af6 326 * @arg 0 clears the pin
AnnaBridge 146:22da6e220af6 327 * @arg >=1 sets the pin.
AnnaBridge 146:22da6e220af6 328 */
AnnaBridge 146:22da6e220af6 329 __STATIC_INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value);
AnnaBridge 146:22da6e220af6 330
AnnaBridge 146:22da6e220af6 331 /**
AnnaBridge 146:22da6e220af6 332 * @brief Function for reading the input level of a GPIO pin.
AnnaBridge 146:22da6e220af6 333 *
AnnaBridge 146:22da6e220af6 334 * Note that the pin must have input connected for the value
AnnaBridge 146:22da6e220af6 335 * returned from this function to be valid.
AnnaBridge 146:22da6e220af6 336 *
AnnaBridge 146:22da6e220af6 337 * @param pin_number specifies the pin number (0-31) to
AnnaBridge 146:22da6e220af6 338 * read.
AnnaBridge 146:22da6e220af6 339 *
AnnaBridge 146:22da6e220af6 340 * @return
AnnaBridge 146:22da6e220af6 341 * @retval 0 if the pin input level is low.
AnnaBridge 146:22da6e220af6 342 * @retval 1 if the pin input level is high.
AnnaBridge 146:22da6e220af6 343 * @retval > 1 should never occur.
AnnaBridge 146:22da6e220af6 344 */
AnnaBridge 146:22da6e220af6 345 __STATIC_INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number);
AnnaBridge 146:22da6e220af6 346
AnnaBridge 146:22da6e220af6 347 /**
AnnaBridge 146:22da6e220af6 348 * @brief Function for reading the input level of all GPIO pins.
AnnaBridge 146:22da6e220af6 349 *
AnnaBridge 146:22da6e220af6 350 * Note that the pin must have input connected for the value
AnnaBridge 146:22da6e220af6 351 * returned from this function to be valid.
AnnaBridge 146:22da6e220af6 352 *
AnnaBridge 146:22da6e220af6 353 * @retval Status of input of all pins
AnnaBridge 146:22da6e220af6 354 */
AnnaBridge 146:22da6e220af6 355 __STATIC_INLINE uint32_t nrf_gpio_pins_read(void);
AnnaBridge 146:22da6e220af6 356
AnnaBridge 146:22da6e220af6 357 /**
AnnaBridge 146:22da6e220af6 358 * @brief Function for reading the sense configuration of a GPIO pin.
AnnaBridge 146:22da6e220af6 359 *
AnnaBridge 146:22da6e220af6 360 * @param pin_number specifies the pin number (0-31) to
AnnaBridge 146:22da6e220af6 361 * read.
AnnaBridge 146:22da6e220af6 362 *
AnnaBridge 146:22da6e220af6 363 * @retval Sense configuration
AnnaBridge 146:22da6e220af6 364 */
AnnaBridge 146:22da6e220af6 365 __STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get(uint32_t pin_number);
AnnaBridge 146:22da6e220af6 366
AnnaBridge 146:22da6e220af6 367 /**
AnnaBridge 146:22da6e220af6 368 * @brief Generic function for writing a single byte of a 32 bit word at a given
AnnaBridge 146:22da6e220af6 369 * address.
AnnaBridge 146:22da6e220af6 370 *
AnnaBridge 146:22da6e220af6 371 * This function should not be called from outside the nrf_gpio
AnnaBridge 146:22da6e220af6 372 * abstraction layer.
AnnaBridge 146:22da6e220af6 373 *
AnnaBridge 146:22da6e220af6 374 * @param word_address is the address of the word to be written.
AnnaBridge 146:22da6e220af6 375 *
AnnaBridge 146:22da6e220af6 376 * @param byte_no is the word byte number (0-3) to be written.
AnnaBridge 146:22da6e220af6 377 *
AnnaBridge 146:22da6e220af6 378 * @param value is the value to be written to byte "byte_no" of word
AnnaBridge 146:22da6e220af6 379 * at address "word_address"
AnnaBridge 146:22da6e220af6 380 */
AnnaBridge 146:22da6e220af6 381 __STATIC_INLINE void nrf_gpio_word_byte_write(volatile uint32_t * word_address, uint8_t byte_no, uint8_t value);
AnnaBridge 146:22da6e220af6 382
AnnaBridge 146:22da6e220af6 383 /**
AnnaBridge 146:22da6e220af6 384 * @brief Generic function for reading a single byte of a 32 bit word at a given
AnnaBridge 146:22da6e220af6 385 * address.
AnnaBridge 146:22da6e220af6 386 *
AnnaBridge 146:22da6e220af6 387 * This function should not be called from outside the nrf_gpio
AnnaBridge 146:22da6e220af6 388 * abstraction layer.
AnnaBridge 146:22da6e220af6 389 *
AnnaBridge 146:22da6e220af6 390 * @param word_address is the address of the word to be read.
AnnaBridge 146:22da6e220af6 391 *
AnnaBridge 146:22da6e220af6 392 * @param byte_no is the byte number (0-3) of the word to be read.
AnnaBridge 146:22da6e220af6 393 *
AnnaBridge 146:22da6e220af6 394 * @return byte "byte_no" of word at address "word_address".
AnnaBridge 146:22da6e220af6 395 */
AnnaBridge 146:22da6e220af6 396 __STATIC_INLINE uint8_t nrf_gpio_word_byte_read(const volatile uint32_t* word_address, uint8_t byte_no);
AnnaBridge 146:22da6e220af6 397
AnnaBridge 146:22da6e220af6 398 /**
AnnaBridge 146:22da6e220af6 399 * @brief Function for setting the direction of a port.
AnnaBridge 146:22da6e220af6 400 *
AnnaBridge 146:22da6e220af6 401 * @param port is the port for which to set the direction.
AnnaBridge 146:22da6e220af6 402 *
AnnaBridge 146:22da6e220af6 403 * @param dir direction to be set for this port.
AnnaBridge 146:22da6e220af6 404 */
AnnaBridge 146:22da6e220af6 405 __STATIC_INLINE void nrf_gpio_port_dir_set(nrf_gpio_port_select_t port, nrf_gpio_port_dir_t dir);
AnnaBridge 146:22da6e220af6 406
AnnaBridge 146:22da6e220af6 407 /**
AnnaBridge 146:22da6e220af6 408 * @brief Function for reading a GPIO port.
AnnaBridge 146:22da6e220af6 409 *
AnnaBridge 146:22da6e220af6 410 * @param port is the port to read.
AnnaBridge 146:22da6e220af6 411 *
AnnaBridge 146:22da6e220af6 412 * @return the input value on this port.
AnnaBridge 146:22da6e220af6 413 */
AnnaBridge 146:22da6e220af6 414 __STATIC_INLINE uint8_t nrf_gpio_port_read(nrf_gpio_port_select_t port);
AnnaBridge 146:22da6e220af6 415
AnnaBridge 146:22da6e220af6 416 /**
AnnaBridge 146:22da6e220af6 417 * @brief Function for writing to a GPIO port.
AnnaBridge 146:22da6e220af6 418 *
AnnaBridge 146:22da6e220af6 419 * @param port is the port to write.
AnnaBridge 146:22da6e220af6 420 *
AnnaBridge 146:22da6e220af6 421 * @param value is the value to write to this port.
AnnaBridge 146:22da6e220af6 422 *
AnnaBridge 146:22da6e220af6 423 * @sa nrf_gpio_port_dir_set()
AnnaBridge 146:22da6e220af6 424 */
AnnaBridge 146:22da6e220af6 425 __STATIC_INLINE void nrf_gpio_port_write(nrf_gpio_port_select_t port, uint8_t value);
AnnaBridge 146:22da6e220af6 426
AnnaBridge 146:22da6e220af6 427 /**
AnnaBridge 146:22da6e220af6 428 * @brief Function for setting individual pins on GPIO port.
AnnaBridge 146:22da6e220af6 429 *
AnnaBridge 146:22da6e220af6 430 * @param port is the port for which to set the pins.
AnnaBridge 146:22da6e220af6 431 *
AnnaBridge 146:22da6e220af6 432 * @param set_mask is a mask specifying which pins to set. A bit
AnnaBridge 146:22da6e220af6 433 * set to 1 indicates that the corresponding port pin shall be
AnnaBridge 146:22da6e220af6 434 * set.
AnnaBridge 146:22da6e220af6 435 *
AnnaBridge 146:22da6e220af6 436 * @sa nrf_gpio_port_dir_set()
AnnaBridge 146:22da6e220af6 437 */
AnnaBridge 146:22da6e220af6 438 __STATIC_INLINE void nrf_gpio_port_set(nrf_gpio_port_select_t port, uint8_t set_mask);
AnnaBridge 146:22da6e220af6 439
AnnaBridge 146:22da6e220af6 440 /**
AnnaBridge 146:22da6e220af6 441 * @brief Function for clearing individual pins on GPIO port.
AnnaBridge 146:22da6e220af6 442 *
AnnaBridge 146:22da6e220af6 443 * @param port is the port for which to clear the pins.
AnnaBridge 146:22da6e220af6 444 *
AnnaBridge 146:22da6e220af6 445 * @param clr_mask is a mask specifying which pins to clear. A bit
AnnaBridge 146:22da6e220af6 446 * set to 1 indicates that the corresponding port pin shall be
AnnaBridge 146:22da6e220af6 447 * cleared.
AnnaBridge 146:22da6e220af6 448 *
AnnaBridge 146:22da6e220af6 449 * @sa nrf_gpio_port_dir_set()
AnnaBridge 146:22da6e220af6 450 */
AnnaBridge 146:22da6e220af6 451 __STATIC_INLINE void nrf_gpio_port_clear(nrf_gpio_port_select_t port, uint8_t clr_mask);
AnnaBridge 146:22da6e220af6 452
AnnaBridge 146:22da6e220af6 453 #ifndef SUPPRESS_INLINE_IMPLEMENTATION
AnnaBridge 146:22da6e220af6 454 __STATIC_INLINE void nrf_gpio_range_cfg_output(uint32_t pin_range_start, uint32_t pin_range_end)
AnnaBridge 146:22da6e220af6 455 {
AnnaBridge 146:22da6e220af6 456 /*lint -e{845} // A zero has been given as right argument to operator '|'" */
AnnaBridge 146:22da6e220af6 457 for (; pin_range_start <= pin_range_end; pin_range_start++)
AnnaBridge 146:22da6e220af6 458 {
AnnaBridge 146:22da6e220af6 459 nrf_gpio_cfg_output(pin_range_start);
AnnaBridge 146:22da6e220af6 460 }
AnnaBridge 146:22da6e220af6 461 }
AnnaBridge 146:22da6e220af6 462
AnnaBridge 146:22da6e220af6 463 __STATIC_INLINE void nrf_gpio_range_cfg_input(uint32_t pin_range_start, uint32_t pin_range_end, nrf_gpio_pin_pull_t pull_config)
AnnaBridge 146:22da6e220af6 464 {
AnnaBridge 146:22da6e220af6 465 /*lint -e{845} // A zero has been given as right argument to operator '|'" */
AnnaBridge 146:22da6e220af6 466 for (; pin_range_start <= pin_range_end; pin_range_start++)
AnnaBridge 146:22da6e220af6 467 {
AnnaBridge 146:22da6e220af6 468 nrf_gpio_cfg_input(pin_range_start, pull_config);
AnnaBridge 146:22da6e220af6 469 }
AnnaBridge 146:22da6e220af6 470 }
AnnaBridge 146:22da6e220af6 471
AnnaBridge 146:22da6e220af6 472 __STATIC_INLINE void nrf_gpio_cfg(
AnnaBridge 146:22da6e220af6 473 uint32_t pin_number,
AnnaBridge 146:22da6e220af6 474 nrf_gpio_pin_dir_t dir,
AnnaBridge 146:22da6e220af6 475 nrf_gpio_pin_input_t input,
AnnaBridge 146:22da6e220af6 476 nrf_gpio_pin_pull_t pull,
AnnaBridge 146:22da6e220af6 477 nrf_gpio_pin_drive_t drive,
AnnaBridge 146:22da6e220af6 478 nrf_gpio_pin_sense_t sense)
AnnaBridge 146:22da6e220af6 479 {
AnnaBridge 146:22da6e220af6 480 NRF_GPIO->PIN_CNF[pin_number] = ((uint32_t)dir << GPIO_PIN_CNF_DIR_Pos)
AnnaBridge 146:22da6e220af6 481 | ((uint32_t)input << GPIO_PIN_CNF_INPUT_Pos)
AnnaBridge 146:22da6e220af6 482 | ((uint32_t)pull << GPIO_PIN_CNF_PULL_Pos)
AnnaBridge 146:22da6e220af6 483 | ((uint32_t)drive << GPIO_PIN_CNF_DRIVE_Pos)
AnnaBridge 146:22da6e220af6 484 | ((uint32_t)sense << GPIO_PIN_CNF_SENSE_Pos);
AnnaBridge 146:22da6e220af6 485 }
AnnaBridge 146:22da6e220af6 486
AnnaBridge 146:22da6e220af6 487 __STATIC_INLINE void nrf_gpio_cfg_output(uint32_t pin_number)
AnnaBridge 146:22da6e220af6 488 {
AnnaBridge 146:22da6e220af6 489 nrf_gpio_cfg(
AnnaBridge 146:22da6e220af6 490 pin_number,
AnnaBridge 146:22da6e220af6 491 NRF_GPIO_PIN_DIR_OUTPUT,
AnnaBridge 146:22da6e220af6 492 NRF_GPIO_PIN_INPUT_DISCONNECT,
AnnaBridge 146:22da6e220af6 493 NRF_GPIO_PIN_NOPULL,
AnnaBridge 146:22da6e220af6 494 NRF_GPIO_PIN_S0S1,
AnnaBridge 146:22da6e220af6 495 NRF_GPIO_PIN_NOSENSE);
AnnaBridge 146:22da6e220af6 496 }
AnnaBridge 146:22da6e220af6 497
AnnaBridge 146:22da6e220af6 498 __STATIC_INLINE void nrf_gpio_cfg_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config)
AnnaBridge 146:22da6e220af6 499 {
AnnaBridge 146:22da6e220af6 500 nrf_gpio_cfg(
AnnaBridge 146:22da6e220af6 501 pin_number,
AnnaBridge 146:22da6e220af6 502 NRF_GPIO_PIN_DIR_INPUT,
AnnaBridge 146:22da6e220af6 503 NRF_GPIO_PIN_INPUT_CONNECT,
AnnaBridge 146:22da6e220af6 504 pull_config,
AnnaBridge 146:22da6e220af6 505 NRF_GPIO_PIN_S0S1,
AnnaBridge 146:22da6e220af6 506 NRF_GPIO_PIN_NOSENSE);
AnnaBridge 146:22da6e220af6 507 }
AnnaBridge 146:22da6e220af6 508
AnnaBridge 146:22da6e220af6 509 __STATIC_INLINE void nrf_gpio_cfg_default(uint32_t pin_number)
AnnaBridge 146:22da6e220af6 510 {
AnnaBridge 146:22da6e220af6 511 nrf_gpio_cfg(
AnnaBridge 146:22da6e220af6 512 pin_number,
AnnaBridge 146:22da6e220af6 513 NRF_GPIO_PIN_DIR_INPUT,
AnnaBridge 146:22da6e220af6 514 NRF_GPIO_PIN_INPUT_DISCONNECT,
AnnaBridge 146:22da6e220af6 515 NRF_GPIO_PIN_NOPULL,
AnnaBridge 146:22da6e220af6 516 NRF_GPIO_PIN_S0S1,
AnnaBridge 146:22da6e220af6 517 NRF_GPIO_PIN_NOSENSE);
AnnaBridge 146:22da6e220af6 518 }
AnnaBridge 146:22da6e220af6 519
AnnaBridge 146:22da6e220af6 520 __STATIC_INLINE void nrf_gpio_cfg_watcher(uint32_t pin_number)
AnnaBridge 146:22da6e220af6 521 {
AnnaBridge 146:22da6e220af6 522 /*lint -e{845} // A zero has been given as right argument to operator '|'" */
AnnaBridge 146:22da6e220af6 523 uint32_t cnf = NRF_GPIO->PIN_CNF[pin_number] & ~GPIO_PIN_CNF_INPUT_Msk;
AnnaBridge 146:22da6e220af6 524 NRF_GPIO->PIN_CNF[pin_number] = cnf | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos);
AnnaBridge 146:22da6e220af6 525 }
AnnaBridge 146:22da6e220af6 526
AnnaBridge 146:22da6e220af6 527 __STATIC_INLINE void nrf_gpio_input_disconnect(uint32_t pin_number)
AnnaBridge 146:22da6e220af6 528 {
AnnaBridge 146:22da6e220af6 529 /*lint -e{845} // A zero has been given as right argument to operator '|'" */
AnnaBridge 146:22da6e220af6 530 uint32_t cnf = NRF_GPIO->PIN_CNF[pin_number] & ~GPIO_PIN_CNF_INPUT_Msk;
AnnaBridge 146:22da6e220af6 531 NRF_GPIO->PIN_CNF[pin_number] = cnf | (GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos);
AnnaBridge 146:22da6e220af6 532 }
AnnaBridge 146:22da6e220af6 533
AnnaBridge 146:22da6e220af6 534 __STATIC_INLINE void nrf_gpio_cfg_sense_input(uint32_t pin_number, nrf_gpio_pin_pull_t pull_config, nrf_gpio_pin_sense_t sense_config)
AnnaBridge 146:22da6e220af6 535 {
AnnaBridge 146:22da6e220af6 536 nrf_gpio_cfg(
AnnaBridge 146:22da6e220af6 537 pin_number,
AnnaBridge 146:22da6e220af6 538 NRF_GPIO_PIN_DIR_INPUT,
AnnaBridge 146:22da6e220af6 539 NRF_GPIO_PIN_INPUT_CONNECT,
AnnaBridge 146:22da6e220af6 540 pull_config,
AnnaBridge 146:22da6e220af6 541 NRF_GPIO_PIN_S0S1,
AnnaBridge 146:22da6e220af6 542 sense_config);
AnnaBridge 146:22da6e220af6 543 }
AnnaBridge 146:22da6e220af6 544
AnnaBridge 146:22da6e220af6 545 __STATIC_INLINE void nrf_gpio_cfg_sense_set(uint32_t pin_number, nrf_gpio_pin_sense_t sense_config)
AnnaBridge 146:22da6e220af6 546 {
AnnaBridge 146:22da6e220af6 547 /*lint -e{845} // A zero has been given as right argument to operator '|'" */
AnnaBridge 146:22da6e220af6 548 //uint32_t cnf = NRF_GPIO->PIN_CNF[pin_number] & ~GPIO_PIN_CNF_SENSE_Msk;
AnnaBridge 146:22da6e220af6 549 NRF_GPIO->PIN_CNF[pin_number] &= ~GPIO_PIN_CNF_SENSE_Msk;
AnnaBridge 146:22da6e220af6 550 NRF_GPIO->PIN_CNF[pin_number] |= (sense_config << GPIO_PIN_CNF_SENSE_Pos);
AnnaBridge 146:22da6e220af6 551 }
AnnaBridge 146:22da6e220af6 552
AnnaBridge 146:22da6e220af6 553 __STATIC_INLINE void nrf_gpio_pin_dir_set(uint32_t pin_number, nrf_gpio_pin_dir_t direction)
AnnaBridge 146:22da6e220af6 554 {
AnnaBridge 146:22da6e220af6 555 if(direction == NRF_GPIO_PIN_DIR_INPUT)
AnnaBridge 146:22da6e220af6 556 {
AnnaBridge 146:22da6e220af6 557 nrf_gpio_cfg(
AnnaBridge 146:22da6e220af6 558 pin_number,
AnnaBridge 146:22da6e220af6 559 NRF_GPIO_PIN_DIR_INPUT,
AnnaBridge 146:22da6e220af6 560 NRF_GPIO_PIN_INPUT_CONNECT,
AnnaBridge 146:22da6e220af6 561 NRF_GPIO_PIN_NOPULL,
AnnaBridge 146:22da6e220af6 562 NRF_GPIO_PIN_S0S1,
AnnaBridge 146:22da6e220af6 563 NRF_GPIO_PIN_NOSENSE);
AnnaBridge 146:22da6e220af6 564 }
AnnaBridge 146:22da6e220af6 565 else
AnnaBridge 146:22da6e220af6 566 {
AnnaBridge 146:22da6e220af6 567 NRF_GPIO->DIRSET = (1UL << pin_number);
AnnaBridge 146:22da6e220af6 568 }
AnnaBridge 146:22da6e220af6 569 }
AnnaBridge 146:22da6e220af6 570
AnnaBridge 146:22da6e220af6 571 __STATIC_INLINE void nrf_gpio_pin_set(uint32_t pin_number)
AnnaBridge 146:22da6e220af6 572 {
AnnaBridge 146:22da6e220af6 573 NRF_GPIO->OUTSET = (1UL << pin_number);
AnnaBridge 146:22da6e220af6 574 }
AnnaBridge 146:22da6e220af6 575
AnnaBridge 146:22da6e220af6 576 __STATIC_INLINE void nrf_gpio_pins_set(uint32_t pin_mask)
AnnaBridge 146:22da6e220af6 577 {
AnnaBridge 146:22da6e220af6 578 NRF_GPIO->OUTSET = pin_mask;
AnnaBridge 146:22da6e220af6 579 }
AnnaBridge 146:22da6e220af6 580
AnnaBridge 146:22da6e220af6 581 __STATIC_INLINE void nrf_gpio_pin_clear(uint32_t pin_number)
AnnaBridge 146:22da6e220af6 582 {
AnnaBridge 146:22da6e220af6 583 NRF_GPIO->OUTCLR = (1UL << pin_number);
AnnaBridge 146:22da6e220af6 584 }
AnnaBridge 146:22da6e220af6 585
AnnaBridge 146:22da6e220af6 586 __STATIC_INLINE void nrf_gpio_pins_clear(uint32_t pin_mask)
AnnaBridge 146:22da6e220af6 587 {
AnnaBridge 146:22da6e220af6 588 NRF_GPIO->OUTCLR = pin_mask;
AnnaBridge 146:22da6e220af6 589 }
AnnaBridge 146:22da6e220af6 590
AnnaBridge 146:22da6e220af6 591 __STATIC_INLINE void nrf_gpio_pin_toggle(uint32_t pin_number)
AnnaBridge 146:22da6e220af6 592 {
AnnaBridge 146:22da6e220af6 593 nrf_gpio_pins_toggle(1UL << pin_number);
AnnaBridge 146:22da6e220af6 594 }
AnnaBridge 146:22da6e220af6 595
AnnaBridge 146:22da6e220af6 596 __STATIC_INLINE void nrf_gpio_pins_toggle(uint32_t pin_mask)
AnnaBridge 146:22da6e220af6 597 {
AnnaBridge 146:22da6e220af6 598 uint32_t pins_state = NRF_GPIO->OUT;
AnnaBridge 146:22da6e220af6 599 NRF_GPIO->OUTSET = (~pins_state & pin_mask);
AnnaBridge 146:22da6e220af6 600 NRF_GPIO->OUTCLR = ( pins_state & pin_mask);
AnnaBridge 146:22da6e220af6 601 }
AnnaBridge 146:22da6e220af6 602
AnnaBridge 146:22da6e220af6 603 __STATIC_INLINE void nrf_gpio_pin_write(uint32_t pin_number, uint32_t value)
AnnaBridge 146:22da6e220af6 604 {
AnnaBridge 146:22da6e220af6 605 if (value == 0)
AnnaBridge 146:22da6e220af6 606 {
AnnaBridge 146:22da6e220af6 607 nrf_gpio_pin_clear(pin_number);
AnnaBridge 146:22da6e220af6 608 }
AnnaBridge 146:22da6e220af6 609 else
AnnaBridge 146:22da6e220af6 610 {
AnnaBridge 146:22da6e220af6 611 nrf_gpio_pin_set(pin_number);
AnnaBridge 146:22da6e220af6 612 }
AnnaBridge 146:22da6e220af6 613 }
AnnaBridge 146:22da6e220af6 614
AnnaBridge 146:22da6e220af6 615 __STATIC_INLINE uint32_t nrf_gpio_pin_read(uint32_t pin_number)
AnnaBridge 146:22da6e220af6 616 {
AnnaBridge 146:22da6e220af6 617 return ((NRF_GPIO->IN >> pin_number) & 1UL);
AnnaBridge 146:22da6e220af6 618 }
AnnaBridge 146:22da6e220af6 619
AnnaBridge 146:22da6e220af6 620 __STATIC_INLINE uint32_t nrf_gpio_pins_read(void)
AnnaBridge 146:22da6e220af6 621 {
AnnaBridge 146:22da6e220af6 622 return NRF_GPIO->IN;
AnnaBridge 146:22da6e220af6 623 }
AnnaBridge 146:22da6e220af6 624
AnnaBridge 146:22da6e220af6 625 __STATIC_INLINE nrf_gpio_pin_sense_t nrf_gpio_pin_sense_get(uint32_t pin_number)
AnnaBridge 146:22da6e220af6 626 {
AnnaBridge 146:22da6e220af6 627 return (nrf_gpio_pin_sense_t)((NRF_GPIO->PIN_CNF[pin_number] & GPIO_PIN_CNF_SENSE_Msk) >> GPIO_PIN_CNF_SENSE_Pos);
AnnaBridge 146:22da6e220af6 628 }
AnnaBridge 146:22da6e220af6 629
AnnaBridge 146:22da6e220af6 630 __STATIC_INLINE void nrf_gpio_word_byte_write(volatile uint32_t * word_address, uint8_t byte_no, uint8_t value)
AnnaBridge 146:22da6e220af6 631 {
AnnaBridge 146:22da6e220af6 632 *((volatile uint8_t*)(word_address) + byte_no) = value;
AnnaBridge 146:22da6e220af6 633 }
AnnaBridge 146:22da6e220af6 634
AnnaBridge 146:22da6e220af6 635 __STATIC_INLINE uint8_t nrf_gpio_word_byte_read(const volatile uint32_t* word_address, uint8_t byte_no)
AnnaBridge 146:22da6e220af6 636 {
AnnaBridge 146:22da6e220af6 637 return (*((const volatile uint8_t*)(word_address) + byte_no));
AnnaBridge 146:22da6e220af6 638 }
AnnaBridge 146:22da6e220af6 639
AnnaBridge 146:22da6e220af6 640 __STATIC_INLINE void nrf_gpio_port_dir_set(nrf_gpio_port_select_t port, nrf_gpio_port_dir_t dir)
AnnaBridge 146:22da6e220af6 641 {
AnnaBridge 146:22da6e220af6 642 if (dir == NRF_GPIO_PORT_DIR_OUTPUT)
AnnaBridge 146:22da6e220af6 643 {
AnnaBridge 146:22da6e220af6 644 nrf_gpio_word_byte_write(&NRF_GPIO->DIRSET, port, 0xFF);
AnnaBridge 146:22da6e220af6 645 }
AnnaBridge 146:22da6e220af6 646 else
AnnaBridge 146:22da6e220af6 647 {
AnnaBridge 146:22da6e220af6 648 nrf_gpio_range_cfg_input(port*8, (port+1)*8-1, NRF_GPIO_PIN_NOPULL);
AnnaBridge 146:22da6e220af6 649 }
AnnaBridge 146:22da6e220af6 650 }
AnnaBridge 146:22da6e220af6 651
AnnaBridge 146:22da6e220af6 652 __STATIC_INLINE uint8_t nrf_gpio_port_read(nrf_gpio_port_select_t port)
AnnaBridge 146:22da6e220af6 653 {
AnnaBridge 146:22da6e220af6 654 return nrf_gpio_word_byte_read(&NRF_GPIO->IN, port);
AnnaBridge 146:22da6e220af6 655 }
AnnaBridge 146:22da6e220af6 656
AnnaBridge 146:22da6e220af6 657 __STATIC_INLINE void nrf_gpio_port_write(nrf_gpio_port_select_t port, uint8_t value)
AnnaBridge 146:22da6e220af6 658 {
AnnaBridge 146:22da6e220af6 659 nrf_gpio_word_byte_write(&NRF_GPIO->OUT, port, value);
AnnaBridge 146:22da6e220af6 660 }
AnnaBridge 146:22da6e220af6 661
AnnaBridge 146:22da6e220af6 662 __STATIC_INLINE void nrf_gpio_port_set(nrf_gpio_port_select_t port, uint8_t set_mask)
AnnaBridge 146:22da6e220af6 663 {
AnnaBridge 146:22da6e220af6 664 nrf_gpio_word_byte_write(&NRF_GPIO->OUTSET, port, set_mask);
AnnaBridge 146:22da6e220af6 665 }
AnnaBridge 146:22da6e220af6 666
AnnaBridge 146:22da6e220af6 667 __STATIC_INLINE void nrf_gpio_port_clear(nrf_gpio_port_select_t port, uint8_t clr_mask)
AnnaBridge 146:22da6e220af6 668 {
AnnaBridge 146:22da6e220af6 669 nrf_gpio_word_byte_write(&NRF_GPIO->OUTCLR, port, clr_mask);
AnnaBridge 146:22da6e220af6 670 }
AnnaBridge 146:22da6e220af6 671 #endif //SUPPRESS_INLINE_IMPLEMENTATION
AnnaBridge 146:22da6e220af6 672 /** @} */
AnnaBridge 146:22da6e220af6 673
AnnaBridge 146:22da6e220af6 674 #endif