aboutsummaryrefslogtreecommitdiff
path: root/src/platforms/f4discovery/platform.c
diff options
context:
space:
mode:
authorUwe Bonnes2013-04-15 16:21:58 +0200
committerGareth McMullin2013-04-23 12:14:18 -0700
commitad151fdca83aa2ea4dfd4f77a27507c9fc53f5d6 (patch)
tree93b096be2adb8c1298f7381eaad53c34776108b8 /src/platforms/f4discovery/platform.c
parent6659d87e9b2daa98b468d9f2648daf37d04bbf4d (diff)
F4 Discovery: - Unconditionally use the System Bootloader - Use PC2/4/5/6 Pins for JTAG/SWD to avoid collision with eventual STLink Uart connection - Indicate Bootloader with blue LED
Diffstat (limited to 'src/platforms/f4discovery/platform.c')
-rw-r--r--src/platforms/f4discovery/platform.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/platforms/f4discovery/platform.c b/src/platforms/f4discovery/platform.c
index de39ab7..645a3c5 100644
--- a/src/platforms/f4discovery/platform.c
+++ b/src/platforms/f4discovery/platform.c
@@ -46,23 +46,28 @@ static void morse_update(void);
int platform_init(void)
{
+ /* Check the USER button*/
+ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
+ if(gpio_get(GPIOA, GPIO0)) {
+ assert_boot_pin();
+ scb_reset_core();
+ }
+
rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
/* Enable peripherals */
rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPBEN);
+ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_CRCEN);
-
/* Set up USB Pins and alternate function*/
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE,
GPIO9 | GPIO11 | GPIO12);
gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12);
- GPIOA_OSPEEDR &=~0xfc;
- GPIOA_OSPEEDR |= 0xa8;
+ GPIOC_OSPEEDR &=~0xF30;
+ GPIOC_OSPEEDR |= 0xA20;
gpio_mode_setup(JTAG_PORT, GPIO_MODE_OUTPUT,
GPIO_PUPD_NONE,
TMS_PIN | TCK_PIN | TDI_PIN);
@@ -73,7 +78,7 @@ int platform_init(void)
gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT,
GPIO_PUPD_NONE,
- LED_UART | LED_IDLE_RUN | LED_ERROR | LED_SPARE1);
+ LED_UART | LED_IDLE_RUN | LED_ERROR | LED_BOOTLOADER);
/* Setup heartbeat timer */
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
@@ -85,8 +90,6 @@ int platform_init(void)
usbuart_init();
- SCB_VTOR = 0x10000; // Relocate interrupt vector table here
-
cdcacm_init();
jtag_scan(NULL);
@@ -194,16 +197,14 @@ const char *platform_target_voltage(void)
void assert_boot_pin(void)
{
- if (gpio_get(GPIOA, GPIO0)) {
- /* Jump to the built in bootloader by mapping System flash */
- rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_SYSCFGEN);
- SYSCFG_MEMRM &= ~3;
- SYSCFG_MEMRM |= 1;
- }
- else {
- /* Flag Bootloader Request by mimicing a pushed USER button*/
- gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT,
- GPIO_PUPD_NONE, GPIO0);
- gpio_set(GPIOA, GPIO0);
- }
+ /* Assert blue LED as indicator we are in the bootloader */
+ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
+ gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT,
+ GPIO_PUPD_NONE, LED_BOOTLOADER);
+ gpio_set(LED_PORT, LED_BOOTLOADER);
+
+ /* Jump to the built in bootloader by mapping System flash */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_SYSCFGEN);
+ SYSCFG_MEMRM &= ~3;
+ SYSCFG_MEMRM |= 1;
}