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