diff --git a/cores/arduino/pins_arduino.c b/cores/arduino/pins_arduino.c index cebc377375..47e4dfa42f 100644 --- a/cores/arduino/pins_arduino.c +++ b/cores/arduino/pins_arduino.c @@ -24,7 +24,7 @@ extern "C" { WEAK uint32_t pinNametoDigitalPin(PinName p) { - uint32_t i = NC; + uint32_t i = NUM_DIGITAL_PINS; if(STM_VALID_PINNAME(p)) { for(i = 0; i < NUM_DIGITAL_PINS; i++) { if (digitalPin[i] == p) diff --git a/cores/arduino/pins_arduino.h b/cores/arduino/pins_arduino.h index b13b9c36e0..de0d05965e 100644 --- a/cores/arduino/pins_arduino.h +++ b/cores/arduino/pins_arduino.h @@ -232,7 +232,7 @@ uint32_t pinNametoDigitalPin(PinName p); #define digitalPinToPort(p) (get_GPIO_Port(STM_PORT(digitalPinToPinName(p)))) #define digitalPinToBitMask(p) (STM_GPIO_PIN(digitalPinToPinName(p))) -#define analogInPinToBit(p) (STM_PIN(digitalPinToPinName(p))) +#define analogInPinToBit(p) (STM_GPIO_PIN(digitalPinToPinName(p))) #define portOutputRegister(P) (&(P->ODR)) #define portInputRegister(P) (&(P->IDR)) diff --git a/cores/arduino/stm32/PinConfigured.h b/cores/arduino/stm32/PinConfigured.h index 7b7d393049..5675a86486 100644 --- a/cores/arduino/stm32/PinConfigured.h +++ b/cores/arduino/stm32/PinConfigured.h @@ -44,10 +44,12 @@ extern "C" { #define PINCONF_VAL(X, Y) ((Y >> PINCONF_SHIFT(X)) & PINCONF_MASK) - -bool is_pin_configured(PinName pin, uint32_t* map); -void set_pin_configured(PinName pin, uint32_t* map); -void reset_pin_configured(PinName pin, uint32_t* map); +#define is_pin_configured(pin, map) \ + (PINCONF_VAL(pin, map[PINCONF_INDEX(pin)])) +#define set_pin_configured(pin, map) \ + (map[PINCONF_INDEX(pin)] = map[PINCONF_INDEX(pin)] | PINCONF_BIT(pin)) +#define reset_pin_configured(pin, map) \ + (map[PINCONF_INDEX(pin)] = map[PINCONF_INDEX(pin)] & (~PINCONF_BIT(pin))) #ifdef __cplusplus } diff --git a/cores/arduino/stm32/PinNamesTypes.h b/cores/arduino/stm32/PinNamesTypes.h index 6095cb3014..2f3672e02c 100644 --- a/cores/arduino/stm32/PinNamesTypes.h +++ b/cores/arduino/stm32/PinNamesTypes.h @@ -36,7 +36,7 @@ extern "C" { /* STM PIN data as used in pin_function is coded on 32 bits as below * [2:0] Function (like in MODER reg) : Input / Output / Alt / Analog * [3] Output Push-Pull / Open Drain (as in OTYPER reg) - * [5:4] as in PUPDR reg: No Pull, Pull-up, Pull-Donc + * [5:4] as in PUPDR reg: No Pull, Pull-up, Pull-Down * [7:6] Reserved for speed config (as in OSPEEDR), but not used yet * [14:8] Alternate Num (as in AFRL/AFRG reg) * [19:15] Channel (Analog/Timer specific) @@ -135,25 +135,6 @@ typedef enum { #define STM_VALID_PINNAME(X) (STM_PORT(X) <= LastPort) #define STM_GPIO_PIN(X) ((uint16_t)(1<Instance == ADC1) { @@ -440,19 +428,8 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) __HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_SYSCLK); #endif - /* Enable GPIO clock ****************************************/ - port = set_GPIO_Port_Clock(STM_PORT(g_current_pin)); - - /*##-2- Configure peripheral GPIO ##########################################*/ - /* ADC Channel GPIO pin configuration */ - GPIO_InitStruct.Pin = STM_GPIO_PIN(g_current_pin); -#ifdef GPIO_MODE_ANALOG_ADC_CONTROL - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL; -#else - GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; -#endif - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(port, &GPIO_InitStruct); + /* Configure ADC GPIO pin */ + pinmap_pinout(g_current_pin, PinMap_ADC); } /** @@ -682,29 +659,12 @@ uint16_t adc_read_value(PinName pin) */ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim) { - GPIO_InitTypeDef GPIO_InitStruct; - GPIO_TypeDef *port; - uint32_t function = pinmap_function(g_current_pin, PinMap_PWM); /*##-1- Enable peripherals and GPIO Clocks #################################*/ /* TIMx Peripheral clock enable */ timer_enable_clock(htim); - /* Enable GPIO Channels Clock */ - /* Enable GPIO clock ****************************************/ - port = set_GPIO_Port_Clock(STM_PORT(g_current_pin)); - - /* Common configuration for all channels */ - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; -#ifdef STM32F1xx - pin_SetF1AFPin(STM_PIN_AFNUM(function)); -#else - GPIO_InitStruct.Alternate = STM_PIN_AFNUM(function); -#endif /* STM32F1xx */ - GPIO_InitStruct.Pin = STM_GPIO_PIN(g_current_pin); - - HAL_GPIO_Init(port, &GPIO_InitStruct); + /* Configure PWM GPIO pins */ + pinmap_pinout(g_current_pin, PinMap_PWM); } /** diff --git a/cores/arduino/stm32/digital_io.c b/cores/arduino/stm32/digital_io.c deleted file mode 100644 index 3824947999..0000000000 --- a/cores/arduino/stm32/digital_io.c +++ /dev/null @@ -1,101 +0,0 @@ -/** - ****************************************************************************** - * @file digital_io.c - * @author WI6LABS - * @version V1.0.0 - * @date 01-August-2016 - * @brief Provide an interface to configure hw ios - * - ****************************************************************************** - * @attention - * - *

© COPYRIGHT(c) 2016 STMicroelectronics

- * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************** - */ -#include "digital_io.h" -#include "stm32_def.h" -#include "hw_config.h" -#include "PinAF_STM32F1.h" - -#ifdef __cplusplus - extern "C" { -#endif - -/** - * @brief This function initialize the IO - * @param port : one of the gpio port - * @param pin : one of the gpio pin - * @param mode : one of the gpio mode (cf hal_gpio.h) - * @param pull : one of the pullup/down mode (cf hal_gpio.h) - * @retval None - */ -void digital_io_init(PinName pin, uint32_t mode, uint32_t pull) -{ - GPIO_InitTypeDef GPIO_InitStructure; - GPIO_TypeDef *port = set_GPIO_Port_Clock(STM_PORT(pin)); - GPIO_InitStructure.Pin = STM_GPIO_PIN(pin); - GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; - GPIO_InitStructure.Mode = mode; - GPIO_InitStructure.Pull = pull; -#ifdef STM32F1xx - pinF1_DisconnectDebug(pin); -#endif /* STM32F1xx */ - HAL_GPIO_Init(port, &GPIO_InitStructure); -} - -/** - * @brief This function set a value to an IO - * @param port : one of the gpio port - * @param pin : one of the gpio pin - * @param val : 0 to set to low, any other value to set to high - * @retval None - */ -void digital_io_write(GPIO_TypeDef *port, uint32_t pin, uint32_t val) -{ - if(val) { - HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET); - } else { - HAL_GPIO_WritePin(port, pin, GPIO_PIN_RESET); - } -} - - -/** - * @brief This function set a value to an IO - * @param port : one of the gpio port - * @param pin : one of the gpio pin - * @retval The pin state (LOW or HIGH) - */ -uint32_t digital_io_read(GPIO_TypeDef *port, uint32_t pin) -{ - return (uint32_t)HAL_GPIO_ReadPin(port, pin); -} - -#ifdef __cplusplus -} -#endif - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/cores/arduino/stm32/digital_io.h b/cores/arduino/stm32/digital_io.h index 941f3c7c73..b5d8dd347e 100644 --- a/cores/arduino/stm32/digital_io.h +++ b/cores/arduino/stm32/digital_io.h @@ -1,9 +1,6 @@ /** ****************************************************************************** * @file digital_io.h - * @author WI6LABS - * @version V1.0.0 - * @date 01-August-2016 * @brief Header for digital_io module ****************************************************************************** * @attention @@ -40,20 +37,87 @@ #define __DIGITAL_IO_H /* Includes ------------------------------------------------------------------*/ -#include "stm32_def.h" -#include "PeripheralPins.h" +#include "wiring_constants.h" +#include "PinNames.h" +#include "pinmap.h" +#include "stm32yyxx_ll_gpio.h" #ifdef __cplusplus - extern "C" { +extern "C" { #endif -/* Exported types ------------------------------------------------------------*/ -/* Exported constants --------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ -void digital_io_init(PinName pin, uint32_t mode, uint32_t pull); -void digital_io_write(GPIO_TypeDef *port, uint32_t pin, uint32_t val); -uint32_t digital_io_read(GPIO_TypeDef *port, uint32_t pin); +/** + * @brief This function set a value to an IO + * @param port : one of the gpio port + * @param pin : one of the gpio pin + * @param val : 0 to set to low, any other value to set to high + * @retval None + */ +static inline void digital_io_write(GPIO_TypeDef *port, uint32_t pin, uint32_t val) +{ + if (val) { + LL_GPIO_SetOutputPin(port, pin); + } else { + LL_GPIO_ResetOutputPin(port, pin); + } +} + +/** + * @brief This function read the value of an IO + * @param port : one of the gpio port + * @param pin : one of the gpio pin + * @retval The pin state (LOW or HIGH) + */ +static inline uint32_t digital_io_read(GPIO_TypeDef *port, uint32_t pin) +{ + return LL_GPIO_IsInputPinSet(port, pin); +} + +/** + * @brief This function toggle value of an IO + * @param port : one of the gpio port + * @param pin : one of the gpio pin + * @retval None + */ +static inline void digital_io_toggle(GPIO_TypeDef *port, uint32_t pin) +{ + LL_GPIO_TogglePin(port, pin); +} + +/** + * @brief This function set a value to an IO + * @param pn : Pin name + * @param val : 0 to set to low, any other value to set to high + * @retval None + */ +static inline void digitalWriteFast(PinName pn, uint32_t ulVal) +{ + digital_io_write(get_GPIO_Port(STM_PORT(pn)), STM_LL_GPIO_PIN(pn), ulVal); +} + +/** + * @brief This function read the value of an IO + * @param pn : Pin name + * @retval The pin state (LOW or HIGH) + */ +static inline int digitalReadFast(PinName pn) +{ + uint8_t level = 0; + level = digital_io_read(get_GPIO_Port(STM_PORT(pn)), STM_LL_GPIO_PIN(pn)); + return (level) ? HIGH : LOW; +} + +/** + * @brief This function toggle value of an IO + * @param port : one of the gpio port + * @param pin : one of the gpio pin + * @retval None + */ +static inline void digitalToggleFast(PinName pn) +{ + digital_io_toggle(get_GPIO_Port(STM_PORT(pn)), STM_LL_GPIO_PIN(pn)); +} #ifdef __cplusplus } diff --git a/cores/arduino/stm32/PinConfigured.c b/cores/arduino/stm32/pinconfig.h similarity index 50% rename from cores/arduino/stm32/PinConfigured.c rename to cores/arduino/stm32/pinconfig.h index 024219c512..4db6bf971e 100644 --- a/cores/arduino/stm32/PinConfigured.c +++ b/cores/arduino/stm32/pinconfig.h @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (c) 2017, STMicroelectronics + * Copyright (c) 2018, STMicroelectronics * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,21 +26,74 @@ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************************************************************* + * Based on mbed-os/target/TARGET_STM/TARGET_STMYY/pin_device.h */ -#include "PinConfigured.h" +#ifndef _PINCONFIG_H +#define _PINCONFIG_H -bool is_pin_configured(PinName pin, uint32_t* map) { - uint32_t index = PINCONF_INDEX(pin); - return PINCONF_VAL(pin, map[index]); +#include "PinAF_STM32F1.h" +#include "stm32yyxx_ll_gpio.h" + +static inline void pin_DisconnectDebug(PinName pin) +{ +#ifdef STM32F1xx + pinF1_DisconnectDebug(pin); +#else + UNUSED(pin); +#endif /* STM32F1xx */ } -void set_pin_configured(PinName pin, uint32_t* map) { - uint32_t index = PINCONF_INDEX(pin); - map[index] = map[index] | PINCONF_BIT(pin); +static inline void pin_PullConfig(GPIO_TypeDef *gpio, uint32_t ll_pin, uint32_t pull_config) +{ +#ifdef STM32F1xx + uint32_t function = LL_GPIO_GetPinMode(gpio, ll_pin); +#endif + + switch (pull_config) { + case GPIO_PULLUP: +#ifdef STM32F1xx + if (function == LL_GPIO_MODE_FLOATING) { + LL_GPIO_SetPinMode(gpio, ll_pin, LL_GPIO_MODE_INPUT); + } +#endif + LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_UP); + break; + case GPIO_PULLDOWN: +#ifdef STM32F1xx + if (function == LL_GPIO_MODE_FLOATING) { + LL_GPIO_SetPinMode(gpio, ll_pin, LL_GPIO_MODE_INPUT); + } +#endif + LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_DOWN); + break; + default: +#ifdef STM32F1xx + /* Input+NoPull = Floating for F1 family */ + if (function == LL_GPIO_MODE_INPUT) { + LL_GPIO_SetPinMode(gpio, ll_pin, LL_GPIO_MODE_FLOATING); + } +#else + LL_GPIO_SetPinPull(gpio, ll_pin, LL_GPIO_PULL_NO); +#endif + break; + } } -void reset_pin_configured(PinName pin, uint32_t* map) { - uint32_t index = PINCONF_INDEX(pin); - map[index] = map[index] & (~PINCONF_BIT(pin)); +static inline void pin_SetAFPin(GPIO_TypeDef *gpio, PinName pin, uint32_t afnum) +{ +#ifdef STM32F1xx + UNUSED(gpio); + UNUSED(pin); + pin_SetF1AFPin(afnum); +#else + uint32_t ll_pin = STM_LL_GPIO_PIN(pin); + + if (STM_PIN(pin) > 7) { + LL_GPIO_SetAFPin_8_15(gpio, ll_pin, afnum); + } else { + LL_GPIO_SetAFPin_0_7(gpio, ll_pin, afnum); + } +#endif } +#endif diff --git a/cores/arduino/stm32/pinmap.c b/cores/arduino/stm32/pinmap.c index abcd381ef9..499fa9a5b1 100644 --- a/cores/arduino/stm32/pinmap.c +++ b/cores/arduino/stm32/pinmap.c @@ -14,98 +14,217 @@ * limitations under the License. */ //Based on mbed-os/hal/mbed_pinmap_common.c - #include "pinmap.h" +#include "pinconfig.h" +#include "stm32yyxx_ll_gpio.h" + +/* Map STM_PIN to LL */ +const uint32_t pin_map_ll[16] = { + LL_GPIO_PIN_0, + LL_GPIO_PIN_1, + LL_GPIO_PIN_2, + LL_GPIO_PIN_3, + LL_GPIO_PIN_4, + LL_GPIO_PIN_5, + LL_GPIO_PIN_6, + LL_GPIO_PIN_7, + LL_GPIO_PIN_8, + LL_GPIO_PIN_9, + LL_GPIO_PIN_10, + LL_GPIO_PIN_11, + LL_GPIO_PIN_12, + LL_GPIO_PIN_13, + LL_GPIO_PIN_14, + LL_GPIO_PIN_15 +}; + +bool pin_in_pinmap(PinName pin, const PinMap *map) +{ + if (pin != (PinName)NC) { + while (map->pin != NC) { + if (map->pin == pin) { + return true; + } + map++; + } + } + return false; +} + +/** + * Configure pin (mode, speed, output type and pull-up/pull-down) + */ +void pin_function(PinName pin, int function) +{ + /* Get the pin informations */ + uint32_t mode = STM_PIN_FUNCTION(function); + uint32_t afnum = STM_PIN_AFNUM(function); + uint32_t port = STM_PORT(pin); + uint32_t ll_pin = STM_LL_GPIO_PIN(pin); + uint32_t ll_mode = 0; + + if (pin == (PinName)NC) { + Error_Handler(); + } + + /* Enable GPIO clock */ + GPIO_TypeDef *gpio = set_GPIO_Port_Clock(port); + + /* Set default speed to high. + * For most families there are dedicated registers so it is + * not so important, register can be set at any time. + * But for families like F1, speed only applies to output. + */ +#if defined (STM32F1xx) + if (mode == STM_PIN_OUTPUT) { +#endif +#ifdef LL_GPIO_SPEED_FREQ_VERY_HIGH + LL_GPIO_SetPinSpeed(gpio, ll_pin, LL_GPIO_SPEED_FREQ_VERY_HIGH); +#else + LL_GPIO_SetPinSpeed(gpio, ll_pin, LL_GPIO_SPEED_FREQ_HIGH); +#endif +#if defined (STM32F1xx) + } +#endif + + switch (mode) { + case STM_PIN_INPUT: + ll_mode = LL_GPIO_MODE_INPUT; + break; + case STM_PIN_OUTPUT: + ll_mode = LL_GPIO_MODE_OUTPUT; + break; + case STM_PIN_ALTERNATE: + ll_mode = LL_GPIO_MODE_ALTERNATE; + /* In case of ALT function, also set the afnum */ + pin_SetAFPin(gpio, pin, afnum); + break; + case STM_PIN_ANALOG: + ll_mode = LL_GPIO_MODE_ANALOG; + break; + default: + Error_Handler(); + break; + } + LL_GPIO_SetPinMode(gpio, ll_pin, ll_mode); + +#if defined(GPIO_ASCR_ASC0) + /* For families where Analog Control ASC0 register is present */ + if (STM_PIN_ANALOG_CONTROL(function)) { + LL_GPIO_EnablePinAnalogControl(gpio, ll_pin); + } else { + LL_GPIO_DisablePinAnalogControl(gpio, ll_pin); + } +#endif + + if ((mode == STM_PIN_OUTPUT) || (mode == STM_PIN_ALTERNATE)) { + if (STM_PIN_OD(function)) { + LL_GPIO_SetPinOutputType(gpio, ll_pin, LL_GPIO_OUTPUT_OPENDRAIN); + } else { + LL_GPIO_SetPinOutputType(gpio, ll_pin, LL_GPIO_OUTPUT_PUSHPULL); + } + } + + pin_PullConfig(gpio, ll_pin, STM_PIN_PUPD(function)); -void* pinmap_find_peripheral(PinName pin, const PinMap* map) { + pin_DisconnectDebug(pin); +} + +void pinmap_pinout(PinName pin, const PinMap *map) +{ + if (pin == NC) { + return; + } + + while (map->pin != NC) { + if (map->pin == pin) { + pin_function(pin, map->function); + return; + } + map++; + } + Error_Handler(); +} + +void *pinmap_find_peripheral(PinName pin, const PinMap *map) +{ while (map->pin != NC) { - if (map->pin == pin) + if (map->pin == pin) { return map->peripheral; + } map++; } return NP; } -void* pinmap_peripheral(PinName pin, const PinMap* map) { - void* peripheral = NP; +void *pinmap_peripheral(PinName pin, const PinMap *map) +{ + void *peripheral = NP; if (pin != (PinName)NC) { peripheral = pinmap_find_peripheral(pin, map); } - // else error("pinmap not found for peripheral"); return peripheral; } -PinName pinmap_find_pin(void* peripheral, const PinMap* map) { +PinName pinmap_find_pin(void *peripheral, const PinMap *map) +{ while (map->peripheral != NP) { - if (map->peripheral == peripheral) + if (map->peripheral == peripheral) { return map->pin; + } map++; } return NC; } -PinName pinmap_pin(void* peripheral, const PinMap* map) { +PinName pinmap_pin(void *peripheral, const PinMap *map) +{ PinName pin = NC; if (peripheral != NP) { pin = pinmap_find_pin(peripheral, map); } - // else error("pinmap not found for pin"); return pin; } -uint32_t pinmap_find_function(PinName pin, const PinMap* map) { +uint32_t pinmap_find_function(PinName pin, const PinMap *map) +{ while (map->pin != NC) { - if (map->pin == pin) + if (map->pin == pin) { return map->function; + } map++; } return (uint32_t)NC; } -uint32_t pinmap_function(PinName pin, const PinMap* map) { +uint32_t pinmap_function(PinName pin, const PinMap *map) +{ uint32_t function = (uint32_t)NC; if (pin != (PinName)NC) { function = pinmap_find_function(pin, map); } - // else error("pinmap not found for function"); return function; } -bool pin_in_pinmap(PinName pin, const PinMap* map) { - if (pin != (PinName)NC) { - while (map->pin != NC) { - if (map->pin == pin) - return true; - map++; - } - } - return false; -} - // Merge peripherals -void* pinmap_merge_peripheral(void* a, void* b) { - // both are the same (inc both NP) - if (a == b) - return a; - - // one (or both) is not set - if (a == NP) - return b; - if (b == NP) - return a; - - // mis-match error case - // error("pinmap mis-match"); - return NP; -} +void *pinmap_merge_peripheral(void *a, void *b) +{ + // both are the same (inc both NP) + if (a == b) { + return a; + } -PinName pin_pinName(const PinMap* map) { - if(map->pin != (PinName)NC) { - return map->pin; - } else { - return (PinName)NC; + // one (or both) is not set + if (a == NP) { + return b; } + if (b == NP) { + return a; + } + + // mis-match error case + return NP; } diff --git a/cores/arduino/stm32/pinmap.h b/cores/arduino/stm32/pinmap.h index 857b9c3461..ed464ee277 100644 --- a/cores/arduino/stm32/pinmap.h +++ b/cores/arduino/stm32/pinmap.h @@ -27,27 +27,35 @@ extern "C" { #endif +extern const uint32_t pin_map_ll[16]; + +#define STM_LL_GPIO_PIN(X) (pin_map_ll[STM_PIN(X)]) + // No peripheral #define NP 0U typedef struct { - PinName pin; - void* peripheral; - int function; + PinName pin; + void *peripheral; + int function; } PinMap; -bool pin_in_pinmap(PinName pin, const PinMap* map); +bool pin_in_pinmap(PinName pin, const PinMap *map); void pin_function(PinName pin, int function); -PinName pin_pinName(const PinMap* map); +static inline PinName pin_pinName(const PinMap *map) +{ + return map->pin; +} -void* pinmap_find_peripheral(PinName pin, const PinMap* map); -void* pinmap_peripheral(PinName pin, const PinMap* map); -PinName pinmap_find_pin(void* peripheral, const PinMap* map); -PinName pinmap_pin(void* peripheral, const PinMap* map); -uint32_t pinmap_find_function(PinName pin, const PinMap* map); -uint32_t pinmap_function(PinName pin, const PinMap* map); -void* pinmap_merge_peripheral(void* a, void* b); +void pinmap_pinout(PinName pin, const PinMap *map); +void *pinmap_find_peripheral(PinName pin, const PinMap *map); +void *pinmap_peripheral(PinName pin, const PinMap *map); +PinName pinmap_find_pin(void *peripheral, const PinMap *map); +PinName pinmap_pin(void *peripheral, const PinMap *map); +uint32_t pinmap_find_function(PinName pin, const PinMap *map); +uint32_t pinmap_function(PinName pin, const PinMap *map); +void *pinmap_merge_peripheral(void *a, void *b); #ifdef __cplusplus } diff --git a/cores/arduino/stm32/spi_com.c b/cores/arduino/stm32/spi_com.c index 9a5f41521f..d37e8458b9 100644 --- a/cores/arduino/stm32/spi_com.c +++ b/cores/arduino/stm32/spi_com.c @@ -50,6 +50,7 @@ #include "stm32_def.h" #include "spi_com.h" #include "PinAF_STM32F1.h" +#include "pinconfig.h" #ifdef __cplusplus extern "C" { @@ -192,9 +193,8 @@ void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb) return; SPI_HandleTypeDef *handle = &(obj->handle); - GPIO_InitTypeDef GPIO_InitStruct; - GPIO_TypeDef *port; uint32_t spi_freq = 0; + uint32_t pull = 0; // Determine the SPI to use SPI_TypeDef *spi_mosi = pinmap_peripheral(obj->pin_mosi, PinMap_SPI_MOSI); @@ -280,69 +280,17 @@ void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb) handle->Init.NSSPMode = SPI_NSS_PULSE_DISABLE; #endif - if(obj->pin_mosi != NC) { - port = set_GPIO_Port_Clock(STM_PORT(obj->pin_mosi)); - GPIO_InitStruct.Pin = STM_GPIO_PIN(obj->pin_mosi); - GPIO_InitStruct.Mode = STM_PIN_MODE(pinmap_function(obj->pin_mosi,PinMap_SPI_MOSI)); - GPIO_InitStruct.Pull = STM_PIN_PUPD(pinmap_function(obj->pin_mosi,PinMap_SPI_MOSI)); - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; -#ifdef STM32F1xx - pin_SetF1AFPin(STM_PIN_AFNUM(pinmap_function(obj->pin_mosi,PinMap_SPI_MOSI))); -#else - GPIO_InitStruct.Alternate = STM_PIN_AFNUM(pinmap_function(obj->pin_mosi,PinMap_SPI_MOSI)); -#endif /* STM32F1xx */ - HAL_GPIO_Init(port, &GPIO_InitStruct); - } - - if(obj->pin_miso != NC) { - port = set_GPIO_Port_Clock(STM_PORT(obj->pin_miso)); - GPIO_InitStruct.Pin = STM_GPIO_PIN(obj->pin_miso); - GPIO_InitStruct.Mode = STM_PIN_MODE(pinmap_function(obj->pin_miso,PinMap_SPI_MISO)); - GPIO_InitStruct.Pull = STM_PIN_PUPD(pinmap_function(obj->pin_miso,PinMap_SPI_MISO)); - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; -#ifdef STM32F1xx - pin_SetF1AFPin(STM_PIN_AFNUM(pinmap_function(obj->pin_miso,PinMap_SPI_MISO))); -#else - GPIO_InitStruct.Alternate = STM_PIN_AFNUM(pinmap_function(obj->pin_miso,PinMap_SPI_MISO)); -#endif /* STM32F1xx */ - HAL_GPIO_Init(port, &GPIO_InitStruct); - } - - if(obj->pin_sclk != NC) { - port = set_GPIO_Port_Clock(STM_PORT(obj->pin_sclk)); - GPIO_InitStruct.Pin = STM_GPIO_PIN(obj->pin_sclk); - GPIO_InitStruct.Mode = STM_PIN_MODE(pinmap_function(obj->pin_sclk,PinMap_SPI_SCLK)); - /* - * According the STM32 Datasheet for SPI peripheral we need to PULLDOWN - * or PULLUP the SCK pin according the polarity used. - */ - if(handle->Init.CLKPolarity == SPI_POLARITY_LOW) { - GPIO_InitStruct.Pull = GPIO_PULLDOWN; - } else { - GPIO_InitStruct.Pull = GPIO_PULLUP; - } - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; -#ifdef STM32F1xx - pin_SetF1AFPin(STM_PIN_AFNUM(pinmap_function(obj->pin_sclk,PinMap_SPI_SCLK))); -#else - GPIO_InitStruct.Alternate = STM_PIN_AFNUM(pinmap_function(obj->pin_sclk,PinMap_SPI_SCLK)); -#endif /* STM32F1xx */ - HAL_GPIO_Init(port, &GPIO_InitStruct); - } - - if(obj->pin_ssel != NC) { - port = set_GPIO_Port_Clock(STM_PORT(obj->pin_ssel)); - GPIO_InitStruct.Pin = STM_GPIO_PIN(obj->pin_ssel); - GPIO_InitStruct.Mode = STM_PIN_MODE(pinmap_function(obj->pin_ssel,PinMap_SPI_SSEL)); - GPIO_InitStruct.Pull = STM_PIN_PUPD(pinmap_function(obj->pin_ssel,PinMap_SPI_SSEL)); - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; -#ifdef STM32F1xx - pin_SetF1AFPin(STM_PIN_AFNUM(pinmap_function(obj->pin_ssel,PinMap_SPI_SSEL))); -#else - GPIO_InitStruct.Alternate = STM_PIN_AFNUM(pinmap_function(obj->pin_ssel,PinMap_SPI_SSEL)); -#endif /* STM32F1xx */ - HAL_GPIO_Init(port, &GPIO_InitStruct); - } + /* Configure SPI GPIO pins */ + pinmap_pinout(obj->pin_mosi, PinMap_SPI_MOSI); + pinmap_pinout(obj->pin_miso, PinMap_SPI_MISO); + pinmap_pinout(obj->pin_sclk, PinMap_SPI_SCLK); + /* + * According the STM32 Datasheet for SPI peripheral we need to PULLDOWN + * or PULLUP the SCK pin according the polarity used. + */ + pull = (handle->Init.CLKPolarity == SPI_POLARITY_LOW) ? GPIO_PULLDOWN: GPIO_PULLUP; + pin_PullConfig(get_GPIO_Port(STM_PORT(obj->pin_sclk)), STM_LL_GPIO_PIN(obj->pin_sclk), pull); + pinmap_pinout(obj->pin_ssel, PinMap_SPI_SSEL); #if defined SPI1_BASE // Enable SPI clock diff --git a/cores/arduino/stm32/timer.c b/cores/arduino/stm32/timer.c index 6905b5846a..76e9e3b5f1 100644 --- a/cores/arduino/stm32/timer.c +++ b/cores/arduino/stm32/timer.c @@ -924,7 +924,7 @@ void TimerPinInit(stimer_t *obj, uint32_t frequency, uint32_t duration) obj->pinInfo.count = -1; } - digital_io_init(obj->pin, GPIO_MODE_OUTPUT_PP, GPIO_NOPULL); + pin_function(obj->pin, STM_PIN_DATA(STM_MODE_OUTPUT_PP, GPIO_NOPULL, 0)); timClkFreq = getTimerClkFreq(obj->timer); // Do this once @@ -957,7 +957,7 @@ void TimerPinInit(stimer_t *obj, uint32_t frequency, uint32_t duration) void TimerPinDeinit(stimer_t *obj) { TimerHandleDeinit(obj); - digital_io_init(obj->pin, GPIO_MODE_INPUT, GPIO_NOPULL); + pin_function(obj->pin, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); } /** diff --git a/cores/arduino/stm32/twi.c b/cores/arduino/stm32/twi.c index 44c8e9fc34..8061ce2c3e 100644 --- a/cores/arduino/stm32/twi.c +++ b/cores/arduino/stm32/twi.c @@ -157,8 +157,6 @@ void i2c_custom_init(i2c_t *obj, i2c_timing_e timing, uint32_t addressingMode, u if(obj == NULL) return; - GPIO_InitTypeDef GPIO_InitStruct; - GPIO_TypeDef *port; I2C_HandleTypeDef *handle = &(obj->handle); // Determine the I2C to use @@ -232,31 +230,9 @@ void i2c_custom_init(i2c_t *obj, i2c_timing_e timing, uint32_t addressingMode, u } #endif // I2C4_BASE - //SCL - port = set_GPIO_Port_Clock(STM_PORT(obj->scl)); - GPIO_InitStruct.Pin = STM_GPIO_PIN(obj->scl); - GPIO_InitStruct.Mode = STM_PIN_MODE(pinmap_function(obj->scl,PinMap_I2C_SCL)); - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.Pull = STM_PIN_PUPD(pinmap_function(obj->scl,PinMap_I2C_SCL)); -#ifdef STM32F1xx - pin_SetF1AFPin(STM_PIN_AFNUM(pinmap_function(obj->scl,PinMap_I2C_SCL))); -#else - GPIO_InitStruct.Alternate = STM_PIN_AFNUM(pinmap_function(obj->scl,PinMap_I2C_SCL)); -#endif /* STM32F1xx */ - HAL_GPIO_Init(port, &GPIO_InitStruct); - - //SDA - port = set_GPIO_Port_Clock(STM_PORT(obj->sda)); - GPIO_InitStruct.Pin = STM_GPIO_PIN(obj->sda); - GPIO_InitStruct.Mode = STM_PIN_MODE(pinmap_function(obj->sda,PinMap_I2C_SDA)); - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; - GPIO_InitStruct.Pull = STM_PIN_PUPD(pinmap_function(obj->sda,PinMap_I2C_SDA)); -#ifdef STM32F1xx - pin_SetF1AFPin(STM_PIN_AFNUM(pinmap_function(obj->sda,PinMap_I2C_SDA))); -#else - GPIO_InitStruct.Alternate = STM_PIN_AFNUM(pinmap_function(obj->sda,PinMap_I2C_SDA)); -#endif /* STM32F1xx */ - HAL_GPIO_Init(port, &GPIO_InitStruct); + /* Configure I2C GPIO pins */ + pinmap_pinout(obj->scl, PinMap_I2C_SCL); + pinmap_pinout(obj->sda, PinMap_I2C_SDA); handle->Instance = obj->i2c; #if defined (STM32F0xx) || defined (STM32F3xx) || defined (STM32F7xx) ||\ diff --git a/cores/arduino/stm32/uart.c b/cores/arduino/stm32/uart.c index 81401788f7..ef74671161 100644 --- a/cores/arduino/stm32/uart.c +++ b/cores/arduino/stm32/uart.c @@ -92,9 +92,6 @@ void uart_init(serial_t *obj) } UART_HandleTypeDef *huart = &(obj->handle); - GPIO_InitTypeDef GPIO_InitStruct; - GPIO_TypeDef *port; - uint32_t function = (uint32_t)NC; /* Determine the U(S)ART peripheral to use (USART1, USART2, ...) */ USART_TypeDef *uart_tx = pinmap_peripheral(obj->pin_tx, PinMap_UART_TX); @@ -260,37 +257,9 @@ void uart_init(serial_t *obj) __HAL_RCC_SYSCFG_CLK_ENABLE(); #endif - /* Configure GPIOs */ - /* RX */ - port = set_GPIO_Port_Clock(STM_PORT(obj->pin_rx)); - function = pinmap_function(obj->pin_rx, PinMap_UART_RX); - GPIO_InitStruct.Pin = STM_GPIO_PIN(obj->pin_rx); - GPIO_InitStruct.Mode = STM_PIN_MODE(function); - GPIO_InitStruct.Pull = STM_PIN_PUPD(function); - /* Common */ -#ifdef STM32F1xx - pin_SetF1AFPin(STM_PIN_AFNUM(function)); -#else - GPIO_InitStruct.Alternate = STM_PIN_AFNUM(function); -#endif /* STM32F1xx */ -#ifdef GPIO_SPEED_FREQ_VERY_HIGH - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; -#else - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; -#endif - HAL_GPIO_Init(port, &GPIO_InitStruct); - - /* TX */ - port = set_GPIO_Port_Clock(STM_PORT(obj->pin_tx)); - function = pinmap_function(obj->pin_tx, PinMap_UART_TX); - GPIO_InitStruct.Pin = STM_GPIO_PIN(obj->pin_tx); - GPIO_InitStruct.Mode = STM_PIN_MODE(function); - GPIO_InitStruct.Pull = STM_PIN_PUPD(function); -#ifndef STM32F1xx - GPIO_InitStruct.Alternate = STM_PIN_AFNUM(function); -#endif /* STM32F1xx */ - HAL_GPIO_Init(port, &GPIO_InitStruct); - + /* Configure UART GPIO pins */ + pinmap_pinout(obj->pin_tx, PinMap_UART_TX); + pinmap_pinout(obj->pin_rx, PinMap_UART_RX); /* Configure uart */ uart_handlers[obj->index] = huart; diff --git a/cores/arduino/wiring_constants.h b/cores/arduino/wiring_constants.h index 312cabde28..98d6484bb1 100644 --- a/cores/arduino/wiring_constants.h +++ b/cores/arduino/wiring_constants.h @@ -20,12 +20,14 @@ #define _WIRING_CONSTANTS_ #include +#include #ifdef __cplusplus #include using std::min; using std::max; #else // C +#include #ifndef abs #define abs(x) ((x)>0?(x):-(x)) #endif // abs @@ -40,13 +42,15 @@ using std::max; #endif // __cplusplus -#define HIGH 0x1 -#define LOW 0x0 - -#define INPUT 0x0 -#define OUTPUT 0x1 -#define INPUT_PULLUP 0x2 -#define INPUT_PULLDOWN 0x3 +/* Official Arduino */ +#define INPUT 0x0 +#define OUTPUT 0x1 +#define INPUT_PULLUP 0x2 +/* STM32 extension */ +#define INPUT_FLOATING INPUT +#define INPUT_PULLDOWN 0x3 +#define INPUT_ANALOG 0x4 +#define OUTPUT_OPEN_DRAIN 0x5 #define PI 3.1415926535897932384626433832795 #define HALF_PI 1.5707963267948966192313216916398 @@ -63,11 +67,11 @@ enum BitOrder { MSBFIRST = 1 }; -// LOW 0 -// HIGH 1 -#define CHANGE 2 -#define FALLING 3 -#define RISING 4 +#define LOW 0x0 +#define HIGH 0x1 +#define CHANGE 0x2 +#define FALLING 0x3 +#define RISING 0x4 #define DEFAULT 1 #define EXTERNAL 0 diff --git a/cores/arduino/wiring_digital.c b/cores/arduino/wiring_digital.c index 6619299d2b..6af48eef5a 100644 --- a/cores/arduino/wiring_digital.c +++ b/cores/arduino/wiring_digital.c @@ -20,7 +20,7 @@ #include "PinConfigured.h" #ifdef __cplusplus - extern "C" { +extern "C" { #endif @@ -29,65 +29,64 @@ uint32_t g_digPinConfigured[MAX_NB_PORT] = {0}; extern uint32_t g_anOutputPinConfigured[MAX_NB_PORT]; -void pinMode( uint32_t ulPin, uint32_t ulMode ) +void pinMode(uint32_t ulPin, uint32_t ulMode) { PinName p = digitalPinToPinName(ulPin); - if(p != NC) { + if (p != NC) { // If the pin that support PWM or DAC output, we need to turn it off - if(is_pin_configured(p, g_anOutputPinConfigured)) { + if (is_pin_configured(p, g_anOutputPinConfigured)) { #ifdef HAL_DAC_MODULE_ENABLED - if(pin_in_pinmap(p, PinMap_DAC)) { + if (pin_in_pinmap(p, PinMap_DAC)) { dac_stop(p); } else #endif //HAL_DAC_MODULE_ENABLED - if(pin_in_pinmap(p, PinMap_PWM)) { - pwm_stop(p); - } + if (pin_in_pinmap(p, PinMap_PWM)) { + pwm_stop(p); + } reset_pin_configured(p, g_anOutputPinConfigured); } - switch ( ulMode ) - { - case INPUT: - digital_io_init(p, GPIO_MODE_INPUT, GPIO_NOPULL); - break; + switch (ulMode) { + case INPUT: /* INPUT_FLOATING */ + pin_function(p, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)); + break; case INPUT_PULLUP: - digital_io_init(p, GPIO_MODE_INPUT, GPIO_PULLUP); - break; + pin_function(p, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, 0)); + break; case INPUT_PULLDOWN: - digital_io_init(p, GPIO_MODE_INPUT, GPIO_PULLDOWN); - break; + pin_function(p, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLDOWN, 0)); + break; + case INPUT_ANALOG: + pin_function(p, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)); + break; case OUTPUT: - digital_io_init(p, GPIO_MODE_OUTPUT_PP, GPIO_NOPULL); - break; + pin_function(p, STM_PIN_DATA(STM_MODE_OUTPUT_PP, GPIO_NOPULL, 0)); + break; + case OUTPUT_OPEN_DRAIN: + pin_function(p, STM_PIN_DATA(STM_MODE_OUTPUT_OD, GPIO_NOPULL, 0)); + break; default: - break; + Error_Handler(); + break; } set_pin_configured(p, g_digPinConfigured); } } -void digitalWrite( uint32_t ulPin, uint32_t ulVal ) +void digitalWrite(uint32_t ulPin, uint32_t ulVal) { - PinName p = digitalPinToPinName(ulPin); - if(p != NC) { - if(is_pin_configured(p, g_digPinConfigured)) { - digital_io_write(get_GPIO_Port(STM_PORT(p)), STM_GPIO_PIN(p), ulVal); - } - } + digitalWriteFast(digitalPinToPinName(ulPin), ulVal); } -int digitalRead( uint32_t ulPin ) +int digitalRead(uint32_t ulPin) { - uint8_t level = 0; - PinName p = digitalPinToPinName(ulPin); - if(p != NC) { - if(is_pin_configured(p, g_digPinConfigured)) { - level = digital_io_read(get_GPIO_Port(STM_PORT(p)), STM_GPIO_PIN(p)); - } - } - return (level)? HIGH : LOW; + return digitalReadFast(digitalPinToPinName(ulPin)); +} + +void digitalToggle(uint32_t ulPin) +{ + digitalToggleFast(digitalPinToPinName(ulPin)); } #ifdef __cplusplus diff --git a/cores/arduino/wiring_digital.h b/cores/arduino/wiring_digital.h index 3b69cf834d..a8f4a0a6de 100644 --- a/cores/arduino/wiring_digital.h +++ b/cores/arduino/wiring_digital.h @@ -20,38 +20,27 @@ #define _WIRING_DIGITAL_ #ifdef __cplusplus - extern "C" { +extern "C" { #endif /** - * \brief Configures the specified pin to behave either as an input or an output. See the description of digital pins for details. + * \brief Configures the specified pin to behave either as an input or an output. * - * \param ulPin The number of the pin whose mode you wish to set - * \param ulMode Either INPUT or OUTPUT + * \param dwPin The number of the pin whose mode you wish to set + * \param dwMode Either INPUT, INPUT_PULLUP, INPUT_PULLDOWN or OUTPUT */ -extern void pinMode( uint32_t dwPin, uint32_t dwMode ) ; +extern void pinMode(uint32_t dwPin, uint32_t dwMode) ; /** * \brief Write a HIGH or a LOW value to a digital pin. * * If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the - * corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW. - * - * If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal - * 20K pullup resistor (see the tutorial on digital pins). Writing LOW will disable the pullup. The pullup - * resistor is enough to light an LED dimly, so if LEDs appear to work, but very dimly, this is a likely - * cause. The remedy is to set the pin to an output with the pinMode() function. - * - * \note Digital pin PIN_LED is harder to use as a digital input than the other digital pins because it has an LED - * and resistor attached to it that's soldered to the board on most boards. If you enable its internal 20k pull-up - * resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor - * pull the voltage level down, meaning it always returns LOW. If you must use pin PIN_LED as a digital input, use an - * external pull down resistor. + * corresponding value: 3.3V for HIGH, 0V (ground) for LOW. * * \param dwPin the pin number * \param dwVal HIGH or LOW */ -extern void digitalWrite( uint32_t dwPin, uint32_t dwVal ) ; +extern void digitalWrite(uint32_t dwPin, uint32_t dwVal) ; /** * \brief Reads the value from a specified digital pin, either HIGH or LOW. @@ -60,7 +49,14 @@ extern void digitalWrite( uint32_t dwPin, uint32_t dwVal ) ; * * \return HIGH or LOW */ -extern int digitalRead( uint32_t ulPin ) ; +extern int digitalRead(uint32_t ulPin) ; + +/** + * \brief Toggle the value from a specified digital pin. + * + * \param ulPin The number of the digital pin you want to toggle (int) + */ +extern void digitalToggle(uint32_t ulPin) ; #ifdef __cplusplus } diff --git a/keywords.txt b/keywords.txt index 13b979ebea..2a71fbcebe 100644 --- a/keywords.txt +++ b/keywords.txt @@ -350,6 +350,10 @@ portConfigRegister KEYWORD2 digitalPinIsValid KEYWORD2 digitalPinFirstOccurence KEYWORD2 pinIsSerial KEYWORD2 +digitalReadFast KEYWORD2 +digitalWriteFast KEYWORD2 +digitalToggle KEYWORD2 +digitalToggleFast KEYWORD2 # Pin number PA0 LITERAL1 diff --git a/variants/DISCO_L475VG_IOT/PeripheralPins.c b/variants/DISCO_L475VG_IOT/PeripheralPins.c index 79f36fbee1..528956c189 100644 --- a/variants/DISCO_L475VG_IOT/PeripheralPins.c +++ b/variants/DISCO_L475VG_IOT/PeripheralPins.c @@ -40,42 +40,42 @@ #ifdef HAL_ADC_MODULE_ENABLED const PinMap PinMap_ADC[] = { - {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 - D1/UART4_TX -// {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 - D1/UART4_TX - {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 - D0/UART4_RX -// {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 - D0/UART4_RX - {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - D10/PWM -// {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 - D10/PWM - {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - D4 -// {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 - D4 - {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 - D7 -// {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 - D7 - {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - D13/SPI1_SCK/LED1 -// {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 - D13/SPI1_SCK/LED1 - {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 - D12/SPI_MISO -// {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 - D12/SPI_MISO - {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 - D11/SPI1_MOSI/PWM -// {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 - D11/SPI1_MOSI/PWM - {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 - D3/PWM -// {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 - D3/PWM - {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC1_IN16 - D6/PWM -// {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC2_IN16 - D6/PWM - {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 - A5 -// {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 - A5 -// {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 - A5 - {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 - A2 -// {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 - A2 -// {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 - A2 - {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 - A3 -// {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 - A3 -// {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 - A3 - {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - A2 -// {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 - A2 -// {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 - A2 - {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 - A1 -// {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 - A1 - {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 - A0 -// {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 - A0 + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 - D1/UART4_TX +// {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 - D1/UART4_TX + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 - D0/UART4_RX +// {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 - D0/UART4_RX + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - D10/PWM +// {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 - D10/PWM + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - D4 +// {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 - D4 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 - D7 +// {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 - D7 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - D13/SPI1_SCK/LED1 +// {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 - D13/SPI1_SCK/LED1 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 - D12/SPI_MISO +// {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 - D12/SPI_MISO + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 - D11/SPI1_MOSI/PWM +// {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 - D11/SPI1_MOSI/PWM + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 - D3/PWM +// {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 - D3/PWM + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 16, 0)}, // ADC1_IN16 - D6/PWM +// {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 16, 0)}, // ADC2_IN16 - D6/PWM + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 - A5 +// {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 - A5 +// {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 - A5 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 - A2 +// {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 - A2 +// {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 - A2 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 - A3 +// {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 - A3 +// {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 - A3 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 - A2 +// {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 - A2 +// {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 - A2 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 - A1 +// {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 - A1 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 - A0 +// {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 - A0 {NC, NP, 0} }; #endif diff --git a/variants/NUCLEO_L476RG/PeripheralPins.c b/variants/NUCLEO_L476RG/PeripheralPins.c index 4a65ada245..9c8a760a50 100644 --- a/variants/NUCLEO_L476RG/PeripheralPins.c +++ b/variants/NUCLEO_L476RG/PeripheralPins.c @@ -40,42 +40,42 @@ #ifdef HAL_ADC_MODULE_ENABLED const PinMap PinMap_ADC[] = { - {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 -// {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 - {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 -// {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 -// {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - STLink Tx -// {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 - STLink Tx -// {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - STLink Rx -// {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 - STLink Rx - {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 -// {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 -// {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - LED -// {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 - {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 -// {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 - {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 -// {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 - {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 -// {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 -// {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC1_IN16 -// {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC2_IN16 - {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 -// {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 -// {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 - {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 -// {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 -// {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 - {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 -// {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 -// {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 - {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 -// {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 -// {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 - {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 -// {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 - {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 -// {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 +// {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 +// {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 +// {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 - STLink Tx +// {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 - STLink Tx +// {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 - STLink Rx +// {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 - STLink Rx + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 +// {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 +// {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 - LED +// {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 +// {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 +// {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 +// {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 +// {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 16, 0)}, // ADC1_IN16 +// {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 16, 0)}, // ADC2_IN16 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 +// {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 +// {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 +// {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 +// {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 +// {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 +// {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 +// {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 +// {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 +// {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 +// {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG_ADC_CONTROL, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 {NC, NP, 0} }; #endif