|
11 | 11 | // |
12 | 12 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
13 | 13 |
|
14 | | -#define ARRAY_LENGTH(x) (sizeof(x)/sizeof(0[x])) |
15 | | - |
16 | 14 | #include <tinyhal.h> |
17 | 15 | #include "..\..\..\..\DeviceCode\Targets\Native\STM32F4\DeviceCode\stm32f4xx.h" |
18 | 16 |
|
19 | 17 | 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 |
20 | 18 |
|
21 | 19 | void __section("SectionForBootstrapOperations") BootstrapCode_GPIO() |
22 | 20 | { |
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 |
41 | 22 | 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; |
44 | 24 |
|
| 25 | + // TODO: Restore at the end of bootloader? |
45 | 26 | CPU_GPIO_EnableOutputPin(LED3, FALSE); |
46 | 27 | CPU_GPIO_EnableOutputPin(LED4, FALSE); |
47 | 28 | CPU_GPIO_EnableOutputPin(LED5, FALSE); |
48 | 29 | 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 | | - //} |
72 | 30 | } |
0 commit comments