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.
TARGET_SAMD21G18A/TOOLCHAIN_ARM_STD/pinmux.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 111:4336505e4b1c | 1 | /** |
Kojto | 111:4336505e4b1c | 2 | * \file |
Kojto | 111:4336505e4b1c | 3 | * |
Kojto | 111:4336505e4b1c | 4 | * \brief SAM Pin Multiplexer 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 PINMUX_H_INCLUDED |
Kojto | 111:4336505e4b1c | 47 | #define PINMUX_H_INCLUDED |
Kojto | 111:4336505e4b1c | 48 | |
Kojto | 111:4336505e4b1c | 49 | /** |
Kojto | 111:4336505e4b1c | 50 | * \defgroup asfdoc_sam0_system_pinmux_group SAM System Pin Multiplexer Driver (SYSTEM PINMUX) |
Kojto | 111:4336505e4b1c | 51 | * |
Kojto | 111:4336505e4b1c | 52 | * This driver for Atmel® | SMART SAM devices provides an interface for the |
Kojto | 111:4336505e4b1c | 53 | * configuration and management of the device's physical I/O Pins, to alter the |
Kojto | 111:4336505e4b1c | 54 | * direction and input/drive characteristics as well as to configure the pin |
Kojto | 111:4336505e4b1c | 55 | * peripheral multiplexer selection. |
Kojto | 111:4336505e4b1c | 56 | * |
Kojto | 111:4336505e4b1c | 57 | * The following peripherals are used by this module: |
Kojto | 111:4336505e4b1c | 58 | * - PORT (Port I/O Management) |
Kojto | 111:4336505e4b1c | 59 | * |
Kojto | 111:4336505e4b1c | 60 | * The following devices can use this module: |
Kojto | 111:4336505e4b1c | 61 | * - Atmel | SMART SAM D20/D21 |
Kojto | 111:4336505e4b1c | 62 | * - Atmel | SMART SAM R21 |
Kojto | 111:4336505e4b1c | 63 | * - Atmel | SMART SAM D10/D11 |
Kojto | 111:4336505e4b1c | 64 | * - Atmel | SMART SAM L21 |
Kojto | 111:4336505e4b1c | 65 | * - Atmel | SMART SAM DAx |
Kojto | 111:4336505e4b1c | 66 | * - Atmel | SMART SAM C20/C21 |
Kojto | 111:4336505e4b1c | 67 | * |
Kojto | 111:4336505e4b1c | 68 | * Physically, the modules are interconnected within the device as shown in the |
Kojto | 111:4336505e4b1c | 69 | * following diagram: |
Kojto | 111:4336505e4b1c | 70 | * |
Kojto | 111:4336505e4b1c | 71 | * The outline of this documentation is as follows: |
Kojto | 111:4336505e4b1c | 72 | * - \ref asfdoc_sam0_system_pinmux_prerequisites |
Kojto | 111:4336505e4b1c | 73 | * - \ref asfdoc_sam0_system_pinmux_module_overview |
Kojto | 111:4336505e4b1c | 74 | * - \ref asfdoc_sam0_system_pinmux_special_considerations |
Kojto | 111:4336505e4b1c | 75 | * - \ref asfdoc_sam0_system_pinmux_extra_info |
Kojto | 111:4336505e4b1c | 76 | * - \ref asfdoc_sam0_system_pinmux_examples |
Kojto | 111:4336505e4b1c | 77 | * - \ref asfdoc_sam0_system_pinmux_api_overview |
Kojto | 111:4336505e4b1c | 78 | * |
Kojto | 111:4336505e4b1c | 79 | * |
Kojto | 111:4336505e4b1c | 80 | * \section asfdoc_sam0_system_pinmux_prerequisites Prerequisites |
Kojto | 111:4336505e4b1c | 81 | * |
Kojto | 111:4336505e4b1c | 82 | * There are no prerequisites for this module. |
Kojto | 111:4336505e4b1c | 83 | * |
Kojto | 111:4336505e4b1c | 84 | * |
Kojto | 111:4336505e4b1c | 85 | * \section asfdoc_sam0_system_pinmux_module_overview Module Overview |
Kojto | 111:4336505e4b1c | 86 | * |
Kojto | 111:4336505e4b1c | 87 | * The SAM devices contain a number of General Purpose I/O pins, used to |
Kojto | 111:4336505e4b1c | 88 | * interface the user application logic and internal hardware peripherals to |
Kojto | 111:4336505e4b1c | 89 | * an external system. The Pin Multiplexer (PINMUX) driver provides a method |
Kojto | 111:4336505e4b1c | 90 | * of configuring the individual pin peripheral multiplexers to select |
Kojto | 111:4336505e4b1c | 91 | * alternate pin functions. |
Kojto | 111:4336505e4b1c | 92 | * |
Kojto | 111:4336505e4b1c | 93 | * \subsection asfdoc_sam0_system_pinmux_features Driver Feature Macro Definition |
Kojto | 111:4336505e4b1c | 94 | * <table> |
Kojto | 111:4336505e4b1c | 95 | * <tr> |
Kojto | 111:4336505e4b1c | 96 | * <th>Driver Feature Macro</th> |
Kojto | 111:4336505e4b1c | 97 | * <th>Supported devices</th> |
Kojto | 111:4336505e4b1c | 98 | * </tr> |
Kojto | 111:4336505e4b1c | 99 | * <tr> |
Kojto | 111:4336505e4b1c | 100 | * <td>FEATURE_SYSTEM_PINMUX_DRIVE_STRENGTH</td> |
Kojto | 111:4336505e4b1c | 101 | * <td>SAML21, SAMC20/C21</td> |
Kojto | 111:4336505e4b1c | 102 | * </tr> |
Kojto | 111:4336505e4b1c | 103 | * </table> |
Kojto | 111:4336505e4b1c | 104 | * \note The specific features are only available in the driver when the |
Kojto | 111:4336505e4b1c | 105 | * selected device supports those features. |
Kojto | 111:4336505e4b1c | 106 | * |
Kojto | 111:4336505e4b1c | 107 | * \subsection asfdoc_sam0_system_pinmux_physical_logical_pins Physical and Logical GPIO Pins |
Kojto | 111:4336505e4b1c | 108 | * SAM devices use two naming conventions for the I/O pins in the device; one |
Kojto | 111:4336505e4b1c | 109 | * physical and one logical. Each physical pin on a device package is assigned |
Kojto | 111:4336505e4b1c | 110 | * both a physical port and pin identifier (e.g. "PORTA.0") as well as a |
Kojto | 111:4336505e4b1c | 111 | * monotonically incrementing logical GPIO number (e.g. "GPIO0"). While the |
Kojto | 111:4336505e4b1c | 112 | * former is used to map physical pins to their physical internal device module |
Kojto | 111:4336505e4b1c | 113 | * counterparts, for simplicity the design of this driver uses the logical GPIO |
Kojto | 111:4336505e4b1c | 114 | * numbers instead. |
Kojto | 111:4336505e4b1c | 115 | * |
Kojto | 111:4336505e4b1c | 116 | * \subsection asfdoc_sam0_system_pinmux_peripheral_muxing Peripheral Multiplexing |
Kojto | 111:4336505e4b1c | 117 | * SAM devices contain a peripheral MUX, which is individually controllable |
Kojto | 111:4336505e4b1c | 118 | * for each I/O pin of the device. The peripheral MUX allows you to select the |
Kojto | 111:4336505e4b1c | 119 | * function of a physical package pin - whether it will be controlled as a user |
Kojto | 111:4336505e4b1c | 120 | * controllable GPIO pin, or whether it will be connected internally to one of |
Kojto | 111:4336505e4b1c | 121 | * several peripheral modules (such as an I<SUP>2</SUP>C module). When a pin is |
Kojto | 111:4336505e4b1c | 122 | * configured in GPIO mode, other peripherals connected to the same pin will be |
Kojto | 111:4336505e4b1c | 123 | * disabled. |
Kojto | 111:4336505e4b1c | 124 | * |
Kojto | 111:4336505e4b1c | 125 | * \subsection asfdoc_sam0_system_pinmux_pad_characteristics Special Pad Characteristics |
Kojto | 111:4336505e4b1c | 126 | * There are several special modes that can be selected on one or more I/O pins |
Kojto | 111:4336505e4b1c | 127 | * of the device, which alter the input and output characteristics of the pad. |
Kojto | 111:4336505e4b1c | 128 | * |
Kojto | 111:4336505e4b1c | 129 | * \subsubsection asfdoc_sam0_system_pinmux_drive_strength Drive Strength |
Kojto | 111:4336505e4b1c | 130 | * The Drive Strength configures the strength of the output driver on the |
Kojto | 111:4336505e4b1c | 131 | * pad. Normally, there is a fixed current limit that each I/O pin can safely |
Kojto | 111:4336505e4b1c | 132 | * drive, however some I/O pads offer a higher drive mode which increases this |
Kojto | 111:4336505e4b1c | 133 | * limit for that I/O pin at the expense of an increased power consumption. |
Kojto | 111:4336505e4b1c | 134 | * |
Kojto | 111:4336505e4b1c | 135 | * \subsubsection asfdoc_sam0_system_pinmux_slew_rate Slew Rate |
Kojto | 111:4336505e4b1c | 136 | * The Slew Rate configures the slew rate of the output driver, limiting the |
Kojto | 111:4336505e4b1c | 137 | * rate at which the pad output voltage can change with time. |
Kojto | 111:4336505e4b1c | 138 | * |
Kojto | 111:4336505e4b1c | 139 | * \subsubsection asfdoc_sam0_system_pinmux_input_sample_mode Input Sample Mode |
Kojto | 111:4336505e4b1c | 140 | * The Input Sample Mode configures the input sampler buffer of the pad. By |
Kojto | 111:4336505e4b1c | 141 | * default, the input buffer is only sampled "on-demand", i.e. when the user |
Kojto | 111:4336505e4b1c | 142 | * application attempts to read from the input buffer. This mode is the most |
Kojto | 111:4336505e4b1c | 143 | * power efficient, but increases the latency of the input sample by two clock |
Kojto | 111:4336505e4b1c | 144 | * cycles of the port clock. To reduce latency, the input sampler can instead |
Kojto | 111:4336505e4b1c | 145 | * be configured to always sample the input buffer on each port clock cycle, at |
Kojto | 111:4336505e4b1c | 146 | * the expense of an increased power consumption. |
Kojto | 111:4336505e4b1c | 147 | * |
Kojto | 111:4336505e4b1c | 148 | * \subsection asfdoc_sam0_system_pinmux_module_overview_physical Physical Connection |
Kojto | 111:4336505e4b1c | 149 | * |
Kojto | 111:4336505e4b1c | 150 | * \ref asfdoc_sam0_system_pinmux_intconnections "The diagram below" shows |
Kojto | 111:4336505e4b1c | 151 | * how this module is interconnected within the device: |
Kojto | 111:4336505e4b1c | 152 | * |
Kojto | 111:4336505e4b1c | 153 | * \anchor asfdoc_sam0_system_pinmux_intconnections |
Kojto | 111:4336505e4b1c | 154 | * \dot |
Kojto | 111:4336505e4b1c | 155 | * digraph overview { |
Kojto | 111:4336505e4b1c | 156 | * node [label="Port Pad" shape=square] pad; |
Kojto | 111:4336505e4b1c | 157 | * |
Kojto | 111:4336505e4b1c | 158 | * subgraph driver { |
Kojto | 111:4336505e4b1c | 159 | * node [label="Peripheral MUX" shape=trapezium] pinmux; |
Kojto | 111:4336505e4b1c | 160 | * node [label="GPIO Module" shape=ellipse shape=ellipse style=filled fillcolor=lightgray] gpio; |
Kojto | 111:4336505e4b1c | 161 | * node [label="Other Peripheral Modules" shape=ellipse style=filled fillcolor=lightgray] peripherals; |
Kojto | 111:4336505e4b1c | 162 | * } |
Kojto | 111:4336505e4b1c | 163 | * |
Kojto | 111:4336505e4b1c | 164 | * pinmux -> gpio; |
Kojto | 111:4336505e4b1c | 165 | * pad -> pinmux; |
Kojto | 111:4336505e4b1c | 166 | * pinmux -> peripherals; |
Kojto | 111:4336505e4b1c | 167 | * } |
Kojto | 111:4336505e4b1c | 168 | * \enddot |
Kojto | 111:4336505e4b1c | 169 | * |
Kojto | 111:4336505e4b1c | 170 | * \section asfdoc_sam0_system_pinmux_special_considerations Special Considerations |
Kojto | 111:4336505e4b1c | 171 | * |
Kojto | 111:4336505e4b1c | 172 | * The SAM port pin input sampling mode is set in groups of four physical |
Kojto | 111:4336505e4b1c | 173 | * pins; setting the sampling mode of any pin in a sub-group of eight I/O pins |
Kojto | 111:4336505e4b1c | 174 | * will configure the sampling mode of the entire sub-group. |
Kojto | 111:4336505e4b1c | 175 | * |
Kojto | 111:4336505e4b1c | 176 | * High Drive Strength output driver mode is not available on all device pins - |
Kojto | 111:4336505e4b1c | 177 | * refer to your device specific datasheet. |
Kojto | 111:4336505e4b1c | 178 | * |
Kojto | 111:4336505e4b1c | 179 | * |
Kojto | 111:4336505e4b1c | 180 | * \section asfdoc_sam0_system_pinmux_extra_info Extra Information |
Kojto | 111:4336505e4b1c | 181 | * |
Kojto | 111:4336505e4b1c | 182 | * For extra information, see \ref asfdoc_sam0_system_pinmux_extra. This includes: |
Kojto | 111:4336505e4b1c | 183 | * - \ref asfdoc_sam0_system_pinmux_extra_acronyms |
Kojto | 111:4336505e4b1c | 184 | * - \ref asfdoc_sam0_system_pinmux_extra_dependencies |
Kojto | 111:4336505e4b1c | 185 | * - \ref asfdoc_sam0_system_pinmux_extra_errata |
Kojto | 111:4336505e4b1c | 186 | * - \ref asfdoc_sam0_system_pinmux_extra_history |
Kojto | 111:4336505e4b1c | 187 | * |
Kojto | 111:4336505e4b1c | 188 | * |
Kojto | 111:4336505e4b1c | 189 | * \section asfdoc_sam0_system_pinmux_examples Examples |
Kojto | 111:4336505e4b1c | 190 | * |
Kojto | 111:4336505e4b1c | 191 | * For a list of examples related to this driver, see |
Kojto | 111:4336505e4b1c | 192 | * \ref asfdoc_sam0_system_pinmux_exqsg. |
Kojto | 111:4336505e4b1c | 193 | * |
Kojto | 111:4336505e4b1c | 194 | * |
Kojto | 111:4336505e4b1c | 195 | * \section asfdoc_sam0_system_pinmux_api_overview API Overview |
Kojto | 111:4336505e4b1c | 196 | * @{ |
Kojto | 111:4336505e4b1c | 197 | */ |
Kojto | 111:4336505e4b1c | 198 | |
Kojto | 111:4336505e4b1c | 199 | #include <compiler.h> |
Kojto | 111:4336505e4b1c | 200 | |
Kojto | 111:4336505e4b1c | 201 | #ifdef __cplusplus |
Kojto | 111:4336505e4b1c | 202 | extern "C" { |
Kojto | 111:4336505e4b1c | 203 | #endif |
Kojto | 111:4336505e4b1c | 204 | |
Kojto | 111:4336505e4b1c | 205 | /*@{*/ |
Kojto | 111:4336505e4b1c | 206 | #if (SAML21) || (SAMC20) || (SAMC21) || defined(__DOXYGEN__) |
Kojto | 111:4336505e4b1c | 207 | /** Output Driver Strength Selection feature support. */ |
Kojto | 111:4336505e4b1c | 208 | # define FEATURE_SYSTEM_PINMUX_DRIVE_STRENGTH |
Kojto | 111:4336505e4b1c | 209 | #endif |
Kojto | 111:4336505e4b1c | 210 | /*@}*/ |
Kojto | 111:4336505e4b1c | 211 | |
Kojto | 111:4336505e4b1c | 212 | /** Peripheral multiplexer index to select GPIO mode for a pin. */ |
Kojto | 111:4336505e4b1c | 213 | #define SYSTEM_PINMUX_GPIO (1 << 7) |
Kojto | 111:4336505e4b1c | 214 | |
Kojto | 111:4336505e4b1c | 215 | /** |
Kojto | 111:4336505e4b1c | 216 | * \brief Port pin direction configuration enum. |
Kojto | 111:4336505e4b1c | 217 | * |
Kojto | 111:4336505e4b1c | 218 | * Enum for the possible pin direction settings of the port pin configuration |
Kojto | 111:4336505e4b1c | 219 | * structure, to indicate the direction the pin should use. |
Kojto | 111:4336505e4b1c | 220 | */ |
Kojto | 111:4336505e4b1c | 221 | enum system_pinmux_pin_dir { |
Kojto | 111:4336505e4b1c | 222 | /** The pin's input buffer should be enabled, so that the pin state can |
Kojto | 111:4336505e4b1c | 223 | * be read. */ |
Kojto | 111:4336505e4b1c | 224 | SYSTEM_PINMUX_PIN_DIR_INPUT, |
Kojto | 111:4336505e4b1c | 225 | /** The pin's output buffer should be enabled, so that the pin state can |
Kojto | 111:4336505e4b1c | 226 | * be set (but not read back). */ |
Kojto | 111:4336505e4b1c | 227 | SYSTEM_PINMUX_PIN_DIR_OUTPUT, |
Kojto | 111:4336505e4b1c | 228 | /** The pin's output and input buffers should both be enabled, so that the |
Kojto | 111:4336505e4b1c | 229 | * pin state can be set and read back. */ |
Kojto | 111:4336505e4b1c | 230 | SYSTEM_PINMUX_PIN_DIR_OUTPUT_WITH_READBACK, |
Kojto | 111:4336505e4b1c | 231 | }; |
Kojto | 111:4336505e4b1c | 232 | |
Kojto | 111:4336505e4b1c | 233 | /** |
Kojto | 111:4336505e4b1c | 234 | * \brief Port pin input pull configuration enum. |
Kojto | 111:4336505e4b1c | 235 | * |
Kojto | 111:4336505e4b1c | 236 | * Enum for the possible pin pull settings of the port pin configuration |
Kojto | 111:4336505e4b1c | 237 | * structure, to indicate the type of logic level pull the pin should use. |
Kojto | 111:4336505e4b1c | 238 | */ |
Kojto | 111:4336505e4b1c | 239 | enum system_pinmux_pin_pull { |
Kojto | 111:4336505e4b1c | 240 | /** No logical pull should be applied to the pin. */ |
Kojto | 111:4336505e4b1c | 241 | SYSTEM_PINMUX_PIN_PULL_NONE, |
Kojto | 111:4336505e4b1c | 242 | /** Pin should be pulled up when idle. */ |
Kojto | 111:4336505e4b1c | 243 | SYSTEM_PINMUX_PIN_PULL_UP, |
Kojto | 111:4336505e4b1c | 244 | /** Pin should be pulled down when idle. */ |
Kojto | 111:4336505e4b1c | 245 | SYSTEM_PINMUX_PIN_PULL_DOWN, |
Kojto | 111:4336505e4b1c | 246 | }; |
Kojto | 111:4336505e4b1c | 247 | |
Kojto | 111:4336505e4b1c | 248 | /** |
Kojto | 111:4336505e4b1c | 249 | * \brief Port pin digital input sampling mode enum. |
Kojto | 111:4336505e4b1c | 250 | * |
Kojto | 111:4336505e4b1c | 251 | * Enum for the possible input sampling modes for the port pin configuration |
Kojto | 111:4336505e4b1c | 252 | * structure, to indicate the type of sampling a port pin should use. |
Kojto | 111:4336505e4b1c | 253 | */ |
Kojto | 111:4336505e4b1c | 254 | enum system_pinmux_pin_sample { |
Kojto | 111:4336505e4b1c | 255 | /** Pin input buffer should continuously sample the pin state. */ |
Kojto | 111:4336505e4b1c | 256 | SYSTEM_PINMUX_PIN_SAMPLE_CONTINUOUS, |
Kojto | 111:4336505e4b1c | 257 | /** Pin input buffer should be enabled when the IN register is read. */ |
Kojto | 111:4336505e4b1c | 258 | SYSTEM_PINMUX_PIN_SAMPLE_ONDEMAND, |
Kojto | 111:4336505e4b1c | 259 | }; |
Kojto | 111:4336505e4b1c | 260 | |
Kojto | 111:4336505e4b1c | 261 | /** |
Kojto | 111:4336505e4b1c | 262 | * \brief Port pin configuration structure. |
Kojto | 111:4336505e4b1c | 263 | * |
Kojto | 111:4336505e4b1c | 264 | * Configuration structure for a port pin instance. This structure should be |
Kojto | 111:4336505e4b1c | 265 | * structure should be initialized by the |
Kojto | 111:4336505e4b1c | 266 | * \ref system_pinmux_get_config_defaults() function before being modified by |
Kojto | 111:4336505e4b1c | 267 | * the user application. |
Kojto | 111:4336505e4b1c | 268 | */ |
Kojto | 111:4336505e4b1c | 269 | struct system_pinmux_config { |
Kojto | 111:4336505e4b1c | 270 | /** MUX index of the peripheral that should control the pin, if peripheral |
Kojto | 111:4336505e4b1c | 271 | * control is desired. For GPIO use, this should be set to |
Kojto | 111:4336505e4b1c | 272 | * \ref SYSTEM_PINMUX_GPIO. */ |
Kojto | 111:4336505e4b1c | 273 | uint8_t mux_position; |
Kojto | 111:4336505e4b1c | 274 | |
Kojto | 111:4336505e4b1c | 275 | /** Port buffer input/output direction. */ |
Kojto | 111:4336505e4b1c | 276 | enum system_pinmux_pin_dir direction; |
Kojto | 111:4336505e4b1c | 277 | |
Kojto | 111:4336505e4b1c | 278 | /** Logic level pull of the input buffer. */ |
Kojto | 111:4336505e4b1c | 279 | enum system_pinmux_pin_pull input_pull; |
Kojto | 111:4336505e4b1c | 280 | |
Kojto | 111:4336505e4b1c | 281 | /** Enable lowest possible powerstate on the pin. |
Kojto | 111:4336505e4b1c | 282 | * |
Kojto | 111:4336505e4b1c | 283 | * \note All other configurations will be ignored, the pin will be disabled. |
Kojto | 111:4336505e4b1c | 284 | */ |
Kojto | 111:4336505e4b1c | 285 | bool powersave; |
Kojto | 111:4336505e4b1c | 286 | }; |
Kojto | 111:4336505e4b1c | 287 | |
Kojto | 111:4336505e4b1c | 288 | /** \name Configuration and Initialization |
Kojto | 111:4336505e4b1c | 289 | * @{ |
Kojto | 111:4336505e4b1c | 290 | */ |
Kojto | 111:4336505e4b1c | 291 | |
Kojto | 111:4336505e4b1c | 292 | /** |
Kojto | 111:4336505e4b1c | 293 | * \brief Initializes a Port pin configuration structure to defaults. |
Kojto | 111:4336505e4b1c | 294 | * |
Kojto | 111:4336505e4b1c | 295 | * Initializes a given Port pin configuration structure to a set of |
Kojto | 111:4336505e4b1c | 296 | * known default values. This function should be called on all new |
Kojto | 111:4336505e4b1c | 297 | * instances of these configuration structures before being modified by the |
Kojto | 111:4336505e4b1c | 298 | * user application. |
Kojto | 111:4336505e4b1c | 299 | * |
Kojto | 111:4336505e4b1c | 300 | * The default configuration is as follows: |
Kojto | 111:4336505e4b1c | 301 | * \li Non peripheral (i.e. GPIO) controlled |
Kojto | 111:4336505e4b1c | 302 | * \li Input mode with internal pull-up enabled |
Kojto | 111:4336505e4b1c | 303 | * |
Kojto | 111:4336505e4b1c | 304 | * \param[out] config Configuration structure to initialize to default values |
Kojto | 111:4336505e4b1c | 305 | */ |
Kojto | 111:4336505e4b1c | 306 | static inline void system_pinmux_get_config_defaults( |
Kojto | 111:4336505e4b1c | 307 | struct system_pinmux_config *const config) |
Kojto | 111:4336505e4b1c | 308 | { |
Kojto | 111:4336505e4b1c | 309 | /* Sanity check arguments */ |
Kojto | 111:4336505e4b1c | 310 | Assert(config); |
Kojto | 111:4336505e4b1c | 311 | |
Kojto | 111:4336505e4b1c | 312 | /* Default configuration values */ |
Kojto | 111:4336505e4b1c | 313 | config->mux_position = SYSTEM_PINMUX_GPIO; |
Kojto | 111:4336505e4b1c | 314 | config->direction = SYSTEM_PINMUX_PIN_DIR_INPUT; |
Kojto | 111:4336505e4b1c | 315 | config->input_pull = SYSTEM_PINMUX_PIN_PULL_UP; |
Kojto | 111:4336505e4b1c | 316 | config->powersave = false; |
Kojto | 111:4336505e4b1c | 317 | } |
Kojto | 111:4336505e4b1c | 318 | |
Kojto | 111:4336505e4b1c | 319 | void system_pinmux_pin_set_config( |
Kojto | 111:4336505e4b1c | 320 | const uint8_t gpio_pin, |
Kojto | 111:4336505e4b1c | 321 | const struct system_pinmux_config *const config); |
Kojto | 111:4336505e4b1c | 322 | |
Kojto | 111:4336505e4b1c | 323 | void system_pinmux_group_set_config( |
Kojto | 111:4336505e4b1c | 324 | PortGroup *const port, |
Kojto | 111:4336505e4b1c | 325 | const uint32_t mask, |
Kojto | 111:4336505e4b1c | 326 | const struct system_pinmux_config *const config); |
Kojto | 111:4336505e4b1c | 327 | |
Kojto | 111:4336505e4b1c | 328 | /** @} */ |
Kojto | 111:4336505e4b1c | 329 | |
Kojto | 111:4336505e4b1c | 330 | /** \name Special Mode Configuration (Physical Group Orientated) |
Kojto | 111:4336505e4b1c | 331 | * @{ |
Kojto | 111:4336505e4b1c | 332 | */ |
Kojto | 111:4336505e4b1c | 333 | |
Kojto | 111:4336505e4b1c | 334 | /** |
Kojto | 111:4336505e4b1c | 335 | * \brief Retrieves the PORT module group instance from a given GPIO pin number. |
Kojto | 111:4336505e4b1c | 336 | * |
Kojto | 111:4336505e4b1c | 337 | * Retrieves the PORT module group instance associated with a given logical |
Kojto | 111:4336505e4b1c | 338 | * GPIO pin number. |
Kojto | 111:4336505e4b1c | 339 | * |
Kojto | 111:4336505e4b1c | 340 | * \param[in] gpio_pin Index of the GPIO pin to convert |
Kojto | 111:4336505e4b1c | 341 | * |
Kojto | 111:4336505e4b1c | 342 | * \return Base address of the associated PORT module. |
Kojto | 111:4336505e4b1c | 343 | */ |
Kojto | 111:4336505e4b1c | 344 | static inline PortGroup* system_pinmux_get_group_from_gpio_pin( |
Kojto | 111:4336505e4b1c | 345 | const uint8_t gpio_pin) |
Kojto | 111:4336505e4b1c | 346 | { |
Kojto | 111:4336505e4b1c | 347 | uint8_t port_index = (gpio_pin / 128); |
Kojto | 111:4336505e4b1c | 348 | uint8_t group_index = (gpio_pin / 32); |
Kojto | 111:4336505e4b1c | 349 | |
Kojto | 111:4336505e4b1c | 350 | /* Array of available ports. */ |
Kojto | 111:4336505e4b1c | 351 | Port *const ports[PORT_INST_NUM] = PORT_INSTS; |
Kojto | 111:4336505e4b1c | 352 | |
Kojto | 111:4336505e4b1c | 353 | if (port_index < PORT_INST_NUM) { |
Kojto | 111:4336505e4b1c | 354 | return &(ports[port_index]->Group[group_index]); |
Kojto | 111:4336505e4b1c | 355 | } else { |
Kojto | 111:4336505e4b1c | 356 | Assert(false); |
Kojto | 111:4336505e4b1c | 357 | return NULL; |
Kojto | 111:4336505e4b1c | 358 | } |
Kojto | 111:4336505e4b1c | 359 | } |
Kojto | 111:4336505e4b1c | 360 | |
Kojto | 111:4336505e4b1c | 361 | void system_pinmux_group_set_input_sample_mode( |
Kojto | 111:4336505e4b1c | 362 | PortGroup *const port, |
Kojto | 111:4336505e4b1c | 363 | const uint32_t mask, |
Kojto | 111:4336505e4b1c | 364 | const enum system_pinmux_pin_sample mode); |
Kojto | 111:4336505e4b1c | 365 | |
Kojto | 111:4336505e4b1c | 366 | /** @} */ |
Kojto | 111:4336505e4b1c | 367 | |
Kojto | 111:4336505e4b1c | 368 | /** \name Special Mode Configuration (Logical Pin Orientated) |
Kojto | 111:4336505e4b1c | 369 | * @{ |
Kojto | 111:4336505e4b1c | 370 | */ |
Kojto | 111:4336505e4b1c | 371 | |
Kojto | 111:4336505e4b1c | 372 | /** |
Kojto | 111:4336505e4b1c | 373 | * \brief Retrieves the currently selected MUX position of a logical pin. |
Kojto | 111:4336505e4b1c | 374 | * |
Kojto | 111:4336505e4b1c | 375 | * Retrieves the selected MUX peripheral on a given logical GPIO pin. |
Kojto | 111:4336505e4b1c | 376 | * |
Kojto | 111:4336505e4b1c | 377 | * \param[in] gpio_pin Index of the GPIO pin to configure |
Kojto | 111:4336505e4b1c | 378 | * |
Kojto | 111:4336505e4b1c | 379 | * \return Currently selected peripheral index on the specified pin. |
Kojto | 111:4336505e4b1c | 380 | */ |
Kojto | 111:4336505e4b1c | 381 | static inline uint8_t system_pinmux_pin_get_mux_position( |
Kojto | 111:4336505e4b1c | 382 | const uint8_t gpio_pin) |
Kojto | 111:4336505e4b1c | 383 | { |
Kojto | 111:4336505e4b1c | 384 | PortGroup *const port = system_pinmux_get_group_from_gpio_pin(gpio_pin); |
Kojto | 111:4336505e4b1c | 385 | uint32_t pin_index = (gpio_pin % 32); |
Kojto | 111:4336505e4b1c | 386 | |
Kojto | 111:4336505e4b1c | 387 | if (!(port->PINCFG[pin_index].reg & PORT_PINCFG_PMUXEN)) { |
Kojto | 111:4336505e4b1c | 388 | return SYSTEM_PINMUX_GPIO; |
Kojto | 111:4336505e4b1c | 389 | } |
Kojto | 111:4336505e4b1c | 390 | |
Kojto | 111:4336505e4b1c | 391 | uint32_t pmux_reg = port->PMUX[pin_index / 2].reg; |
Kojto | 111:4336505e4b1c | 392 | |
Kojto | 111:4336505e4b1c | 393 | if (pin_index & 1) { |
Kojto | 111:4336505e4b1c | 394 | return (pmux_reg & PORT_PMUX_PMUXO_Msk) >> PORT_PMUX_PMUXO_Pos; |
Kojto | 111:4336505e4b1c | 395 | } else { |
Kojto | 111:4336505e4b1c | 396 | return (pmux_reg & PORT_PMUX_PMUXE_Msk) >> PORT_PMUX_PMUXE_Pos; |
Kojto | 111:4336505e4b1c | 397 | } |
Kojto | 111:4336505e4b1c | 398 | } |
Kojto | 111:4336505e4b1c | 399 | |
Kojto | 111:4336505e4b1c | 400 | /** |
Kojto | 111:4336505e4b1c | 401 | * \brief Configures the input sampling mode for a GPIO pin. |
Kojto | 111:4336505e4b1c | 402 | * |
Kojto | 111:4336505e4b1c | 403 | * Configures the input sampling mode for a GPIO input, to |
Kojto | 111:4336505e4b1c | 404 | * control when the physical I/O pin value is sampled and |
Kojto | 111:4336505e4b1c | 405 | * stored inside the microcontroller. |
Kojto | 111:4336505e4b1c | 406 | * |
Kojto | 111:4336505e4b1c | 407 | * \param[in] gpio_pin Index of the GPIO pin to configure |
Kojto | 111:4336505e4b1c | 408 | * \param[in] mode New pin sampling mode to configure |
Kojto | 111:4336505e4b1c | 409 | */ |
Kojto | 111:4336505e4b1c | 410 | static inline void system_pinmux_pin_set_input_sample_mode( |
Kojto | 111:4336505e4b1c | 411 | const uint8_t gpio_pin, |
Kojto | 111:4336505e4b1c | 412 | const enum system_pinmux_pin_sample mode) |
Kojto | 111:4336505e4b1c | 413 | { |
Kojto | 111:4336505e4b1c | 414 | PortGroup* const port = system_pinmux_get_group_from_gpio_pin(gpio_pin); |
Kojto | 111:4336505e4b1c | 415 | uint32_t pin_index = (gpio_pin % 32); |
Kojto | 111:4336505e4b1c | 416 | |
Kojto | 111:4336505e4b1c | 417 | if (mode == SYSTEM_PINMUX_PIN_SAMPLE_ONDEMAND) { |
Kojto | 111:4336505e4b1c | 418 | port->CTRL.reg |= (1 << pin_index); |
Kojto | 111:4336505e4b1c | 419 | } else { |
Kojto | 111:4336505e4b1c | 420 | port->CTRL.reg &= ~(1 << pin_index); |
Kojto | 111:4336505e4b1c | 421 | } |
Kojto | 111:4336505e4b1c | 422 | } |
Kojto | 111:4336505e4b1c | 423 | |
Kojto | 111:4336505e4b1c | 424 | /** @} */ |
Kojto | 111:4336505e4b1c | 425 | |
Kojto | 111:4336505e4b1c | 426 | #ifdef FEATURE_SYSTEM_PINMUX_DRIVE_STRENGTH |
Kojto | 111:4336505e4b1c | 427 | /** |
Kojto | 111:4336505e4b1c | 428 | * \brief Port pin drive output strength enum. |
Kojto | 111:4336505e4b1c | 429 | * |
Kojto | 111:4336505e4b1c | 430 | * Enum for the possible output drive strengths for the port pin |
Kojto | 111:4336505e4b1c | 431 | * configuration structure, to indicate the driver strength the pin should |
Kojto | 111:4336505e4b1c | 432 | * use. |
Kojto | 111:4336505e4b1c | 433 | */ |
Kojto | 111:4336505e4b1c | 434 | enum system_pinmux_pin_strength { |
Kojto | 111:4336505e4b1c | 435 | /** Normal output driver strength. */ |
Kojto | 111:4336505e4b1c | 436 | SYSTEM_PINMUX_PIN_STRENGTH_NORMAL, |
Kojto | 111:4336505e4b1c | 437 | /** High current output driver strength. */ |
Kojto | 111:4336505e4b1c | 438 | SYSTEM_PINMUX_PIN_STRENGTH_HIGH, |
Kojto | 111:4336505e4b1c | 439 | }; |
Kojto | 111:4336505e4b1c | 440 | |
Kojto | 111:4336505e4b1c | 441 | /** |
Kojto | 111:4336505e4b1c | 442 | * \brief Configures the output driver strength mode for a GPIO pin. |
Kojto | 111:4336505e4b1c | 443 | * |
Kojto | 111:4336505e4b1c | 444 | * Configures the output drive strength for a GPIO output, to |
Kojto | 111:4336505e4b1c | 445 | * control the amount of current the pad is able to sink/source. |
Kojto | 111:4336505e4b1c | 446 | * |
Kojto | 111:4336505e4b1c | 447 | * \param[in] gpio_pin Index of the GPIO pin to configure |
Kojto | 111:4336505e4b1c | 448 | * \param[in] mode New output driver strength mode to configure |
Kojto | 111:4336505e4b1c | 449 | */ |
Kojto | 111:4336505e4b1c | 450 | static inline void system_pinmux_pin_set_output_strength( |
Kojto | 111:4336505e4b1c | 451 | const uint8_t gpio_pin, |
Kojto | 111:4336505e4b1c | 452 | const enum system_pinmux_pin_strength mode) |
Kojto | 111:4336505e4b1c | 453 | { |
Kojto | 111:4336505e4b1c | 454 | PortGroup* const port = system_pinmux_get_group_from_gpio_pin(gpio_pin); |
Kojto | 111:4336505e4b1c | 455 | uint32_t pin_index = (gpio_pin % 32); |
Kojto | 111:4336505e4b1c | 456 | |
Kojto | 111:4336505e4b1c | 457 | if (mode == SYSTEM_PINMUX_PIN_STRENGTH_HIGH) { |
Kojto | 111:4336505e4b1c | 458 | port->PINCFG[pin_index].reg |= PORT_PINCFG_DRVSTR; |
Kojto | 111:4336505e4b1c | 459 | } else { |
Kojto | 111:4336505e4b1c | 460 | port->PINCFG[pin_index].reg &= ~PORT_PINCFG_DRVSTR; |
Kojto | 111:4336505e4b1c | 461 | } |
Kojto | 111:4336505e4b1c | 462 | } |
Kojto | 111:4336505e4b1c | 463 | |
Kojto | 111:4336505e4b1c | 464 | void system_pinmux_group_set_output_strength( |
Kojto | 111:4336505e4b1c | 465 | PortGroup *const port, |
Kojto | 111:4336505e4b1c | 466 | const uint32_t mask, |
Kojto | 111:4336505e4b1c | 467 | const enum system_pinmux_pin_strength mode); |
Kojto | 111:4336505e4b1c | 468 | #endif |
Kojto | 111:4336505e4b1c | 469 | |
Kojto | 111:4336505e4b1c | 470 | #ifdef FEATURE_SYSTEM_PINMUX_SLEWRATE_LIMITER |
Kojto | 111:4336505e4b1c | 471 | /** |
Kojto | 111:4336505e4b1c | 472 | * \brief Port pin output slew rate enum. |
Kojto | 111:4336505e4b1c | 473 | * |
Kojto | 111:4336505e4b1c | 474 | * Enum for the possible output drive slew rates for the port pin |
Kojto | 111:4336505e4b1c | 475 | * configuration structure, to indicate the driver slew rate the pin should |
Kojto | 111:4336505e4b1c | 476 | * use. |
Kojto | 111:4336505e4b1c | 477 | */ |
Kojto | 111:4336505e4b1c | 478 | enum system_pinmux_pin_slew_rate { |
Kojto | 111:4336505e4b1c | 479 | /** Normal pin output slew rate. */ |
Kojto | 111:4336505e4b1c | 480 | SYSTEM_PINMUX_PIN_SLEW_RATE_NORMAL, |
Kojto | 111:4336505e4b1c | 481 | /** Enable slew rate limiter on the pin. */ |
Kojto | 111:4336505e4b1c | 482 | SYSTEM_PINMUX_PIN_SLEW_RATE_LIMITED, |
Kojto | 111:4336505e4b1c | 483 | }; |
Kojto | 111:4336505e4b1c | 484 | |
Kojto | 111:4336505e4b1c | 485 | /** |
Kojto | 111:4336505e4b1c | 486 | * \brief Configures the output slew rate mode for a GPIO pin. |
Kojto | 111:4336505e4b1c | 487 | * |
Kojto | 111:4336505e4b1c | 488 | * Configures the output slew rate mode for a GPIO output, to |
Kojto | 111:4336505e4b1c | 489 | * control the speed at which the physical output pin can react to |
Kojto | 111:4336505e4b1c | 490 | * logical changes of the I/O pin value. |
Kojto | 111:4336505e4b1c | 491 | * |
Kojto | 111:4336505e4b1c | 492 | * \param[in] gpio_pin Index of the GPIO pin to configure |
Kojto | 111:4336505e4b1c | 493 | * \param[in] mode New pin slew rate mode to configure |
Kojto | 111:4336505e4b1c | 494 | */ |
Kojto | 111:4336505e4b1c | 495 | static inline void system_pinmux_pin_set_output_slew_rate( |
Kojto | 111:4336505e4b1c | 496 | const uint8_t gpio_pin, |
Kojto | 111:4336505e4b1c | 497 | const enum system_pinmux_pin_slew_rate mode) |
Kojto | 111:4336505e4b1c | 498 | { |
Kojto | 111:4336505e4b1c | 499 | PortGroup* const port = system_pinmux_get_group_from_gpio_pin(gpio_pin); |
Kojto | 111:4336505e4b1c | 500 | uint32_t pin_index = (gpio_pin % 32); |
Kojto | 111:4336505e4b1c | 501 | |
Kojto | 111:4336505e4b1c | 502 | if (mode == SYSTEM_PINMUX_PIN_SLEW_RATE_LIMITED) { |
Kojto | 111:4336505e4b1c | 503 | port->PINCFG[pin_index].reg |= PORT_PINCFG_SLEWLIM; |
Kojto | 111:4336505e4b1c | 504 | } else { |
Kojto | 111:4336505e4b1c | 505 | port->PINCFG[pin_index].reg &= ~PORT_PINCFG_SLEWLIM; |
Kojto | 111:4336505e4b1c | 506 | } |
Kojto | 111:4336505e4b1c | 507 | } |
Kojto | 111:4336505e4b1c | 508 | |
Kojto | 111:4336505e4b1c | 509 | void system_pinmux_group_set_output_slew_rate( |
Kojto | 111:4336505e4b1c | 510 | PortGroup *const port, |
Kojto | 111:4336505e4b1c | 511 | const uint32_t mask, |
Kojto | 111:4336505e4b1c | 512 | const enum system_pinmux_pin_slew_rate mode); |
Kojto | 111:4336505e4b1c | 513 | #endif |
Kojto | 111:4336505e4b1c | 514 | |
Kojto | 111:4336505e4b1c | 515 | #ifdef FEATURE_SYSTEM_PINMUX_OPEN_DRAIN |
Kojto | 111:4336505e4b1c | 516 | /** |
Kojto | 111:4336505e4b1c | 517 | * \brief Port pin output drive mode enum. |
Kojto | 111:4336505e4b1c | 518 | * |
Kojto | 111:4336505e4b1c | 519 | * Enum for the possible output drive modes for the port pin configuration |
Kojto | 111:4336505e4b1c | 520 | * structure, to indicate the output mode the pin should use. |
Kojto | 111:4336505e4b1c | 521 | */ |
Kojto | 111:4336505e4b1c | 522 | enum system_pinmux_pin_drive { |
Kojto | 111:4336505e4b1c | 523 | /** Use totem pole output drive mode. */ |
Kojto | 111:4336505e4b1c | 524 | SYSTEM_PINMUX_PIN_DRIVE_TOTEM, |
Kojto | 111:4336505e4b1c | 525 | /** Use open drain output drive mode. */ |
Kojto | 111:4336505e4b1c | 526 | SYSTEM_PINMUX_PIN_DRIVE_OPEN_DRAIN, |
Kojto | 111:4336505e4b1c | 527 | }; |
Kojto | 111:4336505e4b1c | 528 | |
Kojto | 111:4336505e4b1c | 529 | /** |
Kojto | 111:4336505e4b1c | 530 | * \brief Configures the output driver mode for a GPIO pin. |
Kojto | 111:4336505e4b1c | 531 | * |
Kojto | 111:4336505e4b1c | 532 | * Configures the output driver mode for a GPIO output, to |
Kojto | 111:4336505e4b1c | 533 | * control the pad behavior. |
Kojto | 111:4336505e4b1c | 534 | * |
Kojto | 111:4336505e4b1c | 535 | * \param[in] gpio_pin Index of the GPIO pin to configure |
Kojto | 111:4336505e4b1c | 536 | * \param[in] mode New pad output driver mode to configure |
Kojto | 111:4336505e4b1c | 537 | */ |
Kojto | 111:4336505e4b1c | 538 | static inline void system_pinmux_pin_set_output_drive( |
Kojto | 111:4336505e4b1c | 539 | const uint8_t gpio_pin, |
Kojto | 111:4336505e4b1c | 540 | const enum system_pinmux_pin_drive mode) |
Kojto | 111:4336505e4b1c | 541 | { |
Kojto | 111:4336505e4b1c | 542 | PortGroup* const port = system_pinmux_get_group_from_gpio_pin(gpio_pin); |
Kojto | 111:4336505e4b1c | 543 | uint32_t pin_index = (gpio_pin % 32); |
Kojto | 111:4336505e4b1c | 544 | |
Kojto | 111:4336505e4b1c | 545 | if (mode == SYSTEM_PINMUX_PIN_DRIVE_OPEN_DRAIN) { |
Kojto | 111:4336505e4b1c | 546 | port->PINCFG[pin_index].reg |= PORT_PINCFG_ODRAIN; |
Kojto | 111:4336505e4b1c | 547 | } else { |
Kojto | 111:4336505e4b1c | 548 | port->PINCFG[pin_index].reg &= ~PORT_PINCFG_ODRAIN; |
Kojto | 111:4336505e4b1c | 549 | } |
Kojto | 111:4336505e4b1c | 550 | } |
Kojto | 111:4336505e4b1c | 551 | |
Kojto | 111:4336505e4b1c | 552 | void system_pinmux_group_set_output_drive( |
Kojto | 111:4336505e4b1c | 553 | PortGroup *const port, |
Kojto | 111:4336505e4b1c | 554 | const uint32_t mask, |
Kojto | 111:4336505e4b1c | 555 | const enum system_pinmux_pin_drive mode); |
Kojto | 111:4336505e4b1c | 556 | #endif |
Kojto | 111:4336505e4b1c | 557 | |
Kojto | 111:4336505e4b1c | 558 | #ifdef __cplusplus |
Kojto | 111:4336505e4b1c | 559 | } |
Kojto | 111:4336505e4b1c | 560 | #endif |
Kojto | 111:4336505e4b1c | 561 | |
Kojto | 111:4336505e4b1c | 562 | /** @} */ |
Kojto | 111:4336505e4b1c | 563 | |
Kojto | 111:4336505e4b1c | 564 | /** |
Kojto | 111:4336505e4b1c | 565 | * \page asfdoc_sam0_system_pinmux_extra Extra Information for SYSTEM PINMUX Driver |
Kojto | 111:4336505e4b1c | 566 | * |
Kojto | 111:4336505e4b1c | 567 | * \section asfdoc_sam0_system_pinmux_extra_acronyms Acronyms |
Kojto | 111:4336505e4b1c | 568 | * The table below presents the acronyms used in this module: |
Kojto | 111:4336505e4b1c | 569 | * |
Kojto | 111:4336505e4b1c | 570 | * <table> |
Kojto | 111:4336505e4b1c | 571 | * <tr> |
Kojto | 111:4336505e4b1c | 572 | * <th>Acronym</th> |
Kojto | 111:4336505e4b1c | 573 | * <th>Description</th> |
Kojto | 111:4336505e4b1c | 574 | * </tr> |
Kojto | 111:4336505e4b1c | 575 | * <tr> |
Kojto | 111:4336505e4b1c | 576 | * <td>GPIO</td> |
Kojto | 111:4336505e4b1c | 577 | * <td>General Purpose Input/Output</td> |
Kojto | 111:4336505e4b1c | 578 | * </tr> |
Kojto | 111:4336505e4b1c | 579 | * <tr> |
Kojto | 111:4336505e4b1c | 580 | * <td>MUX</td> |
Kojto | 111:4336505e4b1c | 581 | * <td>Multiplexer</td> |
Kojto | 111:4336505e4b1c | 582 | * </tr> |
Kojto | 111:4336505e4b1c | 583 | * </table> |
Kojto | 111:4336505e4b1c | 584 | * |
Kojto | 111:4336505e4b1c | 585 | * |
Kojto | 111:4336505e4b1c | 586 | * \section asfdoc_sam0_system_pinmux_extra_dependencies Dependencies |
Kojto | 111:4336505e4b1c | 587 | * This driver has the following dependencies: |
Kojto | 111:4336505e4b1c | 588 | * |
Kojto | 111:4336505e4b1c | 589 | * - None |
Kojto | 111:4336505e4b1c | 590 | * |
Kojto | 111:4336505e4b1c | 591 | * |
Kojto | 111:4336505e4b1c | 592 | * \section asfdoc_sam0_system_pinmux_extra_errata Errata |
Kojto | 111:4336505e4b1c | 593 | * There are no errata related to this driver. |
Kojto | 111:4336505e4b1c | 594 | * |
Kojto | 111:4336505e4b1c | 595 | * |
Kojto | 111:4336505e4b1c | 596 | * \section asfdoc_sam0_system_pinmux_extra_history Module History |
Kojto | 111:4336505e4b1c | 597 | * An overview of the module history is presented in the table below, with |
Kojto | 111:4336505e4b1c | 598 | * details on the enhancements and fixes made to the module since its first |
Kojto | 111:4336505e4b1c | 599 | * release. The current version of this corresponds to the newest version in |
Kojto | 111:4336505e4b1c | 600 | * the table. |
Kojto | 111:4336505e4b1c | 601 | * |
Kojto | 111:4336505e4b1c | 602 | * <table> |
Kojto | 111:4336505e4b1c | 603 | * <tr> |
Kojto | 111:4336505e4b1c | 604 | * <th>Changelog</th> |
Kojto | 111:4336505e4b1c | 605 | * </tr> |
Kojto | 111:4336505e4b1c | 606 | * <tr> |
Kojto | 111:4336505e4b1c | 607 | * <td>Removed code of open drain, slew limit and drive strength |
Kojto | 111:4336505e4b1c | 608 | * features</td> |
Kojto | 111:4336505e4b1c | 609 | * </tr> |
Kojto | 111:4336505e4b1c | 610 | * <tr> |
Kojto | 111:4336505e4b1c | 611 | * <td>Fixed broken sampling mode function implementations, which wrote |
Kojto | 111:4336505e4b1c | 612 | * corrupt configuration values to the device registers</td> |
Kojto | 111:4336505e4b1c | 613 | * </tr> |
Kojto | 111:4336505e4b1c | 614 | * <tr> |
Kojto | 111:4336505e4b1c | 615 | * <td>Added missing NULL pointer asserts to the PORT driver functions</td> |
Kojto | 111:4336505e4b1c | 616 | * </tr> |
Kojto | 111:4336505e4b1c | 617 | * <tr> |
Kojto | 111:4336505e4b1c | 618 | * <td>Initial Release</td> |
Kojto | 111:4336505e4b1c | 619 | * </tr> |
Kojto | 111:4336505e4b1c | 620 | * </table> |
Kojto | 111:4336505e4b1c | 621 | */ |
Kojto | 111:4336505e4b1c | 622 | |
Kojto | 111:4336505e4b1c | 623 | /** |
Kojto | 111:4336505e4b1c | 624 | * \page asfdoc_sam0_system_pinmux_exqsg Examples for SYSTEM PINMUX Driver |
Kojto | 111:4336505e4b1c | 625 | * |
Kojto | 111:4336505e4b1c | 626 | * This is a list of the available Quick Start guides (QSGs) and example |
Kojto | 111:4336505e4b1c | 627 | * applications for \ref asfdoc_sam0_system_pinmux_group. QSGs are simple |
Kojto | 111:4336505e4b1c | 628 | * examples with step-by-step instructions to configure and use this driver in a |
Kojto | 111:4336505e4b1c | 629 | * selection of use cases. Note that QSGs can be compiled as a standalone |
Kojto | 111:4336505e4b1c | 630 | * application or be added to the user application. |
Kojto | 111:4336505e4b1c | 631 | * |
Kojto | 111:4336505e4b1c | 632 | * - \subpage asfdoc_sam0_system_pinmux_basic_use_case |
Kojto | 111:4336505e4b1c | 633 | * |
Kojto | 111:4336505e4b1c | 634 | * \page asfdoc_sam0_system_pinmux_document_revision_history Document Revision History |
Kojto | 111:4336505e4b1c | 635 | * |
Kojto | 111:4336505e4b1c | 636 | * <table> |
Kojto | 111:4336505e4b1c | 637 | * <tr> |
Kojto | 111:4336505e4b1c | 638 | * <th>Doc. Rev.</td> |
Kojto | 111:4336505e4b1c | 639 | * <th>Date</td> |
Kojto | 111:4336505e4b1c | 640 | * <th>Comments</td> |
Kojto | 111:4336505e4b1c | 641 | * </tr> |
Kojto | 111:4336505e4b1c | 642 | * <tr> |
Kojto | 111:4336505e4b1c | 643 | * <td>F</td> |
Kojto | 111:4336505e4b1c | 644 | * <td>06/2015</td> |
Kojto | 111:4336505e4b1c | 645 | * <td>Add support for SAML21, SAMDAx, and SAMC20/C21.</td> |
Kojto | 111:4336505e4b1c | 646 | * </tr> |
Kojto | 111:4336505e4b1c | 647 | * <tr> |
Kojto | 111:4336505e4b1c | 648 | * <td>E</td> |
Kojto | 111:4336505e4b1c | 649 | * <td>12/2014</td> |
Kojto | 111:4336505e4b1c | 650 | * <td>Add support for SAMR21 and SAMD10/D11.</td> |
Kojto | 111:4336505e4b1c | 651 | * </tr> |
Kojto | 111:4336505e4b1c | 652 | * <tr> |
Kojto | 111:4336505e4b1c | 653 | * <td>D</td> |
Kojto | 111:4336505e4b1c | 654 | * <td>01/2014</td> |
Kojto | 111:4336505e4b1c | 655 | * <td>Add support for SAMD21.</td> |
Kojto | 111:4336505e4b1c | 656 | * </tr> |
Kojto | 111:4336505e4b1c | 657 | * <tr> |
Kojto | 111:4336505e4b1c | 658 | * <td>C</td> |
Kojto | 111:4336505e4b1c | 659 | * <td>09/2013</td> |
Kojto | 111:4336505e4b1c | 660 | * <td>Fixed incorrect documentation for the device pin sampling mode.</td> |
Kojto | 111:4336505e4b1c | 661 | * </tr> |
Kojto | 111:4336505e4b1c | 662 | * <tr> |
Kojto | 111:4336505e4b1c | 663 | * <td>B</td> |
Kojto | 111:4336505e4b1c | 664 | * <td>06/2013</td> |
Kojto | 111:4336505e4b1c | 665 | * <td>Corrected documentation typos.</td> |
Kojto | 111:4336505e4b1c | 666 | * </tr> |
Kojto | 111:4336505e4b1c | 667 | * <tr> |
Kojto | 111:4336505e4b1c | 668 | * <td>A</td> |
Kojto | 111:4336505e4b1c | 669 | * <td>06/2013</td> |
Kojto | 111:4336505e4b1c | 670 | * <td>Initial release</td> |
Kojto | 111:4336505e4b1c | 671 | * </tr> |
Kojto | 111:4336505e4b1c | 672 | * </table> |
Kojto | 111:4336505e4b1c | 673 | */ |
Kojto | 111:4336505e4b1c | 674 | |
Kojto | 111:4336505e4b1c | 675 | #endif |