summaryrefslogtreecommitdiffstats
path: root/boot/bootloader.c
diff options
context:
space:
mode:
Diffstat (limited to 'boot/bootloader.c')
-rw-r--r--boot/bootloader.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/boot/bootloader.c b/boot/bootloader.c
index 27b6b98..a5932f0 100644
--- a/boot/bootloader.c
+++ b/boot/bootloader.c
@@ -20,7 +20,7 @@
#include "project.h"
-#define BOOTLOADER_BUTTON GPIO15
+#define BOOTLOADER_BUTTON GPIO12
#define BOOTLOADER_BUTTON_PORT GPIOE
@@ -92,12 +92,22 @@ int main (void)
{
rcc_periph_clock_enable (RCC_GPIOE);
+ rcc_periph_clock_enable (RCC_GPIOB);
+ rcc_periph_clock_enable (RCC_GPIOG);
MAP_INPUT_PU (BOOTLOADER_BUTTON);
+ if ((dfu_flag != 0xfee1dead) && (GET (BOOTLOADER_BUTTON))) {
+
- if ((dfu_flag != 0xfee1dead) && (GET(BOOTLOADER_BUTTON))) {
/* Boot the application if it's valid. */
if ((* (volatile uint32_t *)APP_ADDRESS & 0x2FFE0000) == 0x20020000) {
+
+ max7219 ("boot");
+
+ rcc_periph_clock_disable (RCC_GPIOE);
+ rcc_periph_clock_disable (RCC_GPIOB);
+ rcc_periph_clock_disable (RCC_GPIOG);
+
/* Set vector table base address. */
SCB_VTOR = APP_ADDRESS & 0xFFFF;
/* Initialise master stack pointer. */
@@ -106,17 +116,15 @@ int main (void)
"g" (* (volatile uint32_t *)APP_ADDRESS),
"r" (* (uint32_t *) (APP_ADDRESS + 4))
: "memory");
- }
- }
-
-
+ } else
+ max7219 ("nofw dfu");
+ } else
+ max7219 ("dfu");
dfu_flag = 0;
rcc_periph_clock_enable (RCC_SYSCFG);
- rcc_periph_clock_enable (RCC_GPIOB);
- rcc_periph_clock_enable (RCC_GPIOG);
rcc_clock_setup_hsi_3v3 (&hsi_16mhz_3v3_48);
@@ -126,10 +134,9 @@ int main (void)
RCC_AHB2RSTR &= ~RCC_AHB2RSTR_OTGFSRST;
RCC_AHB1RSTR &= ~RCC_AHB1RSTR_ETHMACRST;
- max7219_init();
usart_init();
- usart2_xmit_str("\r\nDFU Bootloader\r\n");
+ usart2_xmit_str ("\r\nDFU Bootloader\r\n");
delay_ms (100);
usart_init();
usart2_xmit_str ("Ready\r\n");