Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pinmap.c
- Revision:
- 340:28d1f895c6fe
- Parent:
- 285:31249416b6f9
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pinmap.c Mon Oct 06 11:45:07 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F030R8/pinmap.c Thu Oct 09 08:15:07 2014 +0100
@@ -32,32 +32,49 @@
#include "PortNames.h"
#include "mbed_error.h"
+// GPIO mode look-up table
+static const uint32_t gpio_mode[13] = {
+ 0x00000000, // 0 = GPIO_MODE_INPUT
+ 0x00000001, // 1 = GPIO_MODE_OUTPUT_PP
+ 0x00000011, // 2 = GPIO_MODE_OUTPUT_OD
+ 0x00000002, // 3 = GPIO_MODE_AF_PP
+ 0x00000012, // 4 = GPIO_MODE_AF_OD
+ 0x00000003, // 5 = GPIO_MODE_ANALOG
+ 0x10110000, // 6 = GPIO_MODE_IT_RISING
+ 0x10210000, // 7 = GPIO_MODE_IT_FALLING
+ 0x10310000, // 8 = GPIO_MODE_IT_RISING_FALLING
+ 0x10120000, // 9 = GPIO_MODE_EVT_RISING
+ 0x10220000, // 10 = GPIO_MODE_EVT_FALLING
+ 0x10320000, // 11 = GPIO_MODE_EVT_RISING_FALLING
+ 0x10000000 // 12 = Reset IT and EVT (not in STM32Cube HAL)
+};
+
// Enable GPIO clock and return GPIO base address
uint32_t Set_GPIO_Clock(uint32_t port_idx) {
uint32_t gpio_add = 0;
switch (port_idx) {
case PortA:
gpio_add = GPIOA_BASE;
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
+ __GPIOA_CLK_ENABLE();
break;
case PortB:
gpio_add = GPIOB_BASE;
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
+ __GPIOB_CLK_ENABLE();
break;
case PortC:
gpio_add = GPIOC_BASE;
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
+ __GPIOC_CLK_ENABLE();
break;
case PortD:
gpio_add = GPIOD_BASE;
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);
+ __GPIOD_CLK_ENABLE();
break;
case PortF:
gpio_add = GPIOF_BASE;
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);
+ __GPIOF_CLK_ENABLE();
break;
default:
- error("Port number is not correct.");
+ error("Pinmap error: wrong port number.");
break;
}
return gpio_add;
@@ -71,7 +88,6 @@
// Get the pin informations
uint32_t mode = STM_PIN_MODE(data);
- uint32_t otype = STM_PIN_OTYPE(data);
uint32_t pupd = STM_PIN_PUPD(data);
uint32_t afnum = STM_PIN_AFNUM(data);
@@ -82,30 +98,20 @@
uint32_t gpio_add = Set_GPIO_Clock(port_index);
GPIO_TypeDef *gpio = (GPIO_TypeDef *)gpio_add;
- // Configure Alternate Function
- // Warning: Must be done before the GPIO is initialized
- if (afnum != 0xFF) {
- GPIO_PinAFConfig(gpio, (uint16_t)pin_index, afnum);
- }
-
// Configure GPIO
GPIO_InitTypeDef GPIO_InitStructure;
- GPIO_InitStructure.GPIO_Pin = (uint16_t)(1 << pin_index);
- GPIO_InitStructure.GPIO_Mode = (GPIOMode_TypeDef)mode;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;
- GPIO_InitStructure.GPIO_OType = (GPIOOType_TypeDef)otype;
- GPIO_InitStructure.GPIO_PuPd = (GPIOPuPd_TypeDef)pupd;
- GPIO_Init(gpio, &GPIO_InitStructure);
+ GPIO_InitStructure.Pin = (uint32_t)(1 << pin_index);
+ GPIO_InitStructure.Mode = gpio_mode[mode];
+ GPIO_InitStructure.Pull = pupd;
+ GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
+ GPIO_InitStructure.Alternate = afnum;
+ HAL_GPIO_Init(gpio, &GPIO_InitStructure);
- // *** TODO ***
- // Disconnect JTAG-DP + SW-DP signals.
- // Warning: Need to reconnect under reset
+ // [TODO] Disconnect SWDIO and SWCLK signals ?
+ // Warning: For debugging it is necessary to reconnect under reset if this is done.
//if ((pin == PA_13) || (pin == PA_14)) {
//
//}
- //if ((pin == PA_15) || (pin == PB_3) || (pin == PB_4)) {
- //
- //}
}
/**
