test
targets/TARGET_STM/TARGET_STM32L0/pin_device.h@1:8a094db1347f, 2020-11-09 (annotated)
- Committer:
- elijahsj
- Date:
- Mon Nov 09 00:02:47 2020 -0500
- Revision:
- 1:8a094db1347f
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elijahsj | 1:8a094db1347f | 1 | /* mbed Microcontroller Library |
elijahsj | 1:8a094db1347f | 2 | ******************************************************************************* |
elijahsj | 1:8a094db1347f | 3 | * Copyright (c) 2016, STMicroelectronics |
elijahsj | 1:8a094db1347f | 4 | * All rights reserved. |
elijahsj | 1:8a094db1347f | 5 | * |
elijahsj | 1:8a094db1347f | 6 | * Redistribution and use in source and binary forms, with or without |
elijahsj | 1:8a094db1347f | 7 | * modification, are permitted provided that the following conditions are met: |
elijahsj | 1:8a094db1347f | 8 | * |
elijahsj | 1:8a094db1347f | 9 | * 1. Redistributions of source code must retain the above copyright notice, |
elijahsj | 1:8a094db1347f | 10 | * this list of conditions and the following disclaimer. |
elijahsj | 1:8a094db1347f | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
elijahsj | 1:8a094db1347f | 12 | * this list of conditions and the following disclaimer in the documentation |
elijahsj | 1:8a094db1347f | 13 | * and/or other materials provided with the distribution. |
elijahsj | 1:8a094db1347f | 14 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
elijahsj | 1:8a094db1347f | 15 | * may be used to endorse or promote products derived from this software |
elijahsj | 1:8a094db1347f | 16 | * without specific prior written permission. |
elijahsj | 1:8a094db1347f | 17 | * |
elijahsj | 1:8a094db1347f | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
elijahsj | 1:8a094db1347f | 19 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
elijahsj | 1:8a094db1347f | 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
elijahsj | 1:8a094db1347f | 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
elijahsj | 1:8a094db1347f | 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
elijahsj | 1:8a094db1347f | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
elijahsj | 1:8a094db1347f | 24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
elijahsj | 1:8a094db1347f | 25 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
elijahsj | 1:8a094db1347f | 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
elijahsj | 1:8a094db1347f | 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
elijahsj | 1:8a094db1347f | 28 | ******************************************************************************* |
elijahsj | 1:8a094db1347f | 29 | */ |
elijahsj | 1:8a094db1347f | 30 | #ifndef MBED_PIN_DEVICE_H |
elijahsj | 1:8a094db1347f | 31 | #define MBED_PIN_DEVICE_H |
elijahsj | 1:8a094db1347f | 32 | |
elijahsj | 1:8a094db1347f | 33 | #include "cmsis.h" |
elijahsj | 1:8a094db1347f | 34 | #include "stm32l0xx_ll_gpio.h" |
elijahsj | 1:8a094db1347f | 35 | |
elijahsj | 1:8a094db1347f | 36 | extern const uint32_t ll_pin_defines[16]; |
elijahsj | 1:8a094db1347f | 37 | |
elijahsj | 1:8a094db1347f | 38 | /* Family specific implementations */ |
elijahsj | 1:8a094db1347f | 39 | static inline void stm_pin_DisconnectDebug(PinName pin) |
elijahsj | 1:8a094db1347f | 40 | { |
elijahsj | 1:8a094db1347f | 41 | /* empty for now */ |
elijahsj | 1:8a094db1347f | 42 | } |
elijahsj | 1:8a094db1347f | 43 | |
elijahsj | 1:8a094db1347f | 44 | static inline void stm_pin_PullConfig(GPIO_TypeDef *gpio, uint32_t ll_pin, uint32_t pull_config) |
elijahsj | 1:8a094db1347f | 45 | { |
elijahsj | 1:8a094db1347f | 46 | switch (pull_config) { |
elijahsj | 1:8a094db1347f | 47 | case GPIO_PULLUP: |
elijahsj | 1:8a094db1347f | 48 | LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_UP); |
elijahsj | 1:8a094db1347f | 49 | break; |
elijahsj | 1:8a094db1347f | 50 | case GPIO_PULLDOWN: |
elijahsj | 1:8a094db1347f | 51 | LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_DOWN); |
elijahsj | 1:8a094db1347f | 52 | break; |
elijahsj | 1:8a094db1347f | 53 | default: |
elijahsj | 1:8a094db1347f | 54 | LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_NO); |
elijahsj | 1:8a094db1347f | 55 | break; |
elijahsj | 1:8a094db1347f | 56 | } |
elijahsj | 1:8a094db1347f | 57 | } |
elijahsj | 1:8a094db1347f | 58 | |
elijahsj | 1:8a094db1347f | 59 | static inline void stm_pin_SetAFPin( GPIO_TypeDef *gpio, PinName pin, uint32_t afnum) |
elijahsj | 1:8a094db1347f | 60 | { |
elijahsj | 1:8a094db1347f | 61 | uint32_t ll_pin = ll_pin_defines[STM_PIN(pin)]; |
elijahsj | 1:8a094db1347f | 62 | |
elijahsj | 1:8a094db1347f | 63 | if (STM_PIN(pin) > 7) |
elijahsj | 1:8a094db1347f | 64 | LL_GPIO_SetAFPin_8_15(gpio, ll_pin, afnum); |
elijahsj | 1:8a094db1347f | 65 | else |
elijahsj | 1:8a094db1347f | 66 | LL_GPIO_SetAFPin_0_7(gpio, ll_pin, afnum); |
elijahsj | 1:8a094db1347f | 67 | } |
elijahsj | 1:8a094db1347f | 68 | |
elijahsj | 1:8a094db1347f | 69 | #endif |