Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit 8f6e1b4

Browse files
committed
Merge pull request #214 from cw2/issue-213-stm32f4disco-ports-usage
Removed not broken-out GPIO ports (used only A - E)
2 parents 5a8a2cc + 39a4c2f commit 8f6e1b4

File tree

2 files changed

+6
-50
lines changed

2 files changed

+6
-50
lines changed

Solutions/STM32F4DISCOVERY/DeviceCode/Init/IO_Init.cpp

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,62 +11,20 @@
1111
//
1212
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1313

14-
#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(0[x]))
15-
1614
#include <tinyhal.h>
1715
#include "..\..\..\..\DeviceCode\Targets\Native\STM32F4\DeviceCode\stm32f4xx.h"
1816

1917
extern void STM32F4_GPIO_Pin_Config( GPIO_PIN pin, UINT32 mode, GPIO_RESISTOR resistor, UINT32 alternate ); // Workaround, since CPU_GPIO_DisablePin() does not correctly initialize pin speeds
2018

2119
void __section("SectionForBootstrapOperations") BootstrapCode_GPIO()
2220
{
23-
//#ifdef DEBUG
24-
// // PE2,3,4,5 are used for TRACECLK and TRACEDATA0-3 so don't enable them as address pins in debug builds
25-
// // This limits external FLASH and SRAM to 1MB addressable space each.
26-
// const uint8_t PortE_PinList[] = {0, 1, /*2, 3, 4, 5,*/ 7, 8, 9, 10, 11, 12, 13, 14, 15};
27-
//#else
28-
// const uint8_t PortE_PinList[] = {0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15};
29-
//#endif
30-
// const uint8_t PortF_PinList[] = {0, 1, 2, 3, 4, 5, 12, 13, 14, 15};
31-
// const uint8_t PortG_PinList[] = {0, 1, 2, 3, 4, 5, 10};
32-
//
33-
// const uint32_t pinConfig = 0x3C2; // Speed 100Mhz, AF12 FSMC, Alternate Mode
34-
// const uint32_t pinMode = pinConfig & 0xF;
35-
// const GPIO_ALT_MODE alternateMode = (GPIO_ALT_MODE) pinConfig;
36-
// const GPIO_RESISTOR resistorConfig = RESISTOR_PULLUP;
37-
//
38-
// uint32_t i;
39-
40-
/* Enable GPIO clocks */
21+
// Enable GPIO clocks for ports A - E
4122
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN | RCC_AHB1ENR_GPIOBEN | RCC_AHB1ENR_GPIOCEN
42-
| RCC_AHB1ENR_GPIODEN | RCC_AHB1ENR_GPIOEEN | RCC_AHB1ENR_GPIOFEN
43-
| RCC_AHB1ENR_GPIOGEN | RCC_AHB1ENR_GPIOHEN | RCC_AHB1ENR_GPIOIEN;
23+
| RCC_AHB1ENR_GPIODEN | RCC_AHB1ENR_GPIOEEN;
4424

25+
// TODO: Restore at the end of bootloader?
4526
CPU_GPIO_EnableOutputPin(LED3, FALSE);
4627
CPU_GPIO_EnableOutputPin(LED4, FALSE);
4728
CPU_GPIO_EnableOutputPin(LED5, FALSE);
4829
CPU_GPIO_EnableOutputPin(LED6, FALSE);
49-
50-
/*Initialize SRAM and NOR GPIOs */
51-
52-
//for(i = 0; i < ARRAY_LENGTH(PortE_PinList); i++) /* Port E */
53-
//{
54-
// CPU_GPIO_ReservePin( PORT_PIN(GPIO_PORTE, PortE_PinList[i]), TRUE);
55-
// CPU_GPIO_DisablePin( PORT_PIN(GPIO_PORTE, PortE_PinList[i]), resistorConfig, 0, alternateMode);
56-
// STM32F4_GPIO_Pin_Config( PORT_PIN(GPIO_PORTE, PortE_PinList[i]), pinMode, resistorConfig, pinConfig ); // Workaround, since CPU_GPIO_DisablePin() does not correctly initialize pin speeds
57-
//}
58-
//
59-
//for(i = 0; i < ARRAY_LENGTH(PortF_PinList); i++) /* Port F */
60-
//{
61-
// CPU_GPIO_ReservePin( PORT_PIN(GPIO_PORTF, PortF_PinList[i]), TRUE);
62-
// CPU_GPIO_DisablePin( PORT_PIN(GPIO_PORTF, PortF_PinList[i]), resistorConfig, 0, alternateMode);
63-
// STM32F4_GPIO_Pin_Config( PORT_PIN(GPIO_PORTF, PortF_PinList[i]), pinMode, resistorConfig, pinConfig ); // Workaround, since CPU_GPIO_DisablePin() does not correctly initialize pin speeds
64-
//}
65-
//
66-
//for(i = 0; i < ARRAY_LENGTH(PortG_PinList); i++) /* Port G */
67-
//{
68-
// CPU_GPIO_ReservePin( PORT_PIN(GPIO_PORTG, PortG_PinList[i]), TRUE);
69-
// CPU_GPIO_DisablePin( PORT_PIN(GPIO_PORTG, PortG_PinList[i]), resistorConfig, 0, alternateMode);
70-
// STM32F4_GPIO_Pin_Config( PORT_PIN(GPIO_PORTG, PortG_PinList[i]), pinMode, resistorConfig, pinConfig ); // Workaround, since CPU_GPIO_DisablePin() does not correctly initialize pin speeds
71-
//}
7230
}

Solutions/STM32F4DISCOVERY/platform_selector.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@
4444
#define GPIO_PORTC 2
4545
#define GPIO_PORTD 3
4646
#define GPIO_PORTE 4
47-
#define GPIO_PORTF 5
48-
#define GPIO_PORTG 6
49-
#define GPIO_PORTH 7
50-
#define GPIO_PORTI 8
47+
// The remaining ports are not broken out - except PH0 and PH1,
48+
// which are deliberately omitted to keep the range continuous.
5149

5250
#define PORT_PIN(port,pin) ( ( (int)port) * 16 + ( pin ) )
5351

@@ -77,7 +75,7 @@
7775
#define CTSPROTECTRESISTOR RESISTOR_DISABLED
7876
#define RTSPROTECTRESISTOR RESISTOR_DISABLED
7977

80-
#define TOTAL_GPIO_PORT 9 // PA - PI
78+
#define TOTAL_GPIO_PORT (GPIO_PORTE + 1)
8179
#define TOTAL_GPIO_PINS (TOTAL_GPIO_PORT*16)
8280

8381
#define INSTRUMENTATION_H_GPIO_PIN GPIO_PIN_NONE

0 commit comments

Comments
 (0)