Browse Source

Support F7 Lightniung Plus board.

Keir Fraser 4 years ago
parent
commit
73c3875252
4 changed files with 22 additions and 5 deletions
  1. 2 0
      inc/stm32/f7.h
  2. 2 1
      scripts/greaseweazle/tools/info.py
  3. 16 4
      src/f7/board.c
  4. 2 0
      src/f7/stm32.c

+ 2 - 0
inc/stm32/f7.h

@@ -94,6 +94,7 @@ enum {
     F7SM_lightning,
     F7SM_basic_v2,
     F7SM_ant_goffart_f7_plus_v2,
+    F7SM_lightning_plus,
 };
 
 struct user_pin {
@@ -105,6 +106,7 @@ struct user_pin {
 
 struct board_config {
     uint8_t hse_mhz;
+    bool_t hse_byp;
     bool_t hs_usb;
     const struct user_pin *user_pins;
 };

+ 2 - 1
scripts/greaseweazle/tools/info.py

@@ -20,7 +20,8 @@ model_id = { 1: { 0: 'F1' },
                   1: 'F7 Plus (Ant Goffart, version 1)',
                   2: 'F7 Lightning',
                   3: 'F7 (version 2)',
-                  4: 'F7 Plus (Ant Goffart, version 2)' } }
+                  4: 'F7 Plus (Ant Goffart, version 2)',
+                  5: 'F7 Lightning Plus' } }
 
 speed_id = { 0: 'Full Speed (12 Mbit/s)',
              1: 'High Speed (480 Mbit/s)' }

+ 16 - 4
src/f7/board.c

@@ -54,14 +54,17 @@ const static struct user_pin _user_pins_F7SM_ant_goffart_f7_plus_v2[] = {
     { 4, _C,  8, _PP },
     { 6, _C,  7, _PP },
     { 0,  0,  0, _PP } };
+const static struct user_pin _user_pins_F7SM_lightning_plus[] = {
+    { 2, _B, 12, _PP },
+    { 4, _E, 15, _PP },
+    { 6, _E, 14, _PP },
+    { 0,  0,  0, _PP } };
 const static struct board_config _board_config[] = {
     [F7SM_basic_v1] = {
         .hse_mhz   = 8,
-        .hs_usb    = FALSE,
         .user_pins = _user_pins_F7SM_basic_v1 },
     [F7SM_ant_goffart_f7_plus_v1] = {
         .hse_mhz   = 8,
-        .hs_usb    = FALSE,
         .user_pins = _user_pins_F7SM_ant_goffart_f7_plus_v1 },
     [F7SM_lightning] = {
         .hse_mhz   = 16,
@@ -69,12 +72,15 @@ const static struct board_config _board_config[] = {
         .user_pins = _user_pins_F7SM_lightning },
     [F7SM_basic_v2] = {
         .hse_mhz   = 8,
-        .hs_usb    = FALSE,
         .user_pins = _user_pins_F7SM_basic_v2 },
     [F7SM_ant_goffart_f7_plus_v2] = {
         .hse_mhz   = 8,
-        .hs_usb    = FALSE,
         .user_pins = _user_pins_F7SM_ant_goffart_f7_plus_v2 },
+    [F7SM_lightning_plus] = {
+        .hse_mhz   = 16,
+        .hse_byp   = TRUE,
+        .hs_usb    = TRUE,
+        .user_pins = _user_pins_F7SM_lightning_plus },
 };
 const struct board_config *board_config;
 
@@ -178,6 +184,12 @@ static void mcu_board_init(void)
         pu[upin->gpio_bank] &= ~(1u << upin->gpio_pin);
     }
 
+    /* Lightning Plus /FLIPPY output. Unused for now. Tie LOW. */
+    if (gw_info.hw_submodel == F7SM_lightning_plus) {
+        gpio_configure_pin(gpioc, 1, GPI_pull_down);
+        pu[_C] &= ~(1u << 1);
+    }
+
     gpio_pull_up_pins(gpioa, pu[_A]);
     gpio_pull_up_pins(gpiob, pu[_B]);
     gpio_pull_up_pins(gpioc, pu[_C]);

+ 2 - 0
src/f7/stm32.c

@@ -23,6 +23,8 @@ static void clock_init(void)
     early_delay_us(2);
 
     /* Start up the external oscillator. */
+    if (board_config->hse_byp)
+        rcc->cr |= RCC_CR_HSEBYP;
     rcc->cr |= RCC_CR_HSEON;
     while (!(rcc->cr & RCC_CR_HSERDY))
         cpu_relax();