mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
targets/hal/TARGET_Atmel/TARGET_SAM_CortexM0P/drivers/system/pinmux/pinmux.c@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 | #include <pinmux.h> |
mbed_official | 15:a81a8d6c1dfe | 47 | |
mbed_official | 15:a81a8d6c1dfe | 48 | /** |
mbed_official | 15:a81a8d6c1dfe | 49 | * \internal |
mbed_official | 15:a81a8d6c1dfe | 50 | * Writes out a given configuration of a Port pin configuration to the |
mbed_official | 15:a81a8d6c1dfe | 51 | * hardware module. |
mbed_official | 15:a81a8d6c1dfe | 52 | * |
mbed_official | 15:a81a8d6c1dfe | 53 | * \note If the pin direction is set as an output, the pull-up/pull-down input |
mbed_official | 15:a81a8d6c1dfe | 54 | * configuration setting is ignored. |
mbed_official | 15:a81a8d6c1dfe | 55 | * |
mbed_official | 15:a81a8d6c1dfe | 56 | * \param[in] port Base of the PORT module to configure |
mbed_official | 15:a81a8d6c1dfe | 57 | * \param[in] pin_mask Mask of the port pin to configure |
mbed_official | 15:a81a8d6c1dfe | 58 | * \param[in] config Configuration settings for the pin |
mbed_official | 15:a81a8d6c1dfe | 59 | */ |
mbed_official | 15:a81a8d6c1dfe | 60 | static void _system_pinmux_config( |
mbed_official | 15:a81a8d6c1dfe | 61 | PortGroup *const port, |
mbed_official | 15:a81a8d6c1dfe | 62 | const uint32_t pin_mask, |
mbed_official | 15:a81a8d6c1dfe | 63 | const struct system_pinmux_config *const config) |
mbed_official | 15:a81a8d6c1dfe | 64 | { |
mbed_official | 15:a81a8d6c1dfe | 65 | Assert(port); |
mbed_official | 15:a81a8d6c1dfe | 66 | Assert(config); |
mbed_official | 15:a81a8d6c1dfe | 67 | |
mbed_official | 15:a81a8d6c1dfe | 68 | /* Track the configuration bits into a temporary variable before writing */ |
mbed_official | 15:a81a8d6c1dfe | 69 | uint32_t pin_cfg = 0; |
mbed_official | 15:a81a8d6c1dfe | 70 | |
mbed_official | 15:a81a8d6c1dfe | 71 | /* Enabled powersave mode, don't create configuration */ |
mbed_official | 15:a81a8d6c1dfe | 72 | if (!config->powersave) { |
mbed_official | 15:a81a8d6c1dfe | 73 | /* Enable the pin peripheral MUX flag if non-GPIO selected (pinmux will |
mbed_official | 15:a81a8d6c1dfe | 74 | * be written later) and store the new MUX mask */ |
mbed_official | 15:a81a8d6c1dfe | 75 | if (config->mux_position != SYSTEM_PINMUX_GPIO) { |
mbed_official | 15:a81a8d6c1dfe | 76 | pin_cfg |= PORT_WRCONFIG_PMUXEN; |
mbed_official | 15:a81a8d6c1dfe | 77 | pin_cfg |= (config->mux_position << PORT_WRCONFIG_PMUX_Pos); |
mbed_official | 15:a81a8d6c1dfe | 78 | } |
mbed_official | 15:a81a8d6c1dfe | 79 | |
mbed_official | 15:a81a8d6c1dfe | 80 | /* Check if the user has requested that the input buffer be enabled */ |
mbed_official | 15:a81a8d6c1dfe | 81 | if ((config->direction == SYSTEM_PINMUX_PIN_DIR_INPUT) || |
mbed_official | 15:a81a8d6c1dfe | 82 | (config->direction == SYSTEM_PINMUX_PIN_DIR_OUTPUT_WITH_READBACK)) { |
mbed_official | 15:a81a8d6c1dfe | 83 | /* Enable input buffer flag */ |
mbed_official | 15:a81a8d6c1dfe | 84 | pin_cfg |= PORT_WRCONFIG_INEN; |
mbed_official | 15:a81a8d6c1dfe | 85 | |
mbed_official | 15:a81a8d6c1dfe | 86 | /* Enable pull-up/pull-down control flag if requested */ |
mbed_official | 15:a81a8d6c1dfe | 87 | if (config->input_pull != SYSTEM_PINMUX_PIN_PULL_NONE) { |
mbed_official | 15:a81a8d6c1dfe | 88 | pin_cfg |= PORT_WRCONFIG_PULLEN; |
mbed_official | 15:a81a8d6c1dfe | 89 | } |
mbed_official | 15:a81a8d6c1dfe | 90 | |
mbed_official | 15:a81a8d6c1dfe | 91 | /* Clear the port DIR bits to disable the output buffer */ |
mbed_official | 15:a81a8d6c1dfe | 92 | port->DIRCLR.reg = pin_mask; |
mbed_official | 15:a81a8d6c1dfe | 93 | } |
mbed_official | 15:a81a8d6c1dfe | 94 | |
mbed_official | 15:a81a8d6c1dfe | 95 | /* Check if the user has requested that the output buffer be enabled */ |
mbed_official | 15:a81a8d6c1dfe | 96 | if ((config->direction == SYSTEM_PINMUX_PIN_DIR_OUTPUT) || |
mbed_official | 15:a81a8d6c1dfe | 97 | (config->direction == SYSTEM_PINMUX_PIN_DIR_OUTPUT_WITH_READBACK)) { |
mbed_official | 15:a81a8d6c1dfe | 98 | /* Cannot use a pull-up if the output driver is enabled, |
mbed_official | 15:a81a8d6c1dfe | 99 | * if requested the input buffer can only sample the current |
mbed_official | 15:a81a8d6c1dfe | 100 | * output state */ |
mbed_official | 15:a81a8d6c1dfe | 101 | pin_cfg &= ~PORT_WRCONFIG_PULLEN; |
mbed_official | 15:a81a8d6c1dfe | 102 | } |
mbed_official | 15:a81a8d6c1dfe | 103 | } else { |
mbed_official | 15:a81a8d6c1dfe | 104 | port->DIRCLR.reg = pin_mask; |
mbed_official | 15:a81a8d6c1dfe | 105 | } |
mbed_official | 15:a81a8d6c1dfe | 106 | |
mbed_official | 15:a81a8d6c1dfe | 107 | /* The Write Configuration register (WRCONFIG) requires the |
mbed_official | 15:a81a8d6c1dfe | 108 | * pins to to grouped into two 16-bit half-words - split them out here */ |
mbed_official | 15:a81a8d6c1dfe | 109 | uint32_t lower_pin_mask = (pin_mask & 0xFFFF); |
mbed_official | 15:a81a8d6c1dfe | 110 | uint32_t upper_pin_mask = (pin_mask >> 16); |
mbed_official | 15:a81a8d6c1dfe | 111 | |
mbed_official | 15:a81a8d6c1dfe | 112 | /* Configure the lower 16-bits of the port to the desired configuration, |
mbed_official | 15:a81a8d6c1dfe | 113 | * including the pin peripheral multiplexer just in case it is enabled */ |
mbed_official | 15:a81a8d6c1dfe | 114 | port->WRCONFIG.reg |
mbed_official | 15:a81a8d6c1dfe | 115 | = (lower_pin_mask << PORT_WRCONFIG_PINMASK_Pos) | |
mbed_official | 15:a81a8d6c1dfe | 116 | pin_cfg | PORT_WRCONFIG_WRPMUX | PORT_WRCONFIG_WRPINCFG; |
mbed_official | 15:a81a8d6c1dfe | 117 | |
mbed_official | 15:a81a8d6c1dfe | 118 | /* Configure the upper 16-bits of the port to the desired configuration, |
mbed_official | 15:a81a8d6c1dfe | 119 | * including the pin peripheral multiplexer just in case it is enabled */ |
mbed_official | 15:a81a8d6c1dfe | 120 | port->WRCONFIG.reg |
mbed_official | 15:a81a8d6c1dfe | 121 | = (upper_pin_mask << PORT_WRCONFIG_PINMASK_Pos) | |
mbed_official | 15:a81a8d6c1dfe | 122 | pin_cfg | PORT_WRCONFIG_WRPMUX | PORT_WRCONFIG_WRPINCFG | |
mbed_official | 15:a81a8d6c1dfe | 123 | PORT_WRCONFIG_HWSEL; |
mbed_official | 15:a81a8d6c1dfe | 124 | |
mbed_official | 15:a81a8d6c1dfe | 125 | if(!config->powersave) { |
mbed_official | 15:a81a8d6c1dfe | 126 | /* Set the pull-up state once the port pins are configured if one was |
mbed_official | 15:a81a8d6c1dfe | 127 | * requested and it does not violate the valid set of port |
mbed_official | 15:a81a8d6c1dfe | 128 | * configurations */ |
mbed_official | 15:a81a8d6c1dfe | 129 | if (pin_cfg & PORT_WRCONFIG_PULLEN) { |
mbed_official | 15:a81a8d6c1dfe | 130 | /* Set the OUT register bits to enable the pull-up if requested, |
mbed_official | 15:a81a8d6c1dfe | 131 | * clear to enable pull-down */ |
mbed_official | 15:a81a8d6c1dfe | 132 | if (config->input_pull == SYSTEM_PINMUX_PIN_PULL_UP) { |
mbed_official | 15:a81a8d6c1dfe | 133 | port->OUTSET.reg = pin_mask; |
mbed_official | 15:a81a8d6c1dfe | 134 | } else { |
mbed_official | 15:a81a8d6c1dfe | 135 | port->OUTCLR.reg = pin_mask; |
mbed_official | 15:a81a8d6c1dfe | 136 | } |
mbed_official | 15:a81a8d6c1dfe | 137 | } |
mbed_official | 15:a81a8d6c1dfe | 138 | |
mbed_official | 15:a81a8d6c1dfe | 139 | /* Check if the user has requested that the output buffer be enabled */ |
mbed_official | 15:a81a8d6c1dfe | 140 | if ((config->direction == SYSTEM_PINMUX_PIN_DIR_OUTPUT) || |
mbed_official | 15:a81a8d6c1dfe | 141 | (config->direction == SYSTEM_PINMUX_PIN_DIR_OUTPUT_WITH_READBACK)) { |
mbed_official | 15:a81a8d6c1dfe | 142 | /* Set the port DIR bits to enable the output buffer */ |
mbed_official | 15:a81a8d6c1dfe | 143 | port->DIRSET.reg = pin_mask; |
mbed_official | 15:a81a8d6c1dfe | 144 | } |
mbed_official | 15:a81a8d6c1dfe | 145 | } |
mbed_official | 15:a81a8d6c1dfe | 146 | } |
mbed_official | 15:a81a8d6c1dfe | 147 | |
mbed_official | 15:a81a8d6c1dfe | 148 | /** |
mbed_official | 15:a81a8d6c1dfe | 149 | * \brief Writes a Port pin configuration to the hardware module. |
mbed_official | 15:a81a8d6c1dfe | 150 | * |
mbed_official | 15:a81a8d6c1dfe | 151 | * Writes out a given configuration of a Port pin configuration to the hardware |
mbed_official | 15:a81a8d6c1dfe | 152 | * module. |
mbed_official | 15:a81a8d6c1dfe | 153 | * |
mbed_official | 15:a81a8d6c1dfe | 154 | * \note If the pin direction is set as an output, the pull-up/pull-down input |
mbed_official | 15:a81a8d6c1dfe | 155 | * configuration setting is ignored. |
mbed_official | 15:a81a8d6c1dfe | 156 | * |
mbed_official | 15:a81a8d6c1dfe | 157 | * \param[in] gpio_pin Index of the GPIO pin to configure |
mbed_official | 15:a81a8d6c1dfe | 158 | * \param[in] config Configuration settings for the pin |
mbed_official | 15:a81a8d6c1dfe | 159 | */ |
mbed_official | 15:a81a8d6c1dfe | 160 | void system_pinmux_pin_set_config( |
mbed_official | 15:a81a8d6c1dfe | 161 | const uint8_t gpio_pin, |
mbed_official | 15:a81a8d6c1dfe | 162 | const struct system_pinmux_config *const config) |
mbed_official | 15:a81a8d6c1dfe | 163 | { |
mbed_official | 15:a81a8d6c1dfe | 164 | PortGroup *const port = system_pinmux_get_group_from_gpio_pin(gpio_pin); |
mbed_official | 15:a81a8d6c1dfe | 165 | uint32_t pin_mask = (1UL << (gpio_pin % 32)); |
mbed_official | 15:a81a8d6c1dfe | 166 | |
mbed_official | 15:a81a8d6c1dfe | 167 | _system_pinmux_config(port, pin_mask, config); |
mbed_official | 15:a81a8d6c1dfe | 168 | } |
mbed_official | 15:a81a8d6c1dfe | 169 | |
mbed_official | 15:a81a8d6c1dfe | 170 | /** |
mbed_official | 15:a81a8d6c1dfe | 171 | * \brief Writes a Port pin group configuration to the hardware module. |
mbed_official | 15:a81a8d6c1dfe | 172 | * |
mbed_official | 15:a81a8d6c1dfe | 173 | * Writes out a given configuration of a Port pin group configuration to the |
mbed_official | 15:a81a8d6c1dfe | 174 | * hardware module. |
mbed_official | 15:a81a8d6c1dfe | 175 | * |
mbed_official | 15:a81a8d6c1dfe | 176 | * \note If the pin direction is set as an output, the pull-up/pull-down input |
mbed_official | 15:a81a8d6c1dfe | 177 | * configuration setting is ignored. |
mbed_official | 15:a81a8d6c1dfe | 178 | * |
mbed_official | 15:a81a8d6c1dfe | 179 | * \param[in] port Base of the PORT module to configure |
mbed_official | 15:a81a8d6c1dfe | 180 | * \param[in] mask Mask of the port pin(s) to configure |
mbed_official | 15:a81a8d6c1dfe | 181 | * \param[in] config Configuration settings for the pin |
mbed_official | 15:a81a8d6c1dfe | 182 | */ |
mbed_official | 15:a81a8d6c1dfe | 183 | void system_pinmux_group_set_config( |
mbed_official | 15:a81a8d6c1dfe | 184 | PortGroup *const port, |
mbed_official | 15:a81a8d6c1dfe | 185 | const uint32_t mask, |
mbed_official | 15:a81a8d6c1dfe | 186 | const struct system_pinmux_config *const config) |
mbed_official | 15:a81a8d6c1dfe | 187 | { |
mbed_official | 15:a81a8d6c1dfe | 188 | Assert(port); |
mbed_official | 15:a81a8d6c1dfe | 189 | |
mbed_official | 15:a81a8d6c1dfe | 190 | for (int i = 0; i < 32; i++) { |
mbed_official | 15:a81a8d6c1dfe | 191 | if (mask & (1UL << i)) { |
mbed_official | 15:a81a8d6c1dfe | 192 | _system_pinmux_config(port, (1UL << i), config); |
mbed_official | 15:a81a8d6c1dfe | 193 | } |
mbed_official | 15:a81a8d6c1dfe | 194 | } |
mbed_official | 15:a81a8d6c1dfe | 195 | } |
mbed_official | 15:a81a8d6c1dfe | 196 | |
mbed_official | 15:a81a8d6c1dfe | 197 | /** |
mbed_official | 15:a81a8d6c1dfe | 198 | * \brief Configures the input sampling mode for a group of pins. |
mbed_official | 15:a81a8d6c1dfe | 199 | * |
mbed_official | 15:a81a8d6c1dfe | 200 | * Configures the input sampling mode for a group of pins, to |
mbed_official | 15:a81a8d6c1dfe | 201 | * control when the physical I/O pin value is sampled and |
mbed_official | 15:a81a8d6c1dfe | 202 | * stored inside the microcontroller. |
mbed_official | 15:a81a8d6c1dfe | 203 | * |
mbed_official | 15:a81a8d6c1dfe | 204 | * \param[in] port Base of the PORT module to configure |
mbed_official | 15:a81a8d6c1dfe | 205 | * \param[in] mask Mask of the port pin(s) to configure |
mbed_official | 15:a81a8d6c1dfe | 206 | * \param[in] mode New pin sampling mode to configure |
mbed_official | 15:a81a8d6c1dfe | 207 | */ |
mbed_official | 15:a81a8d6c1dfe | 208 | void system_pinmux_group_set_input_sample_mode( |
mbed_official | 15:a81a8d6c1dfe | 209 | PortGroup *const port, |
mbed_official | 15:a81a8d6c1dfe | 210 | const uint32_t mask, |
mbed_official | 15:a81a8d6c1dfe | 211 | const enum system_pinmux_pin_sample mode) |
mbed_official | 15:a81a8d6c1dfe | 212 | { |
mbed_official | 15:a81a8d6c1dfe | 213 | Assert(port); |
mbed_official | 15:a81a8d6c1dfe | 214 | |
mbed_official | 15:a81a8d6c1dfe | 215 | if (mode == SYSTEM_PINMUX_PIN_SAMPLE_ONDEMAND) { |
mbed_official | 15:a81a8d6c1dfe | 216 | port->CTRL.reg |= mask; |
mbed_official | 15:a81a8d6c1dfe | 217 | } else { |
mbed_official | 15:a81a8d6c1dfe | 218 | port->CTRL.reg &= ~mask; |
mbed_official | 15:a81a8d6c1dfe | 219 | } |
mbed_official | 15:a81a8d6c1dfe | 220 | } |
mbed_official | 15:a81a8d6c1dfe | 221 | |
mbed_official | 15:a81a8d6c1dfe | 222 | #ifdef FEATURE_SYSTEM_PINMUX_SLEWRATE_LIMITER |
mbed_official | 15:a81a8d6c1dfe | 223 | /** |
mbed_official | 15:a81a8d6c1dfe | 224 | * \brief Configures the output slew rate mode for a group of pins. |
mbed_official | 15:a81a8d6c1dfe | 225 | * |
mbed_official | 15:a81a8d6c1dfe | 226 | * Configures the output slew rate mode for a group of pins, to |
mbed_official | 15:a81a8d6c1dfe | 227 | * control the speed at which the physical output pin can react to |
mbed_official | 15:a81a8d6c1dfe | 228 | * logical changes of the I/O pin value. |
mbed_official | 15:a81a8d6c1dfe | 229 | * |
mbed_official | 15:a81a8d6c1dfe | 230 | * \param[in] port Base of the PORT module to configure |
mbed_official | 15:a81a8d6c1dfe | 231 | * \param[in] mask Mask of the port pin(s) to configure |
mbed_official | 15:a81a8d6c1dfe | 232 | * \param[in] mode New pin slew rate mode to configure |
mbed_official | 15:a81a8d6c1dfe | 233 | */ |
mbed_official | 15:a81a8d6c1dfe | 234 | void system_pinmux_group_set_output_slew_rate( |
mbed_official | 15:a81a8d6c1dfe | 235 | PortGroup *const port, |
mbed_official | 15:a81a8d6c1dfe | 236 | const uint32_t mask, |
mbed_official | 15:a81a8d6c1dfe | 237 | const enum system_pinmux_pin_slew_rate mode) |
mbed_official | 15:a81a8d6c1dfe | 238 | { |
mbed_official | 15:a81a8d6c1dfe | 239 | Assert(port); |
mbed_official | 15:a81a8d6c1dfe | 240 | |
mbed_official | 15:a81a8d6c1dfe | 241 | for (int i = 0; i < 32; i++) { |
mbed_official | 15:a81a8d6c1dfe | 242 | if (mask & (1UL << i)) { |
mbed_official | 15:a81a8d6c1dfe | 243 | if (mode == SYSTEM_PINMUX_PIN_SLEW_RATE_LIMITED) { |
mbed_official | 15:a81a8d6c1dfe | 244 | port->PINCFG[i].reg |= PORT_PINCFG_SLEWLIM; |
mbed_official | 15:a81a8d6c1dfe | 245 | } else { |
mbed_official | 15:a81a8d6c1dfe | 246 | port->PINCFG[i].reg &= ~PORT_PINCFG_SLEWLIM; |
mbed_official | 15:a81a8d6c1dfe | 247 | } |
mbed_official | 15:a81a8d6c1dfe | 248 | } |
mbed_official | 15:a81a8d6c1dfe | 249 | } |
mbed_official | 15:a81a8d6c1dfe | 250 | } |
mbed_official | 15:a81a8d6c1dfe | 251 | #endif |
mbed_official | 15:a81a8d6c1dfe | 252 | |
mbed_official | 15:a81a8d6c1dfe | 253 | #ifdef FEATURE_SYSTEM_PINMUX_DRIVE_STRENGTH |
mbed_official | 15:a81a8d6c1dfe | 254 | /** |
mbed_official | 15:a81a8d6c1dfe | 255 | * \brief Configures the output driver strength mode for a group of pins. |
mbed_official | 15:a81a8d6c1dfe | 256 | * |
mbed_official | 15:a81a8d6c1dfe | 257 | * Configures the output drive strength for a group of pins, to |
mbed_official | 15:a81a8d6c1dfe | 258 | * control the amount of current the pad is able to sink/source. |
mbed_official | 15:a81a8d6c1dfe | 259 | * |
mbed_official | 15:a81a8d6c1dfe | 260 | * \param[in] port Base of the PORT module to configure |
mbed_official | 15:a81a8d6c1dfe | 261 | * \param[in] mask Mask of the port pin(s) to configure |
mbed_official | 15:a81a8d6c1dfe | 262 | * \param[in] mode New output driver strength mode to configure |
mbed_official | 15:a81a8d6c1dfe | 263 | */ |
mbed_official | 15:a81a8d6c1dfe | 264 | void system_pinmux_group_set_output_strength( |
mbed_official | 15:a81a8d6c1dfe | 265 | PortGroup *const port, |
mbed_official | 15:a81a8d6c1dfe | 266 | const uint32_t mask, |
mbed_official | 15:a81a8d6c1dfe | 267 | const enum system_pinmux_pin_strength mode) |
mbed_official | 15:a81a8d6c1dfe | 268 | { |
mbed_official | 15:a81a8d6c1dfe | 269 | Assert(port); |
mbed_official | 15:a81a8d6c1dfe | 270 | |
mbed_official | 15:a81a8d6c1dfe | 271 | for (int i = 0; i < 32; i++) { |
mbed_official | 15:a81a8d6c1dfe | 272 | if (mask & (1UL << i)) { |
mbed_official | 15:a81a8d6c1dfe | 273 | if (mode == SYSTEM_PINMUX_PIN_STRENGTH_HIGH) { |
mbed_official | 15:a81a8d6c1dfe | 274 | port->PINCFG[i].reg |= PORT_PINCFG_DRVSTR; |
mbed_official | 15:a81a8d6c1dfe | 275 | } else { |
mbed_official | 15:a81a8d6c1dfe | 276 | port->PINCFG[i].reg &= ~PORT_PINCFG_DRVSTR; |
mbed_official | 15:a81a8d6c1dfe | 277 | } |
mbed_official | 15:a81a8d6c1dfe | 278 | } |
mbed_official | 15:a81a8d6c1dfe | 279 | } |
mbed_official | 15:a81a8d6c1dfe | 280 | } |
mbed_official | 15:a81a8d6c1dfe | 281 | #endif |
mbed_official | 15:a81a8d6c1dfe | 282 | |
mbed_official | 15:a81a8d6c1dfe | 283 | #ifdef FEATURE_SYSTEM_PINMUX_OPEN_DRAIN |
mbed_official | 15:a81a8d6c1dfe | 284 | /** |
mbed_official | 15:a81a8d6c1dfe | 285 | * \brief Configures the output driver mode for a group of pins. |
mbed_official | 15:a81a8d6c1dfe | 286 | * |
mbed_official | 15:a81a8d6c1dfe | 287 | * Configures the output driver mode for a group of pins, to |
mbed_official | 15:a81a8d6c1dfe | 288 | * control the pad behavior. |
mbed_official | 15:a81a8d6c1dfe | 289 | * |
mbed_official | 15:a81a8d6c1dfe | 290 | * \param[in] port Base of the PORT module to configure |
mbed_official | 15:a81a8d6c1dfe | 291 | * \param[in] mask Mask of the port pin(s) to configure |
mbed_official | 15:a81a8d6c1dfe | 292 | * \param[in] mode New pad output driver mode to configure |
mbed_official | 15:a81a8d6c1dfe | 293 | */ |
mbed_official | 15:a81a8d6c1dfe | 294 | void system_pinmux_group_set_output_drive( |
mbed_official | 15:a81a8d6c1dfe | 295 | PortGroup *const port, |
mbed_official | 15:a81a8d6c1dfe | 296 | const uint32_t mask, |
mbed_official | 15:a81a8d6c1dfe | 297 | const enum system_pinmux_pin_drive mode) |
mbed_official | 15:a81a8d6c1dfe | 298 | { |
mbed_official | 15:a81a8d6c1dfe | 299 | Assert(port); |
mbed_official | 15:a81a8d6c1dfe | 300 | |
mbed_official | 15:a81a8d6c1dfe | 301 | for (int i = 0; i < 32; i++) { |
mbed_official | 15:a81a8d6c1dfe | 302 | if (mask & (1UL << i)) { |
mbed_official | 15:a81a8d6c1dfe | 303 | if (mode == SYSTEM_PINMUX_PIN_DRIVE_OPEN_DRAIN) { |
mbed_official | 15:a81a8d6c1dfe | 304 | port->PINCFG[i].reg |= PORT_PINCFG_ODRAIN; |
mbed_official | 15:a81a8d6c1dfe | 305 | } else { |
mbed_official | 15:a81a8d6c1dfe | 306 | port->PINCFG[i].reg &= ~PORT_PINCFG_ODRAIN; |
mbed_official | 15:a81a8d6c1dfe | 307 | } |
mbed_official | 15:a81a8d6c1dfe | 308 | } |
mbed_official | 15:a81a8d6c1dfe | 309 | } |
mbed_official | 15:a81a8d6c1dfe | 310 | } |
mbed_official | 15:a81a8d6c1dfe | 311 | #endif |