Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 9 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
| 5 | * @brief GPIO LL module driver. |
5 | * @brief GPIO LL module driver. |
| 6 | ****************************************************************************** |
6 | ****************************************************************************** |
| 7 | * @attention |
7 | * @attention |
| 8 | * |
8 | * |
| 9 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
| - | 10 | * All rights reserved.</center></h2> |
|
| 10 | * |
11 | * |
| 11 | * Redistribution and use in source and binary forms, with or without modification, |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
| 12 | * are permitted provided that the following conditions are met: |
13 | * the "License"; You may not use this file except in compliance with the |
| 13 | * 1. Redistributions of source code must retain the above copyright notice, |
- | |
| 14 | * this list of conditions and the following disclaimer. |
- | |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
- | |
| 16 | * this list of conditions and the following disclaimer in the documentation |
- | |
| 17 | * and/or other materials provided with the distribution. |
14 | * License. You may obtain a copy of the License at: |
| 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
- | |
| 19 | * may be used to endorse or promote products derived from this software |
15 | * opensource.org/licenses/BSD-3-Clause |
| 20 | * without specific prior written permission. |
- | |
| 21 | * |
- | |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
- | |
| 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
- | |
| 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
- | |
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
- | |
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
- | |
| 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
- | |
| 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
- | |
| 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- | |
| 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- | |
| 32 | * |
16 | * |
| 33 | ****************************************************************************** |
17 | ****************************************************************************** |
| 34 | */ |
18 | */ |
| - | 19 | ||
| 35 | #if defined(USE_FULL_LL_DRIVER) |
20 | #if defined(USE_FULL_LL_DRIVER) |
| 36 | 21 | ||
| 37 | /* Includes ------------------------------------------------------------------*/ |
22 | /* Includes ------------------------------------------------------------------*/ |
| 38 | #include "stm32f1xx_ll_gpio.h" |
23 | #include "stm32f1xx_ll_gpio.h" |
| 39 | #include "stm32f1xx_ll_bus.h" |
24 | #include "stm32f1xx_ll_bus.h" |
| Line 59... | Line 44... | ||
| 59 | /* Private macros ------------------------------------------------------------*/ |
44 | /* Private macros ------------------------------------------------------------*/ |
| 60 | /** @addtogroup GPIO_LL_Private_Macros |
45 | /** @addtogroup GPIO_LL_Private_Macros |
| 61 | * @{ |
46 | * @{ |
| 62 | */ |
47 | */ |
| 63 | 48 | ||
| 64 | #define IS_LL_GPIO_PIN(__VALUE__) ((((__VALUE__) & LL_GPIO_PIN_ALL)!= 0U) &&\ |
49 | #define IS_LL_GPIO_PIN(__VALUE__) ((((__VALUE__) & LL_GPIO_PIN_ALL)!= 0u) &&\ |
| 65 | (((__VALUE__) & (~LL_GPIO_PIN_ALL))== 0U)) |
50 | (((__VALUE__) & (~LL_GPIO_PIN_ALL))== 0u)) |
| 66 | 51 | ||
| 67 | #define IS_LL_GPIO_MODE(__VALUE__) (((__VALUE__) == LL_GPIO_MODE_ANALOG) ||\ |
52 | #define IS_LL_GPIO_MODE(__VALUE__) (((__VALUE__) == LL_GPIO_MODE_ANALOG) ||\ |
| 68 | ((__VALUE__) == LL_GPIO_MODE_FLOATING) ||\ |
53 | ((__VALUE__) == LL_GPIO_MODE_FLOATING) ||\ |
| 69 | ((__VALUE__) == LL_GPIO_MODE_INPUT) ||\ |
54 | ((__VALUE__) == LL_GPIO_MODE_INPUT) ||\ |
| 70 | ((__VALUE__) == LL_GPIO_MODE_OUTPUT) ||\ |
55 | ((__VALUE__) == LL_GPIO_MODE_OUTPUT) ||\ |
| Line 183... | Line 168... | ||
| 183 | 168 | ||
| 184 | pinmask = ((GPIO_InitStruct->Pin) << GPIO_PIN_MASK_POS) >> GPIO_PIN_NB; |
169 | pinmask = ((GPIO_InitStruct->Pin) << GPIO_PIN_MASK_POS) >> GPIO_PIN_NB; |
| 185 | pinpos = POSITION_VAL(pinmask); |
170 | pinpos = POSITION_VAL(pinmask); |
| 186 | 171 | ||
| 187 | /* Configure the port pins */ |
172 | /* Configure the port pins */ |
| 188 | while ((pinmask >> pinpos) != 0U) |
173 | while ((pinmask >> pinpos) != 0u) |
| 189 | { |
174 | { |
| 190 | /* skip if bit is not set */ |
175 | /* skip if bit is not set */ |
| 191 | if ((pinmask & (1U << pinpos)) != 0U) |
176 | if ((pinmask & (1u << pinpos)) != 0u) |
| 192 | { |
177 | { |
| 193 | /* Get current io position */ |
178 | /* Get current io position */ |
| 194 | if (pinpos < GPIO_PIN_MASK_POS) |
179 | if (pinpos < GPIO_PIN_MASK_POS) |
| 195 | { |
180 | { |
| 196 | currentpin = (0x00000101U << pinpos); |
181 | currentpin = (0x00000101uL << pinpos); |
| 197 | } |
182 | } |
| 198 | else |
183 | else |
| 199 | { |
184 | { |
| 200 | currentpin = ((0x00010001U << (pinpos - GPIO_PIN_MASK_POS)) | 0x04000000U); |
185 | currentpin = ((0x00010001u << (pinpos - GPIO_PIN_MASK_POS)) | 0x04000000u); |
| 201 | } |
186 | } |
| 202 | 187 | ||
| 203 | /* Check Pin Mode and Pin Pull parameters */ |
188 | /* Check Pin Mode and Pin Pull parameters */ |
| 204 | assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode)); |
189 | assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode)); |
| 205 | assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull)); |
190 | assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull)); |
| 206 | 191 | ||
| 207 | /* Pin Mode configuration */ |
- | |
| 208 | LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode); |
- | |
| 209 | - | ||
| 210 | /* Pull-up Pull-down resistor configuration*/ |
192 | /* Pull-up Pull-down resistor configuration*/ |
| 211 | LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull); |
193 | LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull); |
| 212 | 194 | ||
| - | 195 | /* Pin Mode configuration */ |
|
| - | 196 | LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode); |
|
| - | 197 | ||
| 213 | if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)) |
198 | if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)) |
| 214 | { |
199 | { |
| 215 | /* Check speed and Output mode parameters */ |
200 | /* Check speed and Output mode parameters */ |
| 216 | assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed)); |
201 | assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed)); |
| 217 | assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType)); |
202 | assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType)); |