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