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_SAMD21G18A/TARGET_Atmel/TARGET_SAM_CortexM0P/drivers/port/port.h@111:4336505e4b1c
mbed library. Release version 164

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 111:4336505e4b1c 1 /**
Kojto 111:4336505e4b1c 2 * \file
Kojto 111:4336505e4b1c 3 *
Kojto 111:4336505e4b1c 4 * \brief SAM GPIO Port Driver
Kojto 111:4336505e4b1c 5 *
Kojto 111:4336505e4b1c 6 * Copyright (C) 2012-2015 Atmel Corporation. All rights reserved.
Kojto 111:4336505e4b1c 7 *
Kojto 111:4336505e4b1c 8 * \asf_license_start
Kojto 111:4336505e4b1c 9 *
Kojto 111:4336505e4b1c 10 * \page License
Kojto 111:4336505e4b1c 11 *
Kojto 111:4336505e4b1c 12 * Redistribution and use in source and binary forms, with or without
Kojto 111:4336505e4b1c 13 * modification, are permitted provided that the following conditions are met:
Kojto 111:4336505e4b1c 14 *
Kojto 111:4336505e4b1c 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 111:4336505e4b1c 16 * this list of conditions and the following disclaimer.
Kojto 111:4336505e4b1c 17 *
Kojto 111:4336505e4b1c 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 111:4336505e4b1c 19 * this list of conditions and the following disclaimer in the documentation
Kojto 111:4336505e4b1c 20 * and/or other materials provided with the distribution.
Kojto 111:4336505e4b1c 21 *
Kojto 111:4336505e4b1c 22 * 3. The name of Atmel may not be used to endorse or promote products derived
Kojto 111:4336505e4b1c 23 * from this software without specific prior written permission.
Kojto 111:4336505e4b1c 24 *
Kojto 111:4336505e4b1c 25 * 4. This software may only be redistributed and used in connection with an
Kojto 111:4336505e4b1c 26 * Atmel microcontroller product.
Kojto 111:4336505e4b1c 27 *
Kojto 111:4336505e4b1c 28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
Kojto 111:4336505e4b1c 29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
Kojto 111:4336505e4b1c 30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
Kojto 111:4336505e4b1c 31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
Kojto 111:4336505e4b1c 32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 111:4336505e4b1c 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Kojto 111:4336505e4b1c 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Kojto 111:4336505e4b1c 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
Kojto 111:4336505e4b1c 36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
Kojto 111:4336505e4b1c 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Kojto 111:4336505e4b1c 38 * POSSIBILITY OF SUCH DAMAGE.
Kojto 111:4336505e4b1c 39 *
Kojto 111:4336505e4b1c 40 * \asf_license_stop
Kojto 111:4336505e4b1c 41 *
Kojto 111:4336505e4b1c 42 */
Kojto 111:4336505e4b1c 43 /*
Kojto 111:4336505e4b1c 44 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
Kojto 111:4336505e4b1c 45 */
Kojto 111:4336505e4b1c 46 #ifndef PORT_H_INCLUDED
Kojto 111:4336505e4b1c 47 #define PORT_H_INCLUDED
Kojto 111:4336505e4b1c 48
Kojto 111:4336505e4b1c 49 /**
Kojto 111:4336505e4b1c 50 * \defgroup asfdoc_sam0_port_group SAM Port Driver (PORT)
Kojto 111:4336505e4b1c 51 *
Kojto 111:4336505e4b1c 52 * This driver for Atmel&reg; | SMART SAM devices provides an interface for the configuration
Kojto 111:4336505e4b1c 53 * and management of the device's General Purpose Input/Output (GPIO) pin
Kojto 111:4336505e4b1c 54 * functionality, for manual pin state reading and writing.
Kojto 111:4336505e4b1c 55 *
Kojto 111:4336505e4b1c 56 * The following peripherals are used by this module:
Kojto 111:4336505e4b1c 57 * - PORT (GPIO Management)
Kojto 111:4336505e4b1c 58 *
Kojto 111:4336505e4b1c 59 * The following devices can use this module:
Kojto 111:4336505e4b1c 60 * - Atmel | SMART SAM D20/D21
Kojto 111:4336505e4b1c 61 * - Atmel | SMART SAM R21
Kojto 111:4336505e4b1c 62 * - Atmel | SMART SAM D10/D11
Kojto 111:4336505e4b1c 63 * - Atmel | SMART SAM L21
Kojto 111:4336505e4b1c 64 * - Atmel | SMART SAM DAx
Kojto 111:4336505e4b1c 65 * - Atmel | SMART SAM C20/C21
Kojto 111:4336505e4b1c 66 *
Kojto 111:4336505e4b1c 67 * The outline of this documentation is as follows:
Kojto 111:4336505e4b1c 68 * - \ref asfdoc_sam0_port_prerequisites
Kojto 111:4336505e4b1c 69 * - \ref asfdoc_sam0_port_module_overview
Kojto 111:4336505e4b1c 70 * - \ref asfdoc_sam0_port_special_considerations
Kojto 111:4336505e4b1c 71 * - \ref asfdoc_sam0_port_extra_info
Kojto 111:4336505e4b1c 72 * - \ref asfdoc_sam0_port_examples
Kojto 111:4336505e4b1c 73 * - \ref asfdoc_sam0_port_api_overview
Kojto 111:4336505e4b1c 74 *
Kojto 111:4336505e4b1c 75 *
Kojto 111:4336505e4b1c 76 * \section asfdoc_sam0_port_prerequisites Prerequisites
Kojto 111:4336505e4b1c 77 *
Kojto 111:4336505e4b1c 78 * There are no prerequisites for this module.
Kojto 111:4336505e4b1c 79 *
Kojto 111:4336505e4b1c 80 *
Kojto 111:4336505e4b1c 81 * \section asfdoc_sam0_port_module_overview Module Overview
Kojto 111:4336505e4b1c 82 *
Kojto 111:4336505e4b1c 83 * The device GPIO (PORT) module provides an interface between the user
Kojto 111:4336505e4b1c 84 * application logic and external hardware peripherals, when general pin state
Kojto 111:4336505e4b1c 85 * manipulation is required. This driver provides an easy-to-use interface to
Kojto 111:4336505e4b1c 86 * the physical pin input samplers and output drivers, so that pins can be read
Kojto 111:4336505e4b1c 87 * from or written to for general purpose external hardware control.
Kojto 111:4336505e4b1c 88 *
Kojto 111:4336505e4b1c 89 * \subsection asfdoc_sam0_port_features Driver Feature Macro Definition
Kojto 111:4336505e4b1c 90 * <table>
Kojto 111:4336505e4b1c 91 * <tr>
Kojto 111:4336505e4b1c 92 * <th>Driver Feature Macro</th>
Kojto 111:4336505e4b1c 93 * <th>Supported devices</th>
Kojto 111:4336505e4b1c 94 * </tr>
Kojto 111:4336505e4b1c 95 * <tr>
Kojto 111:4336505e4b1c 96 * <td>FEATURE_PORT_INPUT_EVENT</td>
Kojto 111:4336505e4b1c 97 * <td>SAML21/C20/C21</td>
Kojto 111:4336505e4b1c 98 * </tr>
Kojto 111:4336505e4b1c 99 * </table>
Kojto 111:4336505e4b1c 100 * \note The specific features are only available in the driver when the
Kojto 111:4336505e4b1c 101 * selected device supports those features.
Kojto 111:4336505e4b1c 102 *
Kojto 111:4336505e4b1c 103 * \subsection asfdoc_sam0_port_module_overview_pin_numbering Physical and Logical GPIO Pins
Kojto 111:4336505e4b1c 104 * SAM devices use two naming conventions for the I/O pins in the device; one
Kojto 111:4336505e4b1c 105 * physical and one logical. Each physical pin on a device package is assigned
Kojto 111:4336505e4b1c 106 * both a physical port and pin identifier (e.g. "PORTA.0") as well as a
Kojto 111:4336505e4b1c 107 * monotonically incrementing logical GPIO number (e.g. "GPIO0"). While the
Kojto 111:4336505e4b1c 108 * former is used to map physical pins to their physical internal device module
Kojto 111:4336505e4b1c 109 * counterparts, for simplicity the design of this driver uses the logical GPIO
Kojto 111:4336505e4b1c 110 * numbers instead.
Kojto 111:4336505e4b1c 111 *
Kojto 111:4336505e4b1c 112 * \subsection asfdoc_sam0_port_module_overview_physical Physical Connection
Kojto 111:4336505e4b1c 113 *
Kojto 111:4336505e4b1c 114 * \ref asfdoc_sam0_port_module_int_connections "The diagram below" shows how
Kojto 111:4336505e4b1c 115 * this module is interconnected within the device.
Kojto 111:4336505e4b1c 116 *
Kojto 111:4336505e4b1c 117 * \anchor asfdoc_sam0_port_module_int_connections
Kojto 111:4336505e4b1c 118 * \dot
Kojto 111:4336505e4b1c 119 * digraph overview {
Kojto 111:4336505e4b1c 120 * node [label="Port Pad" shape=square] pad;
Kojto 111:4336505e4b1c 121 *
Kojto 111:4336505e4b1c 122 * subgraph driver {
Kojto 111:4336505e4b1c 123 * node [label="Peripheral MUX" shape=trapezium] pinmux;
Kojto 111:4336505e4b1c 124 * node [label="GPIO Module" shape=ellipse] gpio;
Kojto 111:4336505e4b1c 125 * node [label="Other Peripheral Modules" shape=ellipse style=filled fillcolor=lightgray] peripherals;
Kojto 111:4336505e4b1c 126 * }
Kojto 111:4336505e4b1c 127 *
Kojto 111:4336505e4b1c 128 * pinmux -> gpio;
Kojto 111:4336505e4b1c 129 * pad -> pinmux;
Kojto 111:4336505e4b1c 130 * pinmux -> peripherals;
Kojto 111:4336505e4b1c 131 * }
Kojto 111:4336505e4b1c 132 * \enddot
Kojto 111:4336505e4b1c 133 *
Kojto 111:4336505e4b1c 134 *
Kojto 111:4336505e4b1c 135 * \section asfdoc_sam0_port_special_considerations Special Considerations
Kojto 111:4336505e4b1c 136 *
Kojto 111:4336505e4b1c 137 * The SAM port pin input sampler can be disabled when the pin is configured
Kojto 111:4336505e4b1c 138 * in pure output mode to save power; reading the pin state of a pin configured
Kojto 111:4336505e4b1c 139 * in output-only mode will read the logical output state that was last set.
Kojto 111:4336505e4b1c 140 *
Kojto 111:4336505e4b1c 141 * \section asfdoc_sam0_port_extra_info Extra Information
Kojto 111:4336505e4b1c 142 *
Kojto 111:4336505e4b1c 143 * For extra information, see \ref asfdoc_sam0_port_extra. This includes:
Kojto 111:4336505e4b1c 144 * - \ref asfdoc_sam0_port_extra_acronyms
Kojto 111:4336505e4b1c 145 * - \ref asfdoc_sam0_port_extra_dependencies
Kojto 111:4336505e4b1c 146 * - \ref asfdoc_sam0_port_extra_errata
Kojto 111:4336505e4b1c 147 * - \ref asfdoc_sam0_port_extra_history
Kojto 111:4336505e4b1c 148 *
Kojto 111:4336505e4b1c 149 *
Kojto 111:4336505e4b1c 150 * \section asfdoc_sam0_port_examples Examples
Kojto 111:4336505e4b1c 151 *
Kojto 111:4336505e4b1c 152 * For a list of examples related to this driver, see
Kojto 111:4336505e4b1c 153 * \ref asfdoc_sam0_port_exqsg.
Kojto 111:4336505e4b1c 154 *
Kojto 111:4336505e4b1c 155 *
Kojto 111:4336505e4b1c 156 * \section asfdoc_sam0_port_api_overview API Overview
Kojto 111:4336505e4b1c 157 * @{
Kojto 111:4336505e4b1c 158 */
Kojto 111:4336505e4b1c 159
Kojto 111:4336505e4b1c 160 #include <compiler.h>
Kojto 111:4336505e4b1c 161 #include <pinmux.h>
Kojto 111:4336505e4b1c 162
Kojto 111:4336505e4b1c 163 #ifdef __cplusplus
Kojto 111:4336505e4b1c 164 extern "C" {
Kojto 111:4336505e4b1c 165 #endif
Kojto 111:4336505e4b1c 166
Kojto 111:4336505e4b1c 167 /**
Kojto 111:4336505e4b1c 168 * \name Driver Feature Definition
Kojto 111:4336505e4b1c 169 * Define port features set according to different device family.
Kojto 111:4336505e4b1c 170 * @{
Kojto 111:4336505e4b1c 171 */
Kojto 111:4336505e4b1c 172 #if (SAML21) || (SAMC20) || (SAMC21) || defined(__DOXYGEN__)
Kojto 111:4336505e4b1c 173 /** Event input control feature support for PORT group. */
Kojto 111:4336505e4b1c 174 # define FEATURE_PORT_INPUT_EVENT
Kojto 111:4336505e4b1c 175 #endif
Kojto 111:4336505e4b1c 176 /*@}*/
Kojto 111:4336505e4b1c 177
Kojto 111:4336505e4b1c 178 /** \name PORT Alias Macros
Kojto 111:4336505e4b1c 179 * @{
Kojto 111:4336505e4b1c 180 */
Kojto 111:4336505e4b1c 181
Kojto 111:4336505e4b1c 182 /** Convenience definition for GPIO module group A on the device (if
Kojto 111:4336505e4b1c 183 * available). */
Kojto 111:4336505e4b1c 184 #if (PORT_GROUPS > 0) || defined(__DOXYGEN__)
Kojto 111:4336505e4b1c 185 # define PORTA PORT->Group[0]
Kojto 111:4336505e4b1c 186 #endif
Kojto 111:4336505e4b1c 187
Kojto 111:4336505e4b1c 188 #if (PORT_GROUPS > 1) || defined(__DOXYGEN__)
Kojto 111:4336505e4b1c 189 /** Convenience definition for GPIO module group B on the device (if
Kojto 111:4336505e4b1c 190 * available). */
Kojto 111:4336505e4b1c 191 # define PORTB PORT->Group[1]
Kojto 111:4336505e4b1c 192 #endif
Kojto 111:4336505e4b1c 193
Kojto 111:4336505e4b1c 194 #if (PORT_GROUPS > 2) || defined(__DOXYGEN__)
Kojto 111:4336505e4b1c 195 /** Convenience definition for GPIO module group C on the device (if
Kojto 111:4336505e4b1c 196 * available). */
Kojto 111:4336505e4b1c 197 # define PORTC PORT->Group[2]
Kojto 111:4336505e4b1c 198 #endif
Kojto 111:4336505e4b1c 199
Kojto 111:4336505e4b1c 200 #if (PORT_GROUPS > 3) || defined(__DOXYGEN__)
Kojto 111:4336505e4b1c 201 /** Convenience definition for GPIO module group D on the device (if
Kojto 111:4336505e4b1c 202 * available). */
Kojto 111:4336505e4b1c 203 # define PORTD PORT->Group[3]
Kojto 111:4336505e4b1c 204 #endif
Kojto 111:4336505e4b1c 205
Kojto 111:4336505e4b1c 206 /** @} */
Kojto 111:4336505e4b1c 207
Kojto 111:4336505e4b1c 208 /**
Kojto 111:4336505e4b1c 209 * \brief Port pin direction configuration enum.
Kojto 111:4336505e4b1c 210 *
Kojto 111:4336505e4b1c 211 * Enum for the possible pin direction settings of the port pin configuration
Kojto 111:4336505e4b1c 212 * structure, to indicate the direction the pin should use.
Kojto 111:4336505e4b1c 213 */
Kojto 111:4336505e4b1c 214 enum port_pin_dir {
Kojto 111:4336505e4b1c 215 /** The pin's input buffer should be enabled, so that the pin state can
Kojto 111:4336505e4b1c 216 * be read. */
Kojto 111:4336505e4b1c 217 PORT_PIN_DIR_INPUT = SYSTEM_PINMUX_PIN_DIR_INPUT,
Kojto 111:4336505e4b1c 218 /** The pin's output buffer should be enabled, so that the pin state can
Kojto 111:4336505e4b1c 219 * be set. */
Kojto 111:4336505e4b1c 220 PORT_PIN_DIR_OUTPUT = SYSTEM_PINMUX_PIN_DIR_OUTPUT,
Kojto 111:4336505e4b1c 221 /** The pin's output and input buffers should be enabled, so that the pin
Kojto 111:4336505e4b1c 222 * state can be set and read back. */
Kojto 111:4336505e4b1c 223 PORT_PIN_DIR_OUTPUT_WTH_READBACK = SYSTEM_PINMUX_PIN_DIR_OUTPUT_WITH_READBACK,
Kojto 111:4336505e4b1c 224 };
Kojto 111:4336505e4b1c 225
Kojto 111:4336505e4b1c 226 /**
Kojto 111:4336505e4b1c 227 * \brief Port pin input pull configuration enum.
Kojto 111:4336505e4b1c 228 *
Kojto 111:4336505e4b1c 229 * Enum for the possible pin pull settings of the port pin configuration
Kojto 111:4336505e4b1c 230 * structure, to indicate the type of logic level pull the pin should use.
Kojto 111:4336505e4b1c 231 */
Kojto 111:4336505e4b1c 232 enum port_pin_pull {
Kojto 111:4336505e4b1c 233 /** No logical pull should be applied to the pin. */
Kojto 111:4336505e4b1c 234 PORT_PIN_PULL_NONE = SYSTEM_PINMUX_PIN_PULL_NONE,
Kojto 111:4336505e4b1c 235 /** Pin should be pulled up when idle. */
Kojto 111:4336505e4b1c 236 PORT_PIN_PULL_UP = SYSTEM_PINMUX_PIN_PULL_UP,
Kojto 111:4336505e4b1c 237 /** Pin should be pulled down when idle. */
Kojto 111:4336505e4b1c 238 PORT_PIN_PULL_DOWN = SYSTEM_PINMUX_PIN_PULL_DOWN,
Kojto 111:4336505e4b1c 239 };
Kojto 111:4336505e4b1c 240
Kojto 111:4336505e4b1c 241 #ifdef FEATURE_PORT_INPUT_EVENT
Kojto 111:4336505e4b1c 242 /**
Kojto 111:4336505e4b1c 243 * \brief Port input event action.
Kojto 111:4336505e4b1c 244 *
Kojto 111:4336505e4b1c 245 * List of port input events action on pin.
Kojto 111:4336505e4b1c 246 */
Kojto 111:4336505e4b1c 247 enum port_input_event_action {
Kojto 111:4336505e4b1c 248 /** Event out to pin. */
Kojto 111:4336505e4b1c 249 PORT_INPUT_EVENT_ACTION_OUT = 0,
Kojto 111:4336505e4b1c 250 /** Set output register of pin on event. */
Kojto 111:4336505e4b1c 251 PORT_INPUT_EVENT_ACTION_SET,
Kojto 111:4336505e4b1c 252 /** Clear output register pin on event. */
Kojto 111:4336505e4b1c 253 PORT_INPUT_EVENT_ACTION_CLR,
Kojto 111:4336505e4b1c 254 /** Toggle output register pin on event. */
Kojto 111:4336505e4b1c 255 PORT_INPUT_EVENT_ACTION_TGL,
Kojto 111:4336505e4b1c 256 };
Kojto 111:4336505e4b1c 257
Kojto 111:4336505e4b1c 258 /**
Kojto 111:4336505e4b1c 259 * \brief Port input event.
Kojto 111:4336505e4b1c 260 *
Kojto 111:4336505e4b1c 261 * List of port input events.
Kojto 111:4336505e4b1c 262 */
Kojto 111:4336505e4b1c 263 enum port_input_event {
Kojto 111:4336505e4b1c 264 /** Port input event 0. */
Kojto 111:4336505e4b1c 265 PORT_INPUT_EVENT_0 = 0,
Kojto 111:4336505e4b1c 266 /** Port input event 1. */
Kojto 111:4336505e4b1c 267 PORT_INPUT_EVENT_1 = 1,
Kojto 111:4336505e4b1c 268 /** Port input event 2. */
Kojto 111:4336505e4b1c 269 PORT_INPUT_EVENT_2 = 2,
Kojto 111:4336505e4b1c 270 /** Port input event 3. */
Kojto 111:4336505e4b1c 271 PORT_INPUT_EVENT_3 = 3,
Kojto 111:4336505e4b1c 272 };
Kojto 111:4336505e4b1c 273
Kojto 111:4336505e4b1c 274 /**
Kojto 111:4336505e4b1c 275 * \brief Port input event configuration structure.
Kojto 111:4336505e4b1c 276 *
Kojto 111:4336505e4b1c 277 * Configuration structure for a port input event.
Kojto 111:4336505e4b1c 278 */
Kojto 111:4336505e4b1c 279 struct port_input_event_config {
Kojto 111:4336505e4b1c 280 /** Port input event action. */
Kojto 111:4336505e4b1c 281 enum port_input_event_action action;
Kojto 111:4336505e4b1c 282 /** GPIO pin. */
Kojto 111:4336505e4b1c 283 uint8_t gpio_pin;
Kojto 111:4336505e4b1c 284 };
Kojto 111:4336505e4b1c 285 #endif
Kojto 111:4336505e4b1c 286
Kojto 111:4336505e4b1c 287 /**
Kojto 111:4336505e4b1c 288 * \brief Port pin configuration structure.
Kojto 111:4336505e4b1c 289 *
Kojto 111:4336505e4b1c 290 * Configuration structure for a port pin instance. This structure should be
Kojto 111:4336505e4b1c 291 * initialized by the \ref port_get_config_defaults() function before being
Kojto 111:4336505e4b1c 292 * modified by the user application.
Kojto 111:4336505e4b1c 293 */
Kojto 111:4336505e4b1c 294 struct port_config {
Kojto 111:4336505e4b1c 295 /** Port buffer input/output direction. */
Kojto 111:4336505e4b1c 296 enum port_pin_dir direction;
Kojto 111:4336505e4b1c 297
Kojto 111:4336505e4b1c 298 /** Port pull-up/pull-down for input pins. */
Kojto 111:4336505e4b1c 299 enum port_pin_pull input_pull;
Kojto 111:4336505e4b1c 300
Kojto 111:4336505e4b1c 301 /** Enable lowest possible powerstate on the pin.
Kojto 111:4336505e4b1c 302 *
Kojto 111:4336505e4b1c 303 * \note All other configurations will be ignored, the pin will be disabled.
Kojto 111:4336505e4b1c 304 */
Kojto 111:4336505e4b1c 305 bool powersave;
Kojto 111:4336505e4b1c 306 };
Kojto 111:4336505e4b1c 307
Kojto 111:4336505e4b1c 308 /** \name State Reading/Writing (Physical Group Orientated)
Kojto 111:4336505e4b1c 309 * @{
Kojto 111:4336505e4b1c 310 */
Kojto 111:4336505e4b1c 311
Kojto 111:4336505e4b1c 312 /**
Kojto 111:4336505e4b1c 313 * \brief Retrieves the PORT module group instance from a given GPIO pin number.
Kojto 111:4336505e4b1c 314 *
Kojto 111:4336505e4b1c 315 * Retrieves the PORT module group instance associated with a given logical
Kojto 111:4336505e4b1c 316 * GPIO pin number.
Kojto 111:4336505e4b1c 317 *
Kojto 111:4336505e4b1c 318 * \param[in] gpio_pin Index of the GPIO pin to convert
Kojto 111:4336505e4b1c 319 *
Kojto 111:4336505e4b1c 320 * \return Base address of the associated PORT module.
Kojto 111:4336505e4b1c 321 */
Kojto 111:4336505e4b1c 322 static inline PortGroup* port_get_group_from_gpio_pin(
Kojto 111:4336505e4b1c 323 const uint8_t gpio_pin)
Kojto 111:4336505e4b1c 324 {
Kojto 111:4336505e4b1c 325 return system_pinmux_get_group_from_gpio_pin(gpio_pin);
Kojto 111:4336505e4b1c 326 }
Kojto 111:4336505e4b1c 327
Kojto 111:4336505e4b1c 328 /**
Kojto 111:4336505e4b1c 329 * \brief Retrieves the state of a group of port pins that are configured as inputs.
Kojto 111:4336505e4b1c 330 *
Kojto 111:4336505e4b1c 331 * Reads the current logic level of a port module's pins and returns the
Kojto 111:4336505e4b1c 332 * current levels as a bitmask.
Kojto 111:4336505e4b1c 333 *
Kojto 111:4336505e4b1c 334 * \param[in] port Base of the PORT module to read from
Kojto 111:4336505e4b1c 335 * \param[in] mask Mask of the port pin(s) to read
Kojto 111:4336505e4b1c 336 *
Kojto 111:4336505e4b1c 337 * \return Status of the port pin(s) input buffers.
Kojto 111:4336505e4b1c 338 */
Kojto 111:4336505e4b1c 339 static inline uint32_t port_group_get_input_level(
Kojto 111:4336505e4b1c 340 const PortGroup *const port,
Kojto 111:4336505e4b1c 341 const uint32_t mask)
Kojto 111:4336505e4b1c 342 {
Kojto 111:4336505e4b1c 343 /* Sanity check arguments */
Kojto 111:4336505e4b1c 344 Assert(port);
Kojto 111:4336505e4b1c 345
Kojto 111:4336505e4b1c 346 return (port->IN.reg & mask);
Kojto 111:4336505e4b1c 347 }
Kojto 111:4336505e4b1c 348
Kojto 111:4336505e4b1c 349 /**
Kojto 111:4336505e4b1c 350 * \brief Retrieves the state of a group of port pins that are configured as outputs.
Kojto 111:4336505e4b1c 351 *
Kojto 111:4336505e4b1c 352 * Reads the current logical output level of a port module's pins and returns
Kojto 111:4336505e4b1c 353 * the current levels as a bitmask.
Kojto 111:4336505e4b1c 354 *
Kojto 111:4336505e4b1c 355 * \param[in] port Base of the PORT module to read from
Kojto 111:4336505e4b1c 356 * \param[in] mask Mask of the port pin(s) to read
Kojto 111:4336505e4b1c 357 *
Kojto 111:4336505e4b1c 358 * \return Status of the port pin(s) output buffers.
Kojto 111:4336505e4b1c 359 */
Kojto 111:4336505e4b1c 360 static inline uint32_t port_group_get_output_level(
Kojto 111:4336505e4b1c 361 const PortGroup *const port,
Kojto 111:4336505e4b1c 362 const uint32_t mask)
Kojto 111:4336505e4b1c 363 {
Kojto 111:4336505e4b1c 364 /* Sanity check arguments */
Kojto 111:4336505e4b1c 365 Assert(port);
Kojto 111:4336505e4b1c 366
Kojto 111:4336505e4b1c 367 return (port->OUT.reg & mask);
Kojto 111:4336505e4b1c 368 }
Kojto 111:4336505e4b1c 369
Kojto 111:4336505e4b1c 370 /**
Kojto 111:4336505e4b1c 371 * \brief Sets the state of a group of port pins that are configured as outputs.
Kojto 111:4336505e4b1c 372 *
Kojto 111:4336505e4b1c 373 * Sets the current output level of a port module's pins to a given logic
Kojto 111:4336505e4b1c 374 * level.
Kojto 111:4336505e4b1c 375 *
Kojto 111:4336505e4b1c 376 * \param[out] port Base of the PORT module to write to
Kojto 111:4336505e4b1c 377 * \param[in] mask Mask of the port pin(s) to change
Kojto 111:4336505e4b1c 378 * \param[in] level_mask Mask of the port level(s) to set
Kojto 111:4336505e4b1c 379 */
Kojto 111:4336505e4b1c 380 static inline void port_group_set_output_level(
Kojto 111:4336505e4b1c 381 PortGroup *const port,
Kojto 111:4336505e4b1c 382 const uint32_t mask,
Kojto 111:4336505e4b1c 383 const uint32_t level_mask)
Kojto 111:4336505e4b1c 384 {
Kojto 111:4336505e4b1c 385 /* Sanity check arguments */
Kojto 111:4336505e4b1c 386 Assert(port);
Kojto 111:4336505e4b1c 387
Kojto 111:4336505e4b1c 388 port->OUTSET.reg = (mask & level_mask);
Kojto 111:4336505e4b1c 389 port->OUTCLR.reg = (mask & ~level_mask);
Kojto 111:4336505e4b1c 390 }
Kojto 111:4336505e4b1c 391
Kojto 111:4336505e4b1c 392 /**
Kojto 111:4336505e4b1c 393 * \brief Toggles the state of a group of port pins that are configured as an outputs.
Kojto 111:4336505e4b1c 394 *
Kojto 111:4336505e4b1c 395 * Toggles the current output levels of a port module's pins.
Kojto 111:4336505e4b1c 396 *
Kojto 111:4336505e4b1c 397 * \param[out] port Base of the PORT module to write to
Kojto 111:4336505e4b1c 398 * \param[in] mask Mask of the port pin(s) to toggle
Kojto 111:4336505e4b1c 399 */
Kojto 111:4336505e4b1c 400 static inline void port_group_toggle_output_level(
Kojto 111:4336505e4b1c 401 PortGroup *const port,
Kojto 111:4336505e4b1c 402 const uint32_t mask)
Kojto 111:4336505e4b1c 403 {
Kojto 111:4336505e4b1c 404 /* Sanity check arguments */
Kojto 111:4336505e4b1c 405 Assert(port);
Kojto 111:4336505e4b1c 406
Kojto 111:4336505e4b1c 407 port->OUTTGL.reg = mask;
Kojto 111:4336505e4b1c 408 }
Kojto 111:4336505e4b1c 409
Kojto 111:4336505e4b1c 410 /** @} */
Kojto 111:4336505e4b1c 411
Kojto 111:4336505e4b1c 412 /** \name Configuration and Initialization
Kojto 111:4336505e4b1c 413 * @{
Kojto 111:4336505e4b1c 414 */
Kojto 111:4336505e4b1c 415
Kojto 111:4336505e4b1c 416 /**
Kojto 111:4336505e4b1c 417 * \brief Initializes a Port pin/group configuration structure to defaults.
Kojto 111:4336505e4b1c 418 *
Kojto 111:4336505e4b1c 419 * Initializes a given Port pin/group configuration structure to a set of
Kojto 111:4336505e4b1c 420 * known default values. This function should be called on all new
Kojto 111:4336505e4b1c 421 * instances of these configuration structures before being modified by the
Kojto 111:4336505e4b1c 422 * user application.
Kojto 111:4336505e4b1c 423 *
Kojto 111:4336505e4b1c 424 * The default configuration is as follows:
Kojto 111:4336505e4b1c 425 * \li Input mode with internal pullup enabled
Kojto 111:4336505e4b1c 426 *
Kojto 111:4336505e4b1c 427 * \param[out] config Configuration structure to initialize to default values
Kojto 111:4336505e4b1c 428 */
Kojto 111:4336505e4b1c 429 static inline void port_get_config_defaults(
Kojto 111:4336505e4b1c 430 struct port_config *const config)
Kojto 111:4336505e4b1c 431 {
Kojto 111:4336505e4b1c 432 /* Sanity check arguments */
Kojto 111:4336505e4b1c 433 Assert(config);
Kojto 111:4336505e4b1c 434
Kojto 111:4336505e4b1c 435 /* Default configuration values */
Kojto 111:4336505e4b1c 436 config->direction = PORT_PIN_DIR_INPUT;
Kojto 111:4336505e4b1c 437 config->input_pull = PORT_PIN_PULL_UP;
Kojto 111:4336505e4b1c 438 config->powersave = false;
Kojto 111:4336505e4b1c 439 }
Kojto 111:4336505e4b1c 440
Kojto 111:4336505e4b1c 441 void port_pin_set_config(
Kojto 111:4336505e4b1c 442 const uint8_t gpio_pin,
Kojto 111:4336505e4b1c 443 const struct port_config *const config);
Kojto 111:4336505e4b1c 444
Kojto 111:4336505e4b1c 445 void port_group_set_config(
Kojto 111:4336505e4b1c 446 PortGroup *const port,
Kojto 111:4336505e4b1c 447 const uint32_t mask,
Kojto 111:4336505e4b1c 448 const struct port_config *const config);
Kojto 111:4336505e4b1c 449
Kojto 111:4336505e4b1c 450 /** @} */
Kojto 111:4336505e4b1c 451
Kojto 111:4336505e4b1c 452 /** \name State Reading/Writing (Logical Pin Orientated)
Kojto 111:4336505e4b1c 453 * @{
Kojto 111:4336505e4b1c 454 */
Kojto 111:4336505e4b1c 455
Kojto 111:4336505e4b1c 456 /**
Kojto 111:4336505e4b1c 457 * \brief Retrieves the state of a port pin that is configured as an input.
Kojto 111:4336505e4b1c 458 *
Kojto 111:4336505e4b1c 459 * Reads the current logic level of a port pin and returns the current
Kojto 111:4336505e4b1c 460 * level as a Boolean value.
Kojto 111:4336505e4b1c 461 *
Kojto 111:4336505e4b1c 462 * \param[in] gpio_pin Index of the GPIO pin to read
Kojto 111:4336505e4b1c 463 *
Kojto 111:4336505e4b1c 464 * \return Status of the port pin's input buffer.
Kojto 111:4336505e4b1c 465 */
Kojto 111:4336505e4b1c 466 static inline bool port_pin_get_input_level(
Kojto 111:4336505e4b1c 467 const uint8_t gpio_pin)
Kojto 111:4336505e4b1c 468 {
Kojto 111:4336505e4b1c 469 PortGroup *const port_base = port_get_group_from_gpio_pin(gpio_pin);
Kojto 111:4336505e4b1c 470 uint32_t pin_mask = (1UL << (gpio_pin % 32));
Kojto 111:4336505e4b1c 471
Kojto 111:4336505e4b1c 472 return (port_base->IN.reg & pin_mask);
Kojto 111:4336505e4b1c 473 }
Kojto 111:4336505e4b1c 474
Kojto 111:4336505e4b1c 475 /**
Kojto 111:4336505e4b1c 476 * \brief Retrieves the state of a port pin that is configured as an output.
Kojto 111:4336505e4b1c 477 *
Kojto 111:4336505e4b1c 478 * Reads the current logical output level of a port pin and returns the current
Kojto 111:4336505e4b1c 479 * level as a Boolean value.
Kojto 111:4336505e4b1c 480 *
Kojto 111:4336505e4b1c 481 * \param[in] gpio_pin Index of the GPIO pin to read
Kojto 111:4336505e4b1c 482 *
Kojto 111:4336505e4b1c 483 * \return Status of the port pin's output buffer.
Kojto 111:4336505e4b1c 484 */
Kojto 111:4336505e4b1c 485 static inline bool port_pin_get_output_level(
Kojto 111:4336505e4b1c 486 const uint8_t gpio_pin)
Kojto 111:4336505e4b1c 487 {
Kojto 111:4336505e4b1c 488 PortGroup *const port_base = port_get_group_from_gpio_pin(gpio_pin);
Kojto 111:4336505e4b1c 489 uint32_t pin_mask = (1UL << (gpio_pin % 32));
Kojto 111:4336505e4b1c 490
Kojto 111:4336505e4b1c 491 return (port_base->OUT.reg & pin_mask);
Kojto 111:4336505e4b1c 492 }
Kojto 111:4336505e4b1c 493
Kojto 111:4336505e4b1c 494 /**
Kojto 111:4336505e4b1c 495 * \brief Sets the state of a port pin that is configured as an output.
Kojto 111:4336505e4b1c 496 *
Kojto 111:4336505e4b1c 497 * Sets the current output level of a port pin to a given logic level.
Kojto 111:4336505e4b1c 498 *
Kojto 111:4336505e4b1c 499 * \param[in] gpio_pin Index of the GPIO pin to write to
Kojto 111:4336505e4b1c 500 * \param[in] level Logical level to set the given pin to
Kojto 111:4336505e4b1c 501 */
Kojto 111:4336505e4b1c 502 static inline void port_pin_set_output_level(
Kojto 111:4336505e4b1c 503 const uint8_t gpio_pin,
Kojto 111:4336505e4b1c 504 const bool level)
Kojto 111:4336505e4b1c 505 {
Kojto 111:4336505e4b1c 506 PortGroup *const port_base = port_get_group_from_gpio_pin(gpio_pin);
Kojto 111:4336505e4b1c 507 uint32_t pin_mask = (1UL << (gpio_pin % 32));
Kojto 111:4336505e4b1c 508
Kojto 111:4336505e4b1c 509 /* Set the pin to high or low atomically based on the requested level */
Kojto 111:4336505e4b1c 510 if (level) {
Kojto 111:4336505e4b1c 511 port_base->OUTSET.reg = pin_mask;
Kojto 111:4336505e4b1c 512 } else {
Kojto 111:4336505e4b1c 513 port_base->OUTCLR.reg = pin_mask;
Kojto 111:4336505e4b1c 514 }
Kojto 111:4336505e4b1c 515 }
Kojto 111:4336505e4b1c 516
Kojto 111:4336505e4b1c 517 /**
Kojto 111:4336505e4b1c 518 * \brief Toggles the state of a port pin that is configured as an output.
Kojto 111:4336505e4b1c 519 *
Kojto 111:4336505e4b1c 520 * Toggles the current output level of a port pin.
Kojto 111:4336505e4b1c 521 *
Kojto 111:4336505e4b1c 522 * \param[in] gpio_pin Index of the GPIO pin to toggle
Kojto 111:4336505e4b1c 523 */
Kojto 111:4336505e4b1c 524 static inline void port_pin_toggle_output_level(
Kojto 111:4336505e4b1c 525 const uint8_t gpio_pin)
Kojto 111:4336505e4b1c 526 {
Kojto 111:4336505e4b1c 527 PortGroup *const port_base = port_get_group_from_gpio_pin(gpio_pin);
Kojto 111:4336505e4b1c 528 uint32_t pin_mask = (1UL << (gpio_pin % 32));
Kojto 111:4336505e4b1c 529
Kojto 111:4336505e4b1c 530 /* Toggle pin output level */
Kojto 111:4336505e4b1c 531 port_base->OUTTGL.reg = pin_mask;
Kojto 111:4336505e4b1c 532 }
Kojto 111:4336505e4b1c 533
Kojto 111:4336505e4b1c 534 /** @} */
Kojto 111:4336505e4b1c 535
Kojto 111:4336505e4b1c 536 #ifdef FEATURE_PORT_INPUT_EVENT
Kojto 111:4336505e4b1c 537
Kojto 111:4336505e4b1c 538 /** \name Port Input Event
Kojto 111:4336505e4b1c 539 * @{
Kojto 111:4336505e4b1c 540 */
Kojto 111:4336505e4b1c 541
Kojto 111:4336505e4b1c 542 /**
Kojto 111:4336505e4b1c 543 * \brief Enable the port event input.
Kojto 111:4336505e4b1c 544 *
Kojto 111:4336505e4b1c 545 * Enable the port event input with the given pin and event.
Kojto 111:4336505e4b1c 546 *
Kojto 111:4336505e4b1c 547 * \param[in] gpio_pin Index of the GPIO pin
Kojto 111:4336505e4b1c 548 * \param[in] n Port input event
Kojto 111:4336505e4b1c 549 *
Kojto 111:4336505e4b1c 550 * \retval STATUS_ERR_INVALID_ARG Invalid parameter
Kojto 111:4336505e4b1c 551 * \retval STATUS_OK Successfully
Kojto 111:4336505e4b1c 552 */
Kojto 111:4336505e4b1c 553 static inline enum status_code port_enable_input_event(
Kojto 111:4336505e4b1c 554 const uint8_t gpio_pin,
Kojto 111:4336505e4b1c 555 const enum port_input_event n)
Kojto 111:4336505e4b1c 556 {
Kojto 111:4336505e4b1c 557 PortGroup *const port_base = port_get_group_from_gpio_pin(gpio_pin);
Kojto 111:4336505e4b1c 558 switch (n) {
Kojto 111:4336505e4b1c 559 case PORT_INPUT_EVENT_0:
Kojto 111:4336505e4b1c 560 port_base->EVCTRL.reg |= PORT_EVCTRL_PORTEI0;
Kojto 111:4336505e4b1c 561 break;
Kojto 111:4336505e4b1c 562 case PORT_INPUT_EVENT_1:
Kojto 111:4336505e4b1c 563 port_base->EVCTRL.reg |= PORT_EVCTRL_PORTEI1;
Kojto 111:4336505e4b1c 564 break;
Kojto 111:4336505e4b1c 565 case PORT_INPUT_EVENT_2:
Kojto 111:4336505e4b1c 566 port_base->EVCTRL.reg |= PORT_EVCTRL_PORTEI2;
Kojto 111:4336505e4b1c 567 break;
Kojto 111:4336505e4b1c 568 case PORT_INPUT_EVENT_3:
Kojto 111:4336505e4b1c 569 port_base->EVCTRL.reg |= PORT_EVCTRL_PORTEI3;
Kojto 111:4336505e4b1c 570 break;
Kojto 111:4336505e4b1c 571 default:
Kojto 111:4336505e4b1c 572 Assert(false);
Kojto 111:4336505e4b1c 573 return STATUS_ERR_INVALID_ARG;
Kojto 111:4336505e4b1c 574 }
Kojto 111:4336505e4b1c 575 return STATUS_OK;
Kojto 111:4336505e4b1c 576 }
Kojto 111:4336505e4b1c 577
Kojto 111:4336505e4b1c 578 /**
Kojto 111:4336505e4b1c 579 * \brief Disable the port event input.
Kojto 111:4336505e4b1c 580 *
Kojto 111:4336505e4b1c 581 * Disable the port event input with the given pin and event.
Kojto 111:4336505e4b1c 582 *
Kojto 111:4336505e4b1c 583 * \param[in] gpio_pin Index of the GPIO pin
Kojto 111:4336505e4b1c 584 * \param[in] gpio_pin Port input event
Kojto 111:4336505e4b1c 585 *
Kojto 111:4336505e4b1c 586 * \retval STATUS_ERR_INVALID_ARG Invalid parameter
Kojto 111:4336505e4b1c 587 * \retval STATUS_OK Successfully
Kojto 111:4336505e4b1c 588 */
Kojto 111:4336505e4b1c 589 static inline enum status_code port_disable_input_event(
Kojto 111:4336505e4b1c 590 const uint8_t gpio_pin,
Kojto 111:4336505e4b1c 591 const enum port_input_event n)
Kojto 111:4336505e4b1c 592 {
Kojto 111:4336505e4b1c 593 PortGroup *const port_base = port_get_group_from_gpio_pin(gpio_pin);
Kojto 111:4336505e4b1c 594 switch (n) {
Kojto 111:4336505e4b1c 595 case PORT_INPUT_EVENT_0:
Kojto 111:4336505e4b1c 596 port_base->EVCTRL.reg &= ~PORT_EVCTRL_PORTEI0;
Kojto 111:4336505e4b1c 597 break;
Kojto 111:4336505e4b1c 598 case PORT_INPUT_EVENT_1:
Kojto 111:4336505e4b1c 599 port_base->EVCTRL.reg &= ~PORT_EVCTRL_PORTEI1;
Kojto 111:4336505e4b1c 600 break;
Kojto 111:4336505e4b1c 601 case PORT_INPUT_EVENT_2:
Kojto 111:4336505e4b1c 602 port_base->EVCTRL.reg &= ~PORT_EVCTRL_PORTEI2;
Kojto 111:4336505e4b1c 603 break;
Kojto 111:4336505e4b1c 604 case PORT_INPUT_EVENT_3:
Kojto 111:4336505e4b1c 605 port_base->EVCTRL.reg &= ~PORT_EVCTRL_PORTEI3;
Kojto 111:4336505e4b1c 606 break;
Kojto 111:4336505e4b1c 607 default:
Kojto 111:4336505e4b1c 608 Assert(false);
Kojto 111:4336505e4b1c 609 return STATUS_ERR_INVALID_ARG;
Kojto 111:4336505e4b1c 610 }
Kojto 111:4336505e4b1c 611 return STATUS_OK;
Kojto 111:4336505e4b1c 612 }
Kojto 111:4336505e4b1c 613
Kojto 111:4336505e4b1c 614 /**
Kojto 111:4336505e4b1c 615 * \brief Retrieve the default configuration for port input event.
Kojto 111:4336505e4b1c 616 *
Kojto 111:4336505e4b1c 617 * Fills a configuration structure with the default configuration for port input event:
Kojto 111:4336505e4b1c 618 * - Event output to pin
Kojto 111:4336505e4b1c 619 * - Event action to be executed on PIN 0
Kojto 111:4336505e4b1c 620 *
Kojto 111:4336505e4b1c 621 * \param[out] config Configuration structure to fill with default values
Kojto 111:4336505e4b1c 622 */
Kojto 111:4336505e4b1c 623 static inline void port_input_event_get_config_defaults(
Kojto 111:4336505e4b1c 624 struct port_input_event_config *const config)
Kojto 111:4336505e4b1c 625 {
Kojto 111:4336505e4b1c 626 Assert(config);
Kojto 111:4336505e4b1c 627 config->action = PORT_INPUT_EVENT_ACTION_OUT;
Kojto 111:4336505e4b1c 628 config->gpio_pin = 0;
Kojto 111:4336505e4b1c 629 }
Kojto 111:4336505e4b1c 630
Kojto 111:4336505e4b1c 631 /**
Kojto 111:4336505e4b1c 632 * \brief Configure port input event.
Kojto 111:4336505e4b1c 633 *
Kojto 111:4336505e4b1c 634 * Configures port input event with the given configuration settings.
Kojto 111:4336505e4b1c 635 *
Kojto 111:4336505e4b1c 636 * \param[in] config Port input even configuration structure containing the new config
Kojto 111:4336505e4b1c 637 *
Kojto 111:4336505e4b1c 638 * \retval STATUS_ERR_INVALID_ARG Invalid parameter
Kojto 111:4336505e4b1c 639 * \retval STATUS_OK Successfully
Kojto 111:4336505e4b1c 640 */
Kojto 111:4336505e4b1c 641
Kojto 111:4336505e4b1c 642 static inline enum status_code port_input_event_set_config(
Kojto 111:4336505e4b1c 643 const enum port_input_event n,
Kojto 111:4336505e4b1c 644 struct port_input_event_config *const config)
Kojto 111:4336505e4b1c 645 {
Kojto 111:4336505e4b1c 646 Assert(config);
Kojto 111:4336505e4b1c 647 PortGroup *const port_base = port_get_group_from_gpio_pin(config->gpio_pin);
Kojto 111:4336505e4b1c 648 uint8_t pin_index = config->gpio_pin % 32;
Kojto 111:4336505e4b1c 649 struct port_config pin_conf;
Kojto 111:4336505e4b1c 650
Kojto 111:4336505e4b1c 651 port_get_config_defaults(&pin_conf);
Kojto 111:4336505e4b1c 652 /* Configure the GPIO pin as outputs*/
Kojto 111:4336505e4b1c 653 pin_conf.direction = PORT_PIN_DIR_OUTPUT;
Kojto 111:4336505e4b1c 654 port_pin_set_config(config->gpio_pin, &pin_conf);
Kojto 111:4336505e4b1c 655
Kojto 111:4336505e4b1c 656 switch (n) {
Kojto 111:4336505e4b1c 657 case PORT_INPUT_EVENT_0:
Kojto 111:4336505e4b1c 658 port_base->EVCTRL.reg |= PORT_EVCTRL_EVACT0(config->action)
Kojto 111:4336505e4b1c 659 | PORT_EVCTRL_PID0(pin_index);
Kojto 111:4336505e4b1c 660 break;
Kojto 111:4336505e4b1c 661 case PORT_INPUT_EVENT_1:
Kojto 111:4336505e4b1c 662 port_base->EVCTRL.reg |= PORT_EVCTRL_EVACT1(config->action)
Kojto 111:4336505e4b1c 663 | PORT_EVCTRL_PID1(pin_index);
Kojto 111:4336505e4b1c 664 break;
Kojto 111:4336505e4b1c 665 case PORT_INPUT_EVENT_2:
Kojto 111:4336505e4b1c 666 port_base->EVCTRL.reg |= PORT_EVCTRL_EVACT2(config->action)
Kojto 111:4336505e4b1c 667 | PORT_EVCTRL_PID2(pin_index);
Kojto 111:4336505e4b1c 668 break;
Kojto 111:4336505e4b1c 669 case PORT_INPUT_EVENT_3:
Kojto 111:4336505e4b1c 670 port_base->EVCTRL.reg |= PORT_EVCTRL_EVACT3(config->action)
Kojto 111:4336505e4b1c 671 | PORT_EVCTRL_PID3(pin_index);
Kojto 111:4336505e4b1c 672 break;
Kojto 111:4336505e4b1c 673 default:
Kojto 111:4336505e4b1c 674 Assert(false);
Kojto 111:4336505e4b1c 675 return STATUS_ERR_INVALID_ARG;
Kojto 111:4336505e4b1c 676 }
Kojto 111:4336505e4b1c 677 return STATUS_OK;
Kojto 111:4336505e4b1c 678 }
Kojto 111:4336505e4b1c 679
Kojto 111:4336505e4b1c 680 /** @} */
Kojto 111:4336505e4b1c 681
Kojto 111:4336505e4b1c 682 #endif
Kojto 111:4336505e4b1c 683
Kojto 111:4336505e4b1c 684 #ifdef __cplusplus
Kojto 111:4336505e4b1c 685 }
Kojto 111:4336505e4b1c 686 #endif
Kojto 111:4336505e4b1c 687
Kojto 111:4336505e4b1c 688 /** @} */
Kojto 111:4336505e4b1c 689
Kojto 111:4336505e4b1c 690 /**
Kojto 111:4336505e4b1c 691 * \page asfdoc_sam0_port_extra Extra Information for PORT Driver
Kojto 111:4336505e4b1c 692 *
Kojto 111:4336505e4b1c 693 * \section asfdoc_sam0_port_extra_acronyms Acronyms
Kojto 111:4336505e4b1c 694 * Below is a table listing the acronyms used in this module, along with their
Kojto 111:4336505e4b1c 695 * intended meanings.
Kojto 111:4336505e4b1c 696 *
Kojto 111:4336505e4b1c 697 * <table>
Kojto 111:4336505e4b1c 698 * <tr>
Kojto 111:4336505e4b1c 699 * <th>Acronym</th>
Kojto 111:4336505e4b1c 700 * <th>Description</th>
Kojto 111:4336505e4b1c 701 * </tr>
Kojto 111:4336505e4b1c 702 * <tr>
Kojto 111:4336505e4b1c 703 * <td>GPIO</td>
Kojto 111:4336505e4b1c 704 * <td>General Purpose Input/Output</td>
Kojto 111:4336505e4b1c 705 * </tr>
Kojto 111:4336505e4b1c 706 * <tr>
Kojto 111:4336505e4b1c 707 * <td>MUX</td>
Kojto 111:4336505e4b1c 708 * <td>Multiplexer</td>
Kojto 111:4336505e4b1c 709 * </tr>
Kojto 111:4336505e4b1c 710 * </table>
Kojto 111:4336505e4b1c 711 *
Kojto 111:4336505e4b1c 712 *
Kojto 111:4336505e4b1c 713 * \section asfdoc_sam0_port_extra_dependencies Dependencies
Kojto 111:4336505e4b1c 714 * This driver has the following dependencies:
Kojto 111:4336505e4b1c 715 *
Kojto 111:4336505e4b1c 716 * - \ref asfdoc_sam0_system_pinmux_group "System Pin Multiplexer Driver"
Kojto 111:4336505e4b1c 717 *
Kojto 111:4336505e4b1c 718 *
Kojto 111:4336505e4b1c 719 * \section asfdoc_sam0_port_extra_errata Errata
Kojto 111:4336505e4b1c 720 * There are no errata related to this driver.
Kojto 111:4336505e4b1c 721 *
Kojto 111:4336505e4b1c 722 *
Kojto 111:4336505e4b1c 723 * \section asfdoc_sam0_port_extra_history Module History
Kojto 111:4336505e4b1c 724 * An overview of the module history is presented in the table below, with
Kojto 111:4336505e4b1c 725 * details on the enhancements and fixes made to the module since its first
Kojto 111:4336505e4b1c 726 * release. The current version of this corresponds to the newest version in
Kojto 111:4336505e4b1c 727 * the table.
Kojto 111:4336505e4b1c 728 *
Kojto 111:4336505e4b1c 729 * <table>
Kojto 111:4336505e4b1c 730 * <tr>
Kojto 111:4336505e4b1c 731 * <th>Changelog</th>
Kojto 111:4336505e4b1c 732 * </tr>
Kojto 111:4336505e4b1c 733 * <tr>
Kojto 111:4336505e4b1c 734 * <td>Added input event feature</td>
Kojto 111:4336505e4b1c 735 * </tr>
Kojto 111:4336505e4b1c 736 * <tr>
Kojto 111:4336505e4b1c 737 * <td>Initial Release</td>
Kojto 111:4336505e4b1c 738 * </tr>
Kojto 111:4336505e4b1c 739 * </table>
Kojto 111:4336505e4b1c 740 */
Kojto 111:4336505e4b1c 741
Kojto 111:4336505e4b1c 742 /**
Kojto 111:4336505e4b1c 743 * \page asfdoc_sam0_port_exqsg Examples for PORT Driver
Kojto 111:4336505e4b1c 744 *
Kojto 111:4336505e4b1c 745 * This is a list of the available Quick Start guides (QSGs) and example
Kojto 111:4336505e4b1c 746 * applications for \ref asfdoc_sam0_port_group. QSGs are simple examples with
Kojto 111:4336505e4b1c 747 * step-by-step instructions to configure and use this driver in a selection of
Kojto 111:4336505e4b1c 748 * use cases. Note that QSGs can be compiled as a standalone application or be
Kojto 111:4336505e4b1c 749 * added to the user application.
Kojto 111:4336505e4b1c 750 *
Kojto 111:4336505e4b1c 751 * - \subpage asfdoc_sam0_port_basic_use_case
Kojto 111:4336505e4b1c 752 *
Kojto 111:4336505e4b1c 753 * \page asfdoc_sam0_port_document_revision_history Document Revision History
Kojto 111:4336505e4b1c 754 *
Kojto 111:4336505e4b1c 755 * <table>
Kojto 111:4336505e4b1c 756 * <tr>
Kojto 111:4336505e4b1c 757 * <th>Doc. Rev.</td>
Kojto 111:4336505e4b1c 758 * <th>Date</td>
Kojto 111:4336505e4b1c 759 * <th>Comments</td>
Kojto 111:4336505e4b1c 760 * </tr>
Kojto 111:4336505e4b1c 761 * <tr>
Kojto 111:4336505e4b1c 762 * <td>E</td>
Kojto 111:4336505e4b1c 763 * <td>06/2015</td>
Kojto 111:4336505e4b1c 764 * <td>Added input event feature and support for SAML21, SAMC21, and SAMDAx.</td>
Kojto 111:4336505e4b1c 765 * </tr>
Kojto 111:4336505e4b1c 766 * <tr>
Kojto 111:4336505e4b1c 767 * <td>D</td>
Kojto 111:4336505e4b1c 768 * <td>12/2014</td>
Kojto 111:4336505e4b1c 769 * <td>Added support for SAMR21 and SAMD10/D11.</td>
Kojto 111:4336505e4b1c 770 * </tr>
Kojto 111:4336505e4b1c 771 * <tr>
Kojto 111:4336505e4b1c 772 * <td>C</td>
Kojto 111:4336505e4b1c 773 * <td>01/2014</td>
Kojto 111:4336505e4b1c 774 * <td>Added support for SAMD21.</td>
Kojto 111:4336505e4b1c 775 * </tr>
Kojto 111:4336505e4b1c 776 * <tr>
Kojto 111:4336505e4b1c 777 * <td>B</td>
Kojto 111:4336505e4b1c 778 * <td>06/2013</td>
Kojto 111:4336505e4b1c 779 * <td>Corrected documentation typos.</td>
Kojto 111:4336505e4b1c 780 * </tr>
Kojto 111:4336505e4b1c 781 * <tr>
Kojto 111:4336505e4b1c 782 * <td>A</td>
Kojto 111:4336505e4b1c 783 * <td>06/2013</td>
Kojto 111:4336505e4b1c 784 * <td>Initial release</td>
Kojto 111:4336505e4b1c 785 * </tr>
Kojto 111:4336505e4b1c 786 * </table>
Kojto 111:4336505e4b1c 787 */
Kojto 111:4336505e4b1c 788
Kojto 111:4336505e4b1c 789 #endif