Browse Source

Add Lerdge S,X,K (#18302)

J.C. Nelson 4 years ago
parent
commit
6f14d2d37f
No account linked to committer's email address
29 changed files with 1778 additions and 160 deletions
  1. 1
    0
      .github/workflows/test-builds.yml
  2. 6
    5
      Marlin/src/core/boards.h
  3. 9
    1
      Marlin/src/module/temperature.cpp
  4. 3
    1
      Marlin/src/pins/pins.h
  5. 45
    50
      Marlin/src/pins/stm32f4/pins_LERDGE_K.h
  6. 208
    0
      Marlin/src/pins/stm32f4/pins_LERDGE_S.h
  7. 25
    56
      Marlin/src/pins/stm32f4/pins_LERDGE_X.h
  8. 6
    6
      Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp
  9. 7
    7
      Marlin/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h
  10. 4
    4
      Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp
  11. 2
    2
      Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h
  12. 1
    1
      Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp
  13. 4
    4
      Marlin/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h
  14. 1
    1
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h
  15. 1
    1
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h
  16. 15
    15
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h
  17. 4
    4
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h
  18. 2
    2
      Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h
  19. 64
    0
      buildroot/share/PlatformIO/boards/LERDGE.json
  20. 186
    0
      buildroot/share/PlatformIO/ldscripts/lerdge.ld
  21. 47
    0
      buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py
  22. 46
    0
      buildroot/share/PlatformIO/scripts/lerdge.py
  23. 30
    0
      buildroot/share/PlatformIO/scripts/stm32_bootloader.py
  24. 418
    0
      buildroot/share/PlatformIO/variants/LERDGE/PeripheralPins.c
  25. 50
    0
      buildroot/share/PlatformIO/variants/LERDGE/PinNamesVar.h
  26. 297
    0
      buildroot/share/PlatformIO/variants/LERDGE/variant.cpp
  27. 238
    0
      buildroot/share/PlatformIO/variants/LERDGE/variant.h
  28. 18
    0
      buildroot/tests/LERDGEX-tests
  29. 40
    0
      platformio.ini

+ 1
- 0
.github/workflows/test-builds.yml View File

@@ -76,6 +76,7 @@ jobs:
76 76
         - rumba32
77 77
         - mks_robin_pro
78 78
         - STM32F103RET6_creality
79
+        - LERDGEX
79 80
 
80 81
         # Put lengthy tests last
81 82
 

+ 6
- 5
Marlin/src/core/boards.h View File

@@ -337,11 +337,12 @@
337 337
 #define BOARD_BTT_BTT002_V1_0         4211  // BigTreeTech BTT002 v1.0 (STM32F407VG)
338 338
 #define BOARD_BTT_GTR_V1_0            4212  // BigTreeTech GTR v1.0 (STM32F407IGT)
339 339
 #define BOARD_LERDGE_K                4213  // Lerdge K (STM32F407ZG)
340
-#define BOARD_LERDGE_X                4214  // Lerdge X (STM32F407VE)
341
-#define BOARD_VAKE403D                4215  // VAkE 403D (STM32F446VET6)
342
-#define BOARD_FYSETC_S6               4216  // FYSETC S6 board
343
-#define BOARD_FLYF407ZG               4217  // FLYF407ZG board (STM32F407ZG)
344
-#define BOARD_MKS_ROBIN2              4218  // MKS_ROBIN2 (STM32F407ZE)
340
+#define BOARD_LERDGE_S                4214  // Lerdge S (STM32F407VE)
341
+#define BOARD_LERDGE_X                4215  // Lerdge X (STM32F407VE)
342
+#define BOARD_VAKE403D                4216  // VAkE 403D (STM32F446VET6)
343
+#define BOARD_FYSETC_S6               4217  // FYSETC S6 board
344
+#define BOARD_FLYF407ZG               4218  // FLYF407ZG board (STM32F407ZG)
345
+#define BOARD_MKS_ROBIN2              4219  // MKS_ROBIN2 (STM32F407ZE)
345 346
 
346 347
 //
347 348
 // ARM Cortex M7

+ 9
- 1
Marlin/src/module/temperature.cpp View File

@@ -1598,12 +1598,20 @@ void Temperature::init() {
1598 1598
   #if MB(RUMBA)
1599 1599
     // Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
1600 1600
     #define _AD(N) ANY(HEATER_##N##_USES_AD595, HEATER_##N##_USES_AD8495)
1601
-    #if  _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER)
1601
+    #if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER)
1602 1602
       MCUCR = _BV(JTD);
1603 1603
       MCUCR = _BV(JTD);
1604 1604
     #endif
1605 1605
   #endif
1606 1606
 
1607
+  // Thermistor activation by MCU pin
1608
+  #if PIN_EXISTS(TEMP_0_TR_ENABLE_PIN)
1609
+    OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(HEATER_0_USES_MAX6675));
1610
+  #endif
1611
+  #if PIN_EXISTS(TEMP_1_TR_ENABLE_PIN)
1612
+    OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(HEATER_1_USES_MAX6675));
1613
+  #endif
1614
+
1607 1615
   #if BOTH(PIDTEMP, PID_EXTRUSION_SCALING)
1608 1616
     last_e_position = 0;
1609 1617
   #endif

+ 3
- 1
Marlin/src/pins/pins.h View File

@@ -586,8 +586,10 @@
586 586
   #include "stm32f4/pins_BTT_BTT002_V1_0.h"     // STM32F4                                env:BIGTREE_BTT002
587 587
 #elif MB(LERDGE_K)
588 588
   #include "stm32f4/pins_LERDGE_K.h"            // STM32F4                                env:STM32F4
589
+#elif MB(LERDGE_S)
590
+  #include "stm32f4/pins_LERDGE_S.h"            // STM32F4                                env:LERDGE_S
589 591
 #elif MB(LERDGE_X)
590
-  #include "stm32f4/pins_LERDGE_X.h"            // STM32F4                                env:STM32F4
592
+  #include "stm32f4/pins_LERDGE_X.h"            // STM32F4                                env:LERDGE_X
591 593
 #elif MB(VAKE403D)
592 594
   #include "stm32f4/pins_VAKE403D.h"            // STM32F4                                env:STM32F4
593 595
 #elif MB(FYSETC_S6)

+ 45
- 50
Marlin/src/pins/stm32f4/pins_LERDGE_K.h View File

@@ -29,13 +29,10 @@
29 29
 
30 30
 #define I2C_EEPROM
31 31
 
32
-// Ignore temp readings during develpment.
33
-//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000
34
-
35 32
 //
36 33
 // Servos
37 34
 //
38
-//#define SERVO0_PIN                        PD12
35
+//#define SERVO0_PIN                        PB11
39 36
 
40 37
 //
41 38
 // Limit Switches
@@ -48,14 +45,14 @@
48 45
 // Z Probe (when not Z_MIN_PIN)
49 46
 //
50 47
 //#ifndef Z_MIN_PROBE_PIN
51
-//  #define Z_MIN_PROBE_PIN  PB15
48
+//  #define Z_MIN_PROBE_PIN                 PG6
52 49
 //#endif
53 50
 
54 51
 //
55 52
 // Filament runout
56 53
 //
57
-#define FIL_RUNOUT_PIN                      PE6
58
-#define FIL_RUNOUT2_PIN                     PE7
54
+#define FIL_RUNOUT_PIN                      PE5
55
+#define FIL_RUNOUT2_PIN                     PE6
59 56
 
60 57
 //
61 58
 // Steppers
@@ -64,35 +61,35 @@
64 61
 #define X_DIR_PIN                           PB10
65 62
 #define X_ENABLE_PIN                        PG0
66 63
 //#ifndef X_CS_PIN
67
-//  #define X_CS_PIN       PE0
64
+//  #define X_CS_PIN                        PE0
68 65
 //#endif
69 66
 
70 67
 #define Y_STEP_PIN                          PF14
71 68
 #define Y_DIR_PIN                           PF15
72 69
 #define Y_ENABLE_PIN                        PF13
73 70
 //#ifndef Y_CS_PIN
74
-//  #define Y_CS_PIN       PE1
71
+//  #define Y_CS_PIN                        PE1
75 72
 //#endif
76 73
 
77 74
 #define Z_STEP_PIN                          PF11
78 75
 #define Z_DIR_PIN                           PF12
79 76
 #define Z_ENABLE_PIN                        PC5
80 77
 //#ifndef Z_CS_PIN
81
-//  #define Z_CS_PIN       PE2
78
+//  #define Z_CS_PIN                        PE2
82 79
 //#endif
83 80
 
84 81
 #define E0_STEP_PIN                         PC14
85 82
 #define E0_DIR_PIN                          PC13
86 83
 #define E0_ENABLE_PIN                       PC15
87 84
 //#ifndef E0_CS_PIN
88
-//  #define E0_CS_PIN      PE3
85
+//  #define E0_CS_PIN                       PE3
89 86
 //#endif
90 87
 
91 88
 #define E1_STEP_PIN                         PF1
92 89
 #define E1_DIR_PIN                          PF0
93 90
 #define E1_ENABLE_PIN                       PF2
94 91
 //#ifndef E1_CS_PIN
95
-//  #define E1_CS_PIN      PE4
92
+//  #define E1_CS_PIN                       PE4
96 93
 //#endif
97 94
 
98 95
 //
@@ -102,6 +99,12 @@
102 99
 #define TEMP_1_PIN                          PC2   // Analog Input
103 100
 #define TEMP_BED_PIN                        PC0   // Analog Input
104 101
 
102
+// Lergde-K can choose thermocouple/thermistor mode in software.
103
+// For use with thermistors, these pins must be OUT/LOW. 
104
+// This is done automatically.
105
+#define TEMP_0_TR_ENABLE_PIN                PF10
106
+#define TEMP_1_TR_ENABLE_PIN                PF9
107
+
105 108
 //
106 109
 // Heaters / Fans
107 110
 //
@@ -110,10 +113,10 @@
110 113
 #define HEATER_BED_PIN                      PA2
111 114
 
112 115
 #ifndef FAN_PIN
113
-  #define FAN_PIN                           PC15
116
+  #define FAN_PIN                           PF7
114 117
 #endif
115 118
 #define FAN1_PIN                            PF6
116
-#define FAN2_PIN                            PF7
119
+#define FAN2_PIN                            PF8
117 120
 
118 121
 #ifndef E0_AUTO_FAN_PIN
119 122
   #define E0_AUTO_FAN_PIN                   PF6
@@ -125,12 +128,15 @@
125 128
 //#define CASE_LIGHT_PIN_CI                 -1
126 129
 //#define CASE_LIGHT_PIN_DO                 -1
127 130
 //#define NEOPIXEL_PIN                      -1
128
-
129
-//
130
-// Prusa i3 MK2 Multi-Material Multiplexer Support
131
-//
132
-//#define E_MUX0_PIN                        -1
133
-//#define E_MUX1_PIN                        -1
131
+#ifndef RGB_LED_R_PIN
132
+  #define RGB_LED_R_PIN                     PB7
133
+#endif
134
+#ifndef RGB_LED_G_PIN
135
+  #define RGB_LED_G_PIN                     PB8
136
+#endif
137
+#ifndef RGB_LED_B_PIN
138
+  #define RGB_LED_B_PIN                     PB9
139
+#endif
134 140
 
135 141
 //
136 142
 // SD support
@@ -141,45 +147,34 @@
141 147
 // Misc. Functions
142 148
 //
143 149
 #define SDSS                                PC11
144
-#define LED_PIN                             PC7   // Alive
150
+#define LED_PIN                             PA15   // Alive
145 151
 #define PS_ON_PIN                           -1
146 152
 #define KILL_PIN                            -1
147
-#define POWER_LOSS_PIN                      -1    // Power-loss / nAC_FAULT
153
+#define POWER_LOSS_PIN                      PA4    // Power-loss / nAC_FAULT
148 154
 
149 155
 #define SCK_PIN                             PC12
150 156
 #define MISO_PIN                            PC8
151 157
 #define MOSI_PIN                            PD2
152 158
 #define SS_PIN                              PC11
153 159
 
160
+#define SD_DETECT_PIN                       PA8
161
+#define BEEPER_PIN                          PC7
162
+
154 163
 //
155 164
 // LCD / Controller
156 165
 //
157 166
 
158
-// TODO: Replace these with the correct FSMC pins, once known
159
-#define SD_DETECT_PIN                       -1
160
-#define BEEPER_PIN                          PD12
161
-#define LCD_PINS_RS                         -1
162
-#define LCD_PINS_ENABLE                     -1
163
-#define LCD_PINS_D4                         -1
164
-#define LCD_PINS_D5                         -1
165
-#define LCD_PINS_D6                         -1
166
-#define LCD_PINS_D7                         -1
167
-
168
-#define BTN_EN1                             PE3
169
-#define BTN_EN2                             PE4
170
-#define BTN_ENC                             PE2
171
-
172
-//
173
-// ST7920 Delays
174
-//
175
-#if HAS_GRAPHICAL_LCD
176
-  #ifndef BOARD_ST7920_DELAY_1
177
-    #define BOARD_ST7920_DELAY_1  DELAY_NS(96)
178
-  #endif
179
-  #ifndef BOARD_ST7920_DELAY_2
180
-    #define BOARD_ST7920_DELAY_2  DELAY_NS(48)
181
-  #endif
182
-  #ifndef BOARD_ST7920_DELAY_3
183
-    #define BOARD_ST7920_DELAY_3 DELAY_NS(715)
184
-  #endif
185
-#endif
167
+#define TFT_RESET_PIN                       PD6
168
+#define TFT_BACKLIGHT_PIN                   PD3
169
+
170
+#define TFT_CS_PIN                          PD7
171
+#define TFT_RS_PIN                          PD11
172
+
173
+#define TOUCH_CS_PIN                        PG15
174
+#define TOUCH_SCK_PIN                       PB3
175
+#define TOUCH_MOSI_PIN                      PB5
176
+#define TOUCH_MISO_PIN                      PB4
177
+
178
+#define BTN_EN1                             PG10
179
+#define BTN_EN2                             PG11
180
+#define BTN_ENC                             PG9

+ 208
- 0
Marlin/src/pins/stm32f4/pins_LERDGE_S.h View File

@@ -0,0 +1,208 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ */
19
+#pragma once
20
+
21
+#if !defined(STM32F4) && !defined(STM32F4xx)
22
+  #error "Oops! Select an STM32F4 board in 'Tools > Board.'"
23
+#elif HOTENDS > 2 || E_STEPPERS > 2
24
+  #error "LERDGE S supports up to 2 hotends / E-steppers."
25
+#endif
26
+
27
+#define BOARD_INFO_NAME      "Lerdge S"
28
+#define DEFAULT_MACHINE_NAME "LERDGE"
29
+
30
+#define STEP_TIMER 4
31
+#define TEMP_TIMER 2
32
+
33
+//#define I2C_EEPROM
34
+
35
+//
36
+// Servos
37
+//
38
+#define SERVO0_PIN                          PD12  //confirmed
39
+//#define SERVO1_PIN                        -1
40
+
41
+//
42
+// Limit Switches
43
+//
44
+#define X_MIN_PIN                           PG9   //confirmed
45
+#define Y_MIN_PIN                           PG10  //confirmed
46
+#define Z_MIN_PIN                           PG11  //confirmed
47
+
48
+#define X_MAX_PIN                           PG12  //confirmed
49
+#define Y_MAX_PIN                           PG13  //confirmed
50
+#define Z_MAX_PIN                           PG14  //confirmed
51
+
52
+//
53
+// Filament runout
54
+//
55
+#define FIL_RUNOUT_PIN                      PC5   //confirmed
56
+
57
+//
58
+// Z Probe (when not Z_MIN_PIN)
59
+//
60
+#ifndef Z_MIN_PROBE_PIN
61
+  #define Z_MIN_PROBE_PIN                   PG8   //confirmed
62
+#endif
63
+
64
+//
65
+// Steppers
66
+//
67
+#define X_STEP_PIN                          PF7   //confirmed
68
+#define X_DIR_PIN                           PF8   //confirmed
69
+#define X_ENABLE_PIN                        PF6   //confirmed
70
+
71
+#define Y_STEP_PIN                          PF10  //confirmed
72
+#define Y_DIR_PIN                           PF11  //confirmed
73
+#define Y_ENABLE_PIN                        PF9   //confirmed
74
+
75
+#define Z_STEP_PIN                          PF13  //confirmed
76
+#define Z_DIR_PIN                           PF14  //confirmed
77
+#define Z_ENABLE_PIN                        PF12  //confirmed
78
+
79
+#define E0_STEP_PIN                         PG0   //confirmed
80
+#define E0_DIR_PIN                          PG1   //confirmed
81
+#define E0_ENABLE_PIN                       PF15  //confirmed
82
+
83
+#define E1_STEP_PIN                         PG3   //confirmed
84
+#define E1_DIR_PIN                          PG4   //confirmed
85
+#define E1_ENABLE_PIN                       PG2   //confirmed
86
+
87
+//
88
+// Temperature Sensors
89
+//
90
+#define TEMP_0_PIN                          PC0   // See below for activation of thermistor readings
91
+#define TEMP_1_PIN                          PC1   // See below for activation of thermistor readings
92
+#define TEMP_BED_PIN                        PC3   //confirmed
93
+
94
+// Lergde-S can choose thermocouple/thermistor mode in software.
95
+// For use with thermistors, these pins must be OUT/LOW.
96
+// This is done automatically.
97
+#define TEMP_0_TR_ENABLE_PIN                PF3
98
+#define TEMP_1_TR_ENABLE_PIN                PF4
99
+
100
+// MAX6675 Cold-Junction-Compensated K-Thermocouple to Digital Converter (0°C to +1024°C)
101
+// https://datasheets.maximintegrated.com/en/ds/MAX6675.pdf
102
+
103
+#define MAX6675_SCK_PIN                     PB3   // max6675 datasheet: SCK pin, found with multimeter, not tested
104
+#define MAX6675_DO_PIN                      PB4   // max6675 datasheet: SO pin, found with multimeter, not tested
105
+#define MAX6675_SS_PIN                      PC4   // max6675 datasheet: /CS pin, found with multimeter, not tested and likely wrong
106
+
107
+// Expansion board with second max6675
108
+// Warning: Some boards leave the slot unpopulated.
109
+
110
+//#define MAX6675_SCK2_PIN                  PB3   // max6675 datasheet: SCK pin, found with multimeter, not tested
111
+//#define MAX6675_DO2_PIN                   PB4   // max6675 datasheet: SO pin, found with multimeter, not tested
112
+//#define MAX6675_SS2_PIN                   PF1   // max6675 datasheet: /CS pin, found with multimeter, not tested
113
+
114
+//
115
+// Heaters / Fans
116
+//
117
+#define HEATER_0_PIN                        PA0   //confirmed
118
+#define HEATER_1_PIN                        PA1   //confirmed
119
+#define HEATER_BED_PIN                      PA3   //confirmed
120
+
121
+#define FAN_PIN                             PA15  // heater 0 fan 1 //confirmed
122
+#define FAN1_PIN                            PB10  // heater 1 fan 2 //confirmed
123
+#define FAN2_PIN                            PF5   // heater 0 fan 2 and heater 1 fan 1 (two sockets, switched together) //confirmed
124
+
125
+#ifndef E0_AUTO_FAN_PIN
126
+  #define E0_AUTO_FAN_PIN                   PF5
127
+#endif
128
+
129
+//
130
+// Prusa i3 MK2 Multi Material Multiplexer Support
131
+//
132
+//#define E_MUX0_PIN                        -1
133
+//#define E_MUX1_PIN                        -1
134
+
135
+//
136
+// LED / Lighting
137
+//
138
+//Lerdge-S board has two LED connectors (this is the one on the mainboard)
139
+#define CASE_LIGHT_PIN                      PC7   //confirmed
140
+
141
+//on the dual extrusion addon board is a RGB connector
142
+#define RGB_LED_R_PIN                       PC7   // Shared with the mainboard LED light connector (CASE_LIGHT_PIN), confirmed
143
+#define RGB_LED_G_PIN                       PB0   //confirmed
144
+#define RGB_LED_B_PIN                       PB1   //confirmed
145
+
146
+//
147
+// Misc. Functions
148
+//
149
+#define SDSS                                PC11  // SD is working using SDIO, not sure if this definition is needed?
150
+#define LED_PIN                             PC6   // Mainboard soldered green LED, confirmed
151
+#define PS_ON_PIN                           PB2   // Board has a power module connector, confirmed
152
+#define KILL_PIN                            -1    // There is no reset button on the LCD
153
+#define POWER_LOSS_PIN                      -1    // PB2 could be used for this as well
154
+
155
+//
156
+// SD support
157
+//
158
+#define SDIO_SUPPORT
159
+
160
+#define SCK_PIN                             PC12  //confirmed working
161
+#define MISO_PIN                            PC8   //confirmed working
162
+#define MOSI_PIN                            PD2   //confirmed working
163
+#define SS_PIN                              PC11  //confirmed working
164
+
165
+#define SD_DETECT_PIN                       PG15  //confirmed
166
+
167
+//
168
+// Persistent Storage
169
+// If no option is selected below the SD Card will be used
170
+// (this section modelled after pins_LONGER3D_LK.h)
171
+// Warning: Not tested yet! Pins traced with multimeter, mistakes are possible
172
+//#define SPI_EEPROM
173
+
174
+#if ENABLED(SPI_EEPROM)
175
+  // Lerdge has an SPI EEPROM Winbond W25Q128 (128Mbits) https://www.pjrc.com/teensy/W25Q128FV.pdf
176
+  #define SPI_CHAN_EEPROM1 1
177
+  #define SPI_EEPROM1_CS                    PB12  // datasheet: /CS pin, found with multimeter, not tested
178
+  #define EEPROM_SCK                        PB13  // datasheet: CLK pin, found with multimeter, not tested
179
+  #define EEPROM_MISO                       PB14  // datasheet: DO pin, found with multimeter, not tested
180
+  #define EEPROM_MOSI                       PB15  // datasheet: DI pin, found with multimeter, not tested
181
+  #define EEPROM_PAGE_SIZE 0x1000U                // 4KB (from datasheet)
182
+  #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE)   // Limit to 64KB for now...
183
+#else
184
+  #define MARLIN_EEPROM_SIZE 0x800U               // On SD, Limit to 2KB, require this amount of RAM
185
+#endif
186
+
187
+//
188
+// LCD / Controller
189
+//
190
+
191
+// The LCD is initialized in FSMC mode
192
+#define BEEPER_PIN                          PD13  //confirmed
193
+
194
+#define BTN_EN1                             PC14  //confirmed
195
+#define BTN_EN2                             PC15  //confirmed
196
+#define BTN_ENC                             PC13  //confirmed
197
+
198
+#define TFT_RESET_PIN                       PD6   //confirmed
199
+#define TFT_BACKLIGHT_PIN                   PD3   //confirmed
200
+
201
+#define TFT_CS_PIN                          PD7   // TFT works
202
+#define TFT_RS_PIN                          PD11  // TFT works
203
+
204
+// There is touch, but calibration is off
205
+#define TOUCH_CS_PIN                        PB6
206
+#define TOUCH_SCK_PIN                       PB3
207
+#define TOUCH_MOSI_PIN                      PB5
208
+#define TOUCH_MISO_PIN                      PB4

+ 25
- 56
Marlin/src/pins/stm32f4/pins_LERDGE_X.h View File

@@ -20,20 +20,22 @@
20 20
 
21 21
 #if !defined(STM32F4) && !defined(STM32F4xx)
22 22
   #error "Oops! Select an STM32F4 board in 'Tools > Board.'"
23
-#elif HOTENDS > 2 || E_STEPPERS > 2
24
-  #error "LERDGE X supports up to 2 hotends / E-steppers."
23
+#elif HOTENDS > 1 || E_STEPPERS > 1
24
+  #error "LERDGE X supports only one hotend / E-steppers"
25 25
 #endif
26 26
 
27 27
 #define BOARD_INFO_NAME      "Lerdge X"
28 28
 #define DEFAULT_MACHINE_NAME "LERDGE"
29 29
 
30
-//#define I2C_EEPROM
30
+#define STEP_TIMER 4
31
+#define TEMP_TIMER 2
32
+
33
+#define I2C_EEPROM
31 34
 
32 35
 //
33 36
 // Servos
34 37
 //
35
-//#define SERVO0_PIN                        PD12
36
-//#define SERVO1_PIN                        -1
38
+//#define SERVO0_PIN                        PD13
37 39
 
38 40
 //
39 41
 // Limit Switches
@@ -51,7 +53,7 @@
51 53
 // Z Probe (when not Z_MIN_PIN)
52 54
 //
53 55
 //#ifndef Z_MIN_PROBE_PIN
54
-//  #define Z_MIN_PROBE_PIN  PB15
56
+//  #define Z_MIN_PROBE_PIN                 PB15
55 57
 //#endif
56 58
 
57 59
 //
@@ -60,37 +62,18 @@
60 62
 #define X_STEP_PIN                          PB10
61 63
 #define X_DIR_PIN                           PB2
62 64
 #define X_ENABLE_PIN                        PB11
63
-//#ifndef X_CS_PIN
64
-//  #define X_CS_PIN       PD1
65
-//#endif
66 65
 
67 66
 #define Y_STEP_PIN                          PB0
68 67
 #define Y_DIR_PIN                           PC5
69 68
 #define Y_ENABLE_PIN                        PB1
70
-//#ifndef Y_CS_PIN
71
-//  #define Y_CS_PIN       PE12
72
-//#endif
73 69
 
74 70
 #define Z_STEP_PIN                          PA7
75 71
 #define Z_DIR_PIN                           PA6
76 72
 #define Z_ENABLE_PIN                        PC4
77
-//#ifndef Z_CS_PIN
78
-//  #define Z_CS_PIN       PD5
79
-//#endif
80 73
 
81 74
 #define E0_STEP_PIN                         PA4
82 75
 #define E0_DIR_PIN                          PA3
83 76
 #define E0_ENABLE_PIN                       PA5
84
-//#ifndef E0_CS_PIN
85
-//  #define E0_CS_PIN      PB4
86
-//#endif
87
-
88
-#define E1_STEP_PIN                         -1
89
-#define E1_DIR_PIN                          -1
90
-#define E1_ENABLE_PIN                       -1
91
-//#ifndef E1_CS_PIN
92
-//  #define E1_CS_PIN      PE5
93
-//#endif
94 77
 
95 78
 //
96 79
 // Temperature Sensors
@@ -106,9 +89,9 @@
106 89
 #define HEATER_1_PIN                        -1
107 90
 #define HEATER_BED_PIN                      PA2
108 91
 
109
-#ifndef FAN_PIN
110
-  //#define FAN_PIN                         PC15
111
-#endif
92
+//#ifndef FAN_PIN
93
+//  #define FAN_PIN                         PC15
94
+//#endif
112 95
 #define FAN1_PIN                            PC15
113 96
 #define FAN2_PIN                            PA0
114 97
 
@@ -117,12 +100,6 @@
117 100
 #endif
118 101
 
119 102
 //
120
-// Prusa i3 MK2 Multi Material Multiplexer Support
121
-//
122
-//#define E_MUX0_PIN                        -1
123
-//#define E_MUX1_PIN                        -1
124
-
125
-//
126 103
 // LED / Lighting
127 104
 //
128 105
 //#define CASE_LIGHT_PIN_CI                 -1
@@ -136,7 +113,9 @@
136 113
 #define LED_PIN                             PC7   // Alive
137 114
 #define PS_ON_PIN                           -1
138 115
 #define KILL_PIN                            -1
139
-#define POWER_LOSS_PIN                      -1    // Power-loss / nAC_FAULT
116
+
117
+// Lerdge supports auto-power off and power loss sense through a single pin.
118
+#define POWER_LOSS_PIN                      PC14    // Power-loss / nAC_FAULT
140 119
 
141 120
 #define SCK_PIN                             PC12
142 121
 #define MISO_PIN                            PC8
@@ -147,36 +126,26 @@
147 126
 // SD support
148 127
 //
149 128
 #define SDIO_SUPPORT
129
+#define SD_DETECT_PIN                       PA8
150 130
 
151 131
 //
152 132
 // LCD / Controller
153 133
 //
154 134
 
155 135
 // The LCD is initialized in FSMC mode
156
-#define SD_DETECT_PIN                       -1
157 136
 #define BEEPER_PIN                          PD12
158 137
 
159 138
 #define BTN_EN1                             PE3
160 139
 #define BTN_EN2                             PE4
161 140
 #define BTN_ENC                             PE2
162 141
 
163
-#define LCD_RESET_PIN                       PD6
164
-#define LCD_BACKLIGHT_PIN                   PD3
165
-#define FSMC_CS_PIN                         PD4
166
-#define FSMC_RS_PIN                         PD11
167
-#define TOUCH_CS                            PB6
168
-
169
-//
170
-// ST7920 Delays
171
-//
172
-#if HAS_GRAPHICAL_LCD
173
-  #ifndef BOARD_ST7920_DELAY_1
174
-    #define BOARD_ST7920_DELAY_1  DELAY_NS(96)
175
-  #endif
176
-  #ifndef BOARD_ST7920_DELAY_2
177
-    #define BOARD_ST7920_DELAY_2  DELAY_NS(48)
178
-  #endif
179
-  #ifndef BOARD_ST7920_DELAY_3
180
-    #define BOARD_ST7920_DELAY_3 DELAY_NS(715)
181
-  #endif
182
-#endif
142
+#define TFT_RESET_PIN                       PD6
143
+#define TFT_BACKLIGHT_PIN                   PD3
144
+
145
+#define TFT_CS_PIN                          PD7
146
+#define TFT_RS_PIN                          PD11
147
+
148
+#define TOUCH_CS_PIN                        PB6
149
+#define TOUCH_SCK_PIN                       PB3
150
+#define TOUCH_MOSI_PIN                      PB5
151
+#define TOUCH_MISO_PIN                      PB4

+ 6
- 6
Marlin/src/sd/usb_flashdrive/lib-uhs2/Usb.cpp View File

@@ -428,7 +428,7 @@ void USB::Task() { //USB state machine
428 428
   uint8_t rcode;
429 429
   uint8_t tmpdata;
430 430
   static uint32_t delay = 0;
431
-  //USB_FD_DEVICE_DESCRIPTOR buf;
431
+  //USB_DEVICE_DESCRIPTOR buf;
432 432
   bool lowspeed = false;
433 433
 
434 434
   MAX3421E::Task();
@@ -647,8 +647,8 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
647 647
   //printf("Configuring: parent = %i, port = %i\r\n", parent, port);
648 648
   uint8_t devConfigIndex;
649 649
   uint8_t rcode = 0;
650
-  uint8_t buf[sizeof (USB_FD_DEVICE_DESCRIPTOR)];
651
-  USB_FD_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_FD_DEVICE_DESCRIPTOR *>(buf);
650
+  uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
651
+  USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR *>(buf);
652 652
   UsbDevice *p = nullptr;
653 653
   EpInfo *oldep_ptr = nullptr;
654 654
   EpInfo epInfo;
@@ -678,13 +678,13 @@ uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
678 678
 
679 679
   p->lowspeed = lowspeed;
680 680
   // Get device descriptor
681
-  rcode = getDevDescr(0, 0, sizeof (USB_FD_DEVICE_DESCRIPTOR), (uint8_t*)buf);
681
+  rcode = getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);
682 682
 
683 683
   // Restore p->epinfo
684 684
   p->epinfo = oldep_ptr;
685 685
 
686 686
   if (rcode) {
687
-    //printf("Configuring error: Can't get USB_FD_DEVICE_DESCRIPTOR\r\n");
687
+    //printf("Configuring error: Can't get USB_DEVICE_DESCRIPTOR\r\n");
688 688
     return rcode;
689 689
   }
690 690
 
@@ -762,7 +762,7 @@ uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t con
762 762
 uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) {
763 763
   const uint8_t bufSize = 64;
764 764
   uint8_t buf[bufSize];
765
-  USB_FD_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_FD_CONFIGURATION_DESCRIPTOR *>(buf);
765
+  USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR *>(buf);
766 766
 
767 767
   uint8_t ret = getConfDescr(addr, ep, 9, conf, buf);
768 768
   if (ret) return ret;

+ 7
- 7
Marlin/src/sd/usb_flashdrive/lib-uhs2/confdescparser.h View File

@@ -30,10 +30,10 @@
30 30
 
31 31
 class UsbConfigXtracter {
32 32
 public:
33
-  //virtual void ConfigXtract(const USB_FD_CONFIGURATION_DESCRIPTOR *conf) = 0;
34
-  //virtual void InterfaceXtract(uint8_t conf, const USB_FD_INTERFACE_DESCRIPTOR *iface) = 0;
33
+  //virtual void ConfigXtract(const USB_CONFIGURATION_DESCRIPTOR *conf) = 0;
34
+  //virtual void InterfaceXtract(uint8_t conf, const USB_INTERFACE_DESCRIPTOR *iface) = 0;
35 35
 
36
-  virtual void EndpointXtract(uint8_t conf __attribute__((unused)), uint8_t iface __attribute__((unused)), uint8_t alt __attribute__((unused)), uint8_t proto __attribute__((unused)), const USB_FD_ENDPOINT_DESCRIPTOR *ep __attribute__((unused))) {
36
+  virtual void EndpointXtract(uint8_t conf __attribute__((unused)), uint8_t iface __attribute__((unused)), uint8_t alt __attribute__((unused)), uint8_t proto __attribute__((unused)), const USB_ENDPOINT_DESCRIPTOR *ep __attribute__((unused))) {
37 37
   }
38 38
 };
39 39
 
@@ -50,7 +50,7 @@ class ConfigDescParser : public USBReadParser {
50 50
   MultiValueBuffer theBuffer;
51 51
   MultiByteValueParser valParser;
52 52
   ByteSkipper theSkipper;
53
-  uint8_t varBuffer[16 /*sizeof(USB_FD_CONFIGURATION_DESCRIPTOR)*/];
53
+  uint8_t varBuffer[16 /*sizeof(USB_CONFIGURATION_DESCRIPTOR)*/];
54 54
 
55 55
   uint8_t stateParseDescr; // ParseDescriptor state
56 56
 
@@ -97,8 +97,8 @@ void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::Parse(const uin
97 97
   compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */
98 98
 template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTOCOL_ID, const uint8_t MASK>
99 99
 bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor(uint8_t **pp, uint16_t *pcntdn) {
100
-  USB_FD_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast<USB_FD_CONFIGURATION_DESCRIPTOR*>(varBuffer);
101
-  USB_FD_INTERFACE_DESCRIPTOR* uid = reinterpret_cast<USB_FD_INTERFACE_DESCRIPTOR*>(varBuffer);
100
+  USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(varBuffer);
101
+  USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast<USB_INTERFACE_DESCRIPTOR*>(varBuffer);
102 102
   switch (stateParseDescr) {
103 103
     case 0:
104 104
       theBuffer.valueSize = 2;
@@ -155,7 +155,7 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
155 155
         case USB_DESCRIPTOR_ENDPOINT:
156 156
           if (!valParser.Parse(pp, pcntdn)) return false;
157 157
           if (isGoodInterface && theXtractor)
158
-            theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_FD_ENDPOINT_DESCRIPTOR*)varBuffer);
158
+            theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer);
159 159
           break;
160 160
           //case HID_DESCRIPTOR_HID:
161 161
           //  if (!valParser.Parse(pp, pcntdn)) return false;

+ 4
- 4
Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.cpp View File

@@ -250,10 +250,10 @@ bLastUsbError(0) {
250 250
  */
251 251
 uint8_t BulkOnly::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
252 252
 
253
-  const uint8_t constBufSize = sizeof (USB_FD_DEVICE_DESCRIPTOR);
253
+  const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
254 254
 
255 255
   uint8_t buf[constBufSize];
256
-  USB_FD_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_FD_DEVICE_DESCRIPTOR*>(buf);
256
+  USB_DEVICE_DESCRIPTOR * udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR*>(buf);
257 257
   uint8_t rcode;
258 258
   UsbDevice *p = nullptr;
259 259
   EpInfo *oldep_ptr = nullptr;
@@ -529,7 +529,7 @@ uint8_t BulkOnly::Init(uint8_t parent __attribute__((unused)), uint8_t port __at
529 529
  * @param proto
530 530
  * @param pep
531 531
  */
532
-void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto __attribute__((unused)), const USB_FD_ENDPOINT_DESCRIPTOR * pep) {
532
+void BulkOnly::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto __attribute__((unused)), const USB_ENDPOINT_DESCRIPTOR * pep) {
533 533
   ErrorMessage<uint8_t> (PSTR("Conf.Val"), conf);
534 534
   ErrorMessage<uint8_t> (PSTR("Iface Num"), iface);
535 535
   ErrorMessage<uint8_t> (PSTR("Alt.Set"), alt);
@@ -1166,7 +1166,7 @@ uint8_t BulkOnly::HandleSCSIError(uint8_t status) {
1166 1166
  *
1167 1167
  * @param ep_ptr
1168 1168
  */
1169
-void BulkOnly::PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR * ep_ptr) {
1169
+void BulkOnly::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR * ep_ptr) {
1170 1170
   Notify(PSTR("Endpoint descriptor:"), 0x80);
1171 1171
   Notify(PSTR("\r\nLength:\t\t"), 0x80);
1172 1172
   D_PrintHex<uint8_t> (ep_ptr->bLength, 0x80);

+ 2
- 2
Marlin/src/sd/usb_flashdrive/lib-uhs2/masstorage.h View File

@@ -491,7 +491,7 @@ protected:
491 491
   uint16_t CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]; // Sector size, clipped to 16 bits
492 492
   bool LUNOk[MASS_MAX_SUPPORTED_LUN]; // use this to check for media changes.
493 493
   bool WriteOk[MASS_MAX_SUPPORTED_LUN];
494
-  void PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR* ep_ptr);
494
+  void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
495 495
 
496 496
   // Additional Initialization Method for Subclasses
497 497
 
@@ -526,7 +526,7 @@ public:
526 526
   virtual uint8_t GetAddress() { return bAddress; }
527 527
 
528 528
   // UsbConfigXtracter implementation
529
-  void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_FD_ENDPOINT_DESCRIPTOR *ep);
529
+  void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
530 530
 
531 531
   virtual bool DEVCLASSOK(uint8_t klass) { return klass == USB_CLASS_MASS_STORAGE; }
532 532
 

+ 1
- 1
Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp View File

@@ -37,7 +37,7 @@ int UsbDEBUGlvl = 0x80;
37 37
 void E_Notifyc(char c, int lvl) {
38 38
   if (UsbDEBUGlvl < lvl) return;
39 39
   USB_HOST_SERIAL.print(c
40
-    #if !defined(ARDUINO) && !defined(ARDUINO_ARCH_LPC176X)
40
+    #if !defined(ARDUINO) || ARDUINO < 100
41 41
       , BYTE
42 42
     #endif
43 43
   );

+ 4
- 4
Marlin/src/sd/usb_flashdrive/lib-uhs2/usb_ch9.h View File

@@ -116,7 +116,7 @@ typedef struct {
116 116
         uint8_t iProduct; // Index of String Descriptor describing the product.
117 117
         uint8_t iSerialNumber; // Index of String Descriptor with the device's serial number.
118 118
         uint8_t bNumConfigurations; // Number of possible configurations.
119
-} __attribute__((packed)) USB_FD_DEVICE_DESCRIPTOR;
119
+} __attribute__((packed)) USB_DEVICE_DESCRIPTOR;
120 120
 
121 121
 /* Configuration descriptor structure */
122 122
 typedef struct {
@@ -128,7 +128,7 @@ typedef struct {
128 128
         uint8_t iConfiguration; // Index of String Descriptor describing the configuration.
129 129
         uint8_t bmAttributes; // Configuration characteristics.
130 130
         uint8_t bMaxPower; // Maximum power consumed by this configuration.
131
-} __attribute__((packed)) USB_FD_CONFIGURATION_DESCRIPTOR;
131
+} __attribute__((packed)) USB_CONFIGURATION_DESCRIPTOR;
132 132
 
133 133
 /* Interface descriptor structure */
134 134
 typedef struct {
@@ -141,7 +141,7 @@ typedef struct {
141 141
         uint8_t bInterfaceSubClass; // Subclass code (assigned by the USB-IF).
142 142
         uint8_t bInterfaceProtocol; // Protocol code (assigned by the USB-IF).  0xFF-Vendor specific.
143 143
         uint8_t iInterface; // Index of String Descriptor describing the interface.
144
-} __attribute__((packed)) USB_FD_INTERFACE_DESCRIPTOR;
144
+} __attribute__((packed)) USB_INTERFACE_DESCRIPTOR;
145 145
 
146 146
 /* Endpoint descriptor structure */
147 147
 typedef struct {
@@ -151,7 +151,7 @@ typedef struct {
151 151
         uint8_t bmAttributes; // Endpoint transfer type.
152 152
         uint16_t wMaxPacketSize; // Maximum packet size.
153 153
         uint8_t bInterval; // Polling interval in frames.
154
-} __attribute__((packed)) USB_FD_ENDPOINT_DESCRIPTOR;
154
+} __attribute__((packed)) USB_ENDPOINT_DESCRIPTOR;
155 155
 
156 156
 /* HID descriptor */
157 157
 typedef struct {

+ 1
- 1
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE.h View File

@@ -174,7 +174,7 @@ protected:
174 174
         volatile uint16_t CurrentSectorSize[MASS_MAX_SUPPORTED_LUN]; // Sector size, clipped to 16 bits
175 175
         volatile bool LUNOk[MASS_MAX_SUPPORTED_LUN]; // use this to check for media changes.
176 176
         volatile bool WriteOk[MASS_MAX_SUPPORTED_LUN];
177
-        void PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR* ep_ptr);
177
+        void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr);
178 178
 
179 179
 public:
180 180
         UHS_Bulk_Storage(UHS_USB_HOST_BASE *p);

+ 1
- 1
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_BULK_STORAGE/UHS_BULK_STORAGE_INLINE.h View File

@@ -1188,7 +1188,7 @@ uint8_t UHS_NI UHS_Bulk_Storage::HandleSCSIError(uint8_t status) {
1188 1188
  *
1189 1189
  * @param ep_ptr
1190 1190
  */
1191
-void UHS_NI UHS_Bulk_Storage::PrintEndpointDescriptor(const USB_FD_ENDPOINT_DESCRIPTOR * ep_ptr) {
1191
+void UHS_NI UHS_Bulk_Storage::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR * ep_ptr) {
1192 1192
         Notify(PSTR("Endpoint descriptor:"), 0x80);
1193 1193
         Notify(PSTR("\r\nLength:\t\t"), 0x80);
1194 1194
         D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);

+ 15
- 15
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_host_INLINE.h View File

@@ -239,12 +239,12 @@ uint8_t UHS_USB_HOST_BASE::Configuring(uint8_t parent, uint8_t port, uint8_t spe
239 239
         // wrap in {} to throw away the 64 byte buffer when we are done with it
240 240
         {
241 241
                 uint8_t buf[biggest];
242
-                USB_FD_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_FD_DEVICE_DESCRIPTOR *>(buf);
242
+                USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR *>(buf);
243 243
 #else
244 244
         const uint8_t biggest = 18;
245 245
         uint8_t buf[biggest];
246
-        USB_FD_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_FD_DEVICE_DESCRIPTOR *>(buf);
247
-        USB_FD_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_FD_CONFIGURATION_DESCRIPTOR *>(buf);
246
+        USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR *>(buf);
247
+        USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR *>(buf);
248 248
 #endif
249 249
 
250 250
                 //for(devConfigIndex = 0; devConfigIndex < UHS_HOST_MAX_INTERFACE_DRIVERS; devConfigIndex++) {
@@ -309,7 +309,7 @@ again:
309 309
                                 sof_delay(200);
310 310
                                 goto again;
311 311
                         }
312
-                        HOST_DEBUG("Configuring error: 0x%2.2x Can't get USB_FD_DEVICE_DESCRIPTOR\r\n", rcode);
312
+                        HOST_DEBUG("Configuring error: 0x%2.2x Can't get USB_DEVICE_DESCRIPTOR\r\n", rcode);
313 313
                         return rcode;
314 314
                 }
315 315
 
@@ -378,7 +378,7 @@ again:
378 378
         } // unwrapped, old large buf now invalid and discarded.
379 379
 
380 380
         uint8_t buf[18];
381
-        USB_FD_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_FD_CONFIGURATION_DESCRIPTOR *>(buf);
381
+        USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR *>(buf);
382 382
 #endif
383 383
 
384 384
         ei.address = addrPool.AllocAddress(parent, IsHub(ei.klass), port);
@@ -415,9 +415,9 @@ again:
415 415
                 HOST_DEBUG("configs: %i\r\n", configs);
416 416
                 for(uint8_t conf = 0; (!rcode) && (conf < configs); conf++) {
417 417
                         // read the config descriptor into a buffer.
418
-                        rcode = getConfDescr(ei.address, sizeof (USB_FD_CONFIGURATION_DESCRIPTOR), conf, buf);
418
+                        rcode = getConfDescr(ei.address, sizeof (USB_CONFIGURATION_DESCRIPTOR), conf, buf);
419 419
                         if(rcode) {
420
-                                HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR\r\n", rcode);
420
+                                HOST_DEBUG("Configuring error: %2.2x Can't get USB_INTERFACE_DESCRIPTOR\r\n", rcode);
421 421
                                 rcode = UHS_HOST_ERROR_FailGetConfDescr;
422 422
                                 continue;
423 423
                         }
@@ -438,7 +438,7 @@ again:
438 438
                         uint8_t offset;
439 439
                         rcode = initDescrStream(&ei, ucd, pep, data, &left, &read, &offset);
440 440
                         if(rcode) {
441
-                                HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode);
441
+                                HOST_DEBUG("Configuring error: %2.2x Can't get USB_INTERFACE_DESCRIPTOR stream.\r\n", rcode);
442 442
                                 break;
443 443
                         }
444 444
                         for(; (numinf) && (!rcode); inf++) {
@@ -451,7 +451,7 @@ again:
451 451
                                         break;
452 452
                                 }
453 453
                                 if(rcode) {
454
-                                        HOST_DEBUG("Configuring error: %2.2x Can't close USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode);
454
+                                        HOST_DEBUG("Configuring error: %2.2x Can't close USB_INTERFACE_DESCRIPTOR stream.\r\n", rcode);
455 455
                                         continue;
456 456
                                 }
457 457
                                 rcode = TestInterface(&ei);
@@ -471,9 +471,9 @@ again:
471 471
                 if(!bestsuccess) rcode = UHS_HOST_ERROR_DEVICE_NOT_SUPPORTED;
472 472
         }
473 473
         if(!rcode) {
474
-                rcode = getConfDescr(ei.address, sizeof (USB_FD_CONFIGURATION_DESCRIPTOR), bestconf, buf);
474
+                rcode = getConfDescr(ei.address, sizeof (USB_CONFIGURATION_DESCRIPTOR), bestconf, buf);
475 475
                 if(rcode) {
476
-                        HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR\r\n", rcode);
476
+                        HOST_DEBUG("Configuring error: %2.2x Can't get USB_INTERFACE_DESCRIPTOR\r\n", rcode);
477 477
                         rcode = UHS_HOST_ERROR_FailGetConfDescr;
478 478
                 }
479 479
         }
@@ -497,7 +497,7 @@ again:
497 497
                                 uint8_t offset;
498 498
                                 rcode = initDescrStream(&ei, ucd, pep, data, &left, &read, &offset);
499 499
                                 if(rcode) {
500
-                                        HOST_DEBUG("Configuring error: %2.2x Can't get USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode);
500
+                                        HOST_DEBUG("Configuring error: %2.2x Can't get USB_INTERFACE_DESCRIPTOR stream.\r\n", rcode);
501 501
                                 } else {
502 502
                                         for(; (numinf) && (!rcode); inf++) {
503 503
                                                 // iterate for each interface on this config
@@ -508,7 +508,7 @@ again:
508 508
                                                         break;
509 509
                                                 }
510 510
                                                 if(rcode) {
511
-                                                        HOST_DEBUG("Configuring error: %2.2x Can't close USB_FD_INTERFACE_DESCRIPTOR stream.\r\n", rcode);
511
+                                                        HOST_DEBUG("Configuring error: %2.2x Can't close USB_INTERFACE_DESCRIPTOR stream.\r\n", rcode);
512 512
                                                         continue;
513 513
                                                 }
514 514
 
@@ -721,7 +721,7 @@ uint8_t UHS_USB_HOST_BASE::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytes
721 721
  * @param offset
722 722
  * @return zero for success or error code
723 723
  */
724
-uint8_t UHS_USB_HOST_BASE::initDescrStream(ENUMERATION_INFO *ei, USB_FD_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset) {
724
+uint8_t UHS_USB_HOST_BASE::initDescrStream(ENUMERATION_INFO *ei, USB_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset) {
725 725
         if(!ei || !ucd) return UHS_HOST_ERROR_BAD_ARGUMENT;
726 726
         if(!pep) return UHS_HOST_ERROR_NULL_EPINFO;
727 727
         *left = ucd->wTotalLength;
@@ -837,7 +837,7 @@ uint8_t UHS_USB_HOST_BASE::getNextInterface(ENUMERATION_INFO *ei, UHS_EpInfo *pe
837 837
         return rcode;
838 838
 }
839 839
 
840
-uint8_t UHS_USB_HOST_BASE::seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_FD_CONFIGURATION_DESCRIPTOR *ucd) {
840
+uint8_t UHS_USB_HOST_BASE::seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_CONFIGURATION_DESCRIPTOR *ucd) {
841 841
         if(!ei || !ucd) return UHS_HOST_ERROR_BAD_ARGUMENT;
842 842
         uint8_t data[ei->bMaxPacketSize0];
843 843
         UHS_EpInfo *pep;

+ 4
- 4
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usb_ch9.h View File

@@ -164,7 +164,7 @@ typedef struct {
164 164
         uint8_t iProduct; // Index of String Descriptor describing the product.
165 165
         uint8_t iSerialNumber; // Index of String Descriptor with the device's serial number.
166 166
         uint8_t bNumConfigurations; // Number of possible configurations.
167
-} __attribute__((packed)) USB_FD_DEVICE_DESCRIPTOR;
167
+} __attribute__((packed)) USB_DEVICE_DESCRIPTOR;
168 168
 
169 169
 /* Configuration descriptor structure */
170 170
 typedef struct {
@@ -176,7 +176,7 @@ typedef struct {
176 176
         uint8_t iConfiguration; // Index of String Descriptor describing the configuration.
177 177
         uint8_t bmAttributes; // Configuration characteristics.
178 178
         uint8_t bMaxPower; // Maximum power consumed by this configuration.
179
-} __attribute__((packed)) USB_FD_CONFIGURATION_DESCRIPTOR;
179
+} __attribute__((packed)) USB_CONFIGURATION_DESCRIPTOR;
180 180
 
181 181
 /* Interface descriptor structure */
182 182
 typedef struct {
@@ -189,7 +189,7 @@ typedef struct {
189 189
         uint8_t bInterfaceSubClass; // Subclass code (assigned by the USB-IF).
190 190
         uint8_t bInterfaceProtocol; // Protocol code (assigned by the USB-IF).  0xFF-Vendor specific.
191 191
         uint8_t iInterface; // Index of String Descriptor describing the interface.
192
-} __attribute__((packed)) USB_FD_INTERFACE_DESCRIPTOR;
192
+} __attribute__((packed)) USB_INTERFACE_DESCRIPTOR;
193 193
 
194 194
 /* Endpoint descriptor structure */
195 195
 typedef struct {
@@ -199,7 +199,7 @@ typedef struct {
199 199
         uint8_t bmAttributes; // Endpoint transfer type.
200 200
         uint16_t wMaxPacketSize; // Maximum packet size.
201 201
         uint8_t bInterval; // Polling interval in frames.
202
-} __attribute__((packed)) USB_FD_ENDPOINT_DESCRIPTOR;
202
+} __attribute__((packed)) USB_ENDPOINT_DESCRIPTOR;
203 203
 
204 204
 /* HID descriptor */
205 205
 /*

+ 2
- 2
Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/UHS_usbhost.h View File

@@ -207,7 +207,7 @@ public:
207 207
                 interrupts();
208 208
         }
209 209
 
210
-        uint8_t UHS_NI seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_FD_CONFIGURATION_DESCRIPTOR *ucd);
210
+        uint8_t UHS_NI seekInterface(ENUMERATION_INFO *ei, uint16_t inf, USB_CONFIGURATION_DESCRIPTOR *ucd);
211 211
 
212 212
         uint8_t UHS_NI setEpInfoEntry(uint8_t addr, uint8_t iface, uint8_t epcount, volatile UHS_EpInfo* eprecord_ptr);
213 213
 
@@ -261,7 +261,7 @@ public:
261 261
         uint8_t TestInterface(ENUMERATION_INFO *ei);
262 262
         uint8_t enumerateInterface(ENUMERATION_INFO *ei);
263 263
         uint8_t getNextInterface(ENUMERATION_INFO *ei, UHS_EpInfo *pep, uint8_t data[], uint16_t *left, uint16_t *read, uint8_t *offset);
264
-        uint8_t initDescrStream(ENUMERATION_INFO *ei, USB_FD_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset);
264
+        uint8_t initDescrStream(ENUMERATION_INFO *ei, USB_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset);
265 265
         uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data);
266 266
         uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data);
267 267
         uint8_t doSoftReset(uint8_t parent, uint8_t port, uint8_t address);

+ 64
- 0
buildroot/share/PlatformIO/boards/LERDGE.json View File

@@ -0,0 +1,64 @@
1
+{
2
+  "build": {
3
+    "core": "stm32",
4
+    "cpu": "cortex-m4",
5
+    "extra_flags": "-DSTM32F407xx",
6
+    "f_cpu": "168000000L",
7
+    "hwids": [
8
+      [
9
+        "0x1EAF",
10
+        "0x0003"
11
+      ],
12
+      [
13
+        "0x0483",
14
+        "0x3748"
15
+      ]
16
+    ],
17
+    "mcu": "stm32f407zgt6",
18
+    "variant": "LERDGE"
19
+  },
20
+  "debug": {
21
+    "jlink_device": "STM32F407ZG",
22
+    "openocd_target": "stm32f4x",
23
+    "svd_path": "STM32F40x.svd",
24
+    "tools": {
25
+      "stlink": {
26
+        "server": {
27
+          "arguments": [
28
+            "-f",
29
+            "scripts/interface/stlink.cfg",
30
+            "-c",
31
+            "transport select hla_swd",
32
+            "-f",
33
+            "scripts/target/stm32f4x.cfg",
34
+            "-c",
35
+            "reset_config none"
36
+          ],
37
+          "executable": "bin/openocd",
38
+          "package": "tool-openocd"
39
+        }
40
+      }
41
+    }
42
+  },
43
+  "frameworks": [
44
+    "arduino",
45
+    "stm32cube"
46
+  ],
47
+  "name": "STM32F407ZGT6(192k RAM. 1024k Flash)",
48
+  "upload": {
49
+    "disable_flushing": false,
50
+    "maximum_ram_size": 196608,
51
+    "maximum_size": 1048576,
52
+    "protocol": "stlink",
53
+    "protocols": [
54
+      "stlink",
55
+      "dfu",
56
+      "jlink"
57
+    ],
58
+    "require_upload_port": true,
59
+    "use_1200bps_touch": false,
60
+    "wait_for_upload_port": false
61
+  },
62
+  "url": "http://www.st.com/en/microcontrollers/stm32f407ZG.html",
63
+  "vendor": "Generic"
64
+}

+ 186
- 0
buildroot/share/PlatformIO/ldscripts/lerdge.ld View File

@@ -0,0 +1,186 @@
1
+/*
2
+*****************************************************************************
3
+**
4
+**  File        : LinkerScript.ld
5
+**
6
+**  Abstract    : Linker script for STM32F407VGTx Device with
7
+**                1024KByte FLASH, 128KByte RAM
8
+**
9
+**                Set heap size, stack size and stack location according
10
+**                to application requirements.
11
+**
12
+**                Set memory bank area and size if external memory is used.
13
+**
14
+**  Target      : STMicroelectronics STM32
15
+**
16
+**
17
+**  Distribution: The file is distributed as is, without any warranty
18
+**                of any kind.
19
+**
20
+**  (c)Copyright Ac6.
21
+**  You may use this file as-is or modify it according to the needs of your
22
+**  project. Distribution of this file (unmodified or modified) is not
23
+**  permitted. Ac6 permit registered System Workbench for MCU users the
24
+**  rights to distribute the assembled, compiled & linked contents of this
25
+**  file as part of an application binary file, provided that it is built
26
+**  using the System Workbench for MCU toolchain.
27
+**
28
+*****************************************************************************
29
+*/
30
+
31
+/* Entry Point */
32
+ENTRY(Reset_Handler)
33
+
34
+/* Highest address of the user mode stack */
35
+_estack = 0x20010000;    /* end of RAM */
36
+/* Generate a link error if heap and stack don't fit into RAM */
37
+_Min_Heap_Size = 0x200;;      /* required amount of heap  */
38
+_Min_Stack_Size = 0x400;; /* required amount of stack */
39
+
40
+/* Specify the memory areas */
41
+MEMORY
42
+{
43
+FLASH (rx)      : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET
44
+RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE
45
+CCMRAM (rw)      : ORIGIN = 0x10000000, LENGTH = 64K
46
+}
47
+
48
+/* Define output sections */
49
+SECTIONS
50
+{
51
+  /* The startup code goes first into FLASH */
52
+  .isr_vector :
53
+  {
54
+    . = ALIGN(4);
55
+    KEEP(*(.isr_vector)) /* Startup code */
56
+    . = ALIGN(4);
57
+  } >FLASH
58
+
59
+  /* The program code and other data goes into FLASH */
60
+  .text ALIGN(4):
61
+  {
62
+    . = ALIGN(4);
63
+    *(.text)           /* .text sections (code) */
64
+    *(.text*)          /* .text* sections (code) */
65
+    *(.glue_7)         /* glue arm to thumb code */
66
+    *(.glue_7t)        /* glue thumb to arm code */
67
+    *(.eh_frame)
68
+
69
+    KEEP (*(.init))
70
+    KEEP (*(.fini))
71
+
72
+    . = ALIGN(4);
73
+    _etext = .;        /* define a global symbols at end of code */
74
+  } >FLASH
75
+
76
+  /* Constant data goes into FLASH */
77
+  .rodata ALIGN(4):
78
+  {
79
+    . = ALIGN(4);
80
+    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
81
+    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
82
+    . = ALIGN(4);
83
+  } >FLASH
84
+
85
+  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
86
+  .ARM : {
87
+    __exidx_start = .;
88
+    *(.ARM.exidx*)
89
+    __exidx_end = .;
90
+  } >FLASH
91
+
92
+  .preinit_array     :
93
+  {
94
+    PROVIDE_HIDDEN (__preinit_array_start = .);
95
+    KEEP (*(.preinit_array*))
96
+    PROVIDE_HIDDEN (__preinit_array_end = .);
97
+  } >FLASH
98
+  .init_array :
99
+  {
100
+    PROVIDE_HIDDEN (__init_array_start = .);
101
+    KEEP (*(SORT(.init_array.*)))
102
+    KEEP (*(.init_array*))
103
+    PROVIDE_HIDDEN (__init_array_end = .);
104
+  } >FLASH
105
+  .fini_array :
106
+  {
107
+    PROVIDE_HIDDEN (__fini_array_start = .);
108
+    KEEP (*(SORT(.fini_array.*)))
109
+    KEEP (*(.fini_array*))
110
+    PROVIDE_HIDDEN (__fini_array_end = .);
111
+  } >FLASH
112
+
113
+  /* used by the startup to initialize data */
114
+  _sidata = LOADADDR(.data);
115
+
116
+  /* Initialized data sections goes into RAM, load LMA copy after code */
117
+  .data :
118
+  {
119
+    . = ALIGN(4);
120
+    _sdata = .;        /* create a global symbol at data start */
121
+    *(.data)           /* .data sections */
122
+    *(.data*)          /* .data* sections */
123
+
124
+    . = ALIGN(4);
125
+    _edata = .;        /* define a global symbol at data end */
126
+  } >RAM AT> FLASH
127
+
128
+  _siccmram = LOADADDR(.ccmram);
129
+
130
+  /* CCM-RAM section
131
+  *
132
+  * IMPORTANT NOTE!
133
+  * If initialized variables will be placed in this section,
134
+  * the startup code needs to be modified to copy the init-values.
135
+  */
136
+  .ccmram :
137
+  {
138
+    . = ALIGN(4);
139
+    _sccmram = .;       /* create a global symbol at ccmram start */
140
+    *(.ccmram)
141
+    *(.ccmram*)
142
+
143
+    . = ALIGN(4);
144
+    _eccmram = .;       /* create a global symbol at ccmram end */
145
+  } >CCMRAM AT> FLASH
146
+
147
+
148
+  /* Uninitialized data section */
149
+  . = ALIGN(4);
150
+  .bss :
151
+  {
152
+    /* This is used by the startup in order to initialize the .bss secion */
153
+    _sbss = .;         /* define a global symbol at bss start */
154
+    __bss_start__ = _sbss;
155
+    *(.bss)
156
+    *(.bss*)
157
+    *(COMMON)
158
+
159
+    . = ALIGN(4);
160
+    _ebss = .;         /* define a global symbol at bss end */
161
+    __bss_end__ = _ebss;
162
+  } >RAM
163
+
164
+  /* User_heap_stack section, used to check that there is enough RAM left */
165
+  ._user_heap_stack :
166
+  {
167
+    . = ALIGN(4);
168
+    PROVIDE ( end = . );
169
+    PROVIDE ( _end = . );
170
+    . = . + _Min_Heap_Size;
171
+    . = . + _Min_Stack_Size;
172
+    . = ALIGN(4);
173
+  } >RAM
174
+
175
+
176
+
177
+  /* Remove information from the standard libraries */
178
+  /DISCARD/ :
179
+  {
180
+    libc.a ( * )
181
+    libm.a ( * )
182
+    libgcc.a ( * )
183
+  }
184
+
185
+  .ARM.attributes 0 : { *(.ARM.attributes) }
186
+}

+ 47
- 0
buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py View File

@@ -0,0 +1,47 @@
1
+import os,shutil
2
+from SCons.Script import DefaultEnvironment
3
+from platformio import util
4
+
5
+def copytree(src, dst, symlinks=False, ignore=None):
6
+    for item in os.listdir(src):
7
+        s = os.path.join(src, item)
8
+        d = os.path.join(dst, item)
9
+        if os.path.isdir(s):
10
+            shutil.copytree(s, d, symlinks, ignore)
11
+        else:
12
+            shutil.copy2(s, d)
13
+
14
+env = DefaultEnvironment()
15
+platform = env.PioPlatform()
16
+board = env.BoardConfig()
17
+variant = board.get("build.variant")
18
+variant_dir = ' +<buildroot/share/PlatformIO/variants/' + variant + '>';
19
+src_filter = env.get("SRC_FILTER")
20
+print("Starting SRC Filter:", env.get("SRC_FILTER"))
21
+src_filter_value = src_filter[0];
22
+
23
+src_filter_value = src_filter_value + variant_dir
24
+src_filter[0] = src_filter_value;
25
+env["SRC_FILTER"] = src_filter
26
+
27
+print("Modified SRC Filter:", env.get("SRC_FILTER"))
28
+
29
+cxx_flags = env['CXXFLAGS']
30
+print("CXXFLAGS", cxx_flags)
31
+
32
+FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32")
33
+assert os.path.isdir(FRAMEWORK_DIR)
34
+assert os.path.isdir("buildroot/share/PlatformIO/variants")
35
+
36
+variant_dir = os.path.join(FRAMEWORK_DIR, "variants", variant)
37
+
38
+source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant)
39
+assert os.path.isdir(source_dir)
40
+
41
+if os.path.isdir(variant_dir):
42
+    shutil.rmtree(variant_dir)
43
+
44
+if not os.path.isdir(variant_dir):
45
+    os.mkdir(variant_dir)
46
+
47
+copytree(source_dir, variant_dir)

+ 46
- 0
buildroot/share/PlatformIO/scripts/lerdge.py View File

@@ -0,0 +1,46 @@
1
+import os,sys
2
+Import("env")
3
+
4
+from SCons.Script import DefaultEnvironment
5
+board = DefaultEnvironment().BoardConfig()
6
+
7
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/lerdge.ld")
8
+for i, flag in enumerate(env["LINKFLAGS"]):
9
+    if "-Wl,-T" in flag:
10
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
11
+    elif flag == "-T":
12
+        env["LINKFLAGS"][i + 1] = custom_ld_script
13
+
14
+def encryptByte(byte):
15
+    byte = 0xFF & ((byte << 6) | (byte >> 2))
16
+    i = 0x58 + byte
17
+    j = 0x05 + byte + (i >> 8)
18
+    byte = (0xF8 & i) | (0x07 & j)
19
+    return byte
20
+
21
+def encrypt_file(input, output_file, file_length):
22
+    input_file = bytearray(input.read())
23
+    for i in range(len(input_file)):
24
+        result = encryptByte(input_file[i])
25
+        input_file[i] = result
26
+
27
+    output_file.write(input_file)
28
+    return
29
+
30
+# Encrypt ${PROGNAME}.bin and save it as build.firmware
31
+def encrypt(source, target, env):
32
+    print("Encrypting to:", board.get("build.firmware"))
33
+    firmware = open(target[0].path, "rb")
34
+    result = open(target[0].dir.path + "/" + board.get("build.firmware"), "wb")
35
+    length = os.path.getsize(target[0].path)
36
+
37
+    encrypt_file(firmware, result, length)
38
+
39
+    firmware.close()
40
+    result.close()
41
+
42
+if 'firmware' in board.get("build").keys():
43
+  env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
44
+else:
45
+  print("You need to define output file via board_build.firmware = 'filename' parameter")
46
+  exit(1);

+ 30
- 0
buildroot/share/PlatformIO/scripts/stm32_bootloader.py View File

@@ -0,0 +1,30 @@
1
+import os,sys,shutil
2
+Import("env")
3
+
4
+from SCons.Script import DefaultEnvironment
5
+board = DefaultEnvironment().BoardConfig()
6
+
7
+def noencrypt(source, target, env):
8
+  firmware = os.path.join(target[0].dir.path, board.get("build.firmware"))
9
+  # do not overwrite encrypted firmware if present
10
+  if not os.path.isfile(firmware):
11
+    shutil.copy(target[0].path, firmware)
12
+
13
+if 'offset' in board.get("build").keys():
14
+  LD_FLASH_OFFSET = board.get("build.offset")
15
+
16
+  for define in env['CPPDEFINES']:
17
+    if define[0] == "VECT_TAB_OFFSET":
18
+      env['CPPDEFINES'].remove(define)
19
+  env['CPPDEFINES'].append(("VECT_TAB_OFFSET", LD_FLASH_OFFSET))
20
+
21
+  maximum_ram_size = board.get("upload.maximum_ram_size")
22
+
23
+  for i, flag in enumerate(env["LINKFLAGS"]):
24
+    if "-Wl,--defsym=LD_FLASH_OFFSET" in flag:
25
+      env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET
26
+    if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag:
27
+      env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40)
28
+
29
+  if 'firmware' in board.get("build").keys():
30
+    env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", noencrypt);

+ 418
- 0
buildroot/share/PlatformIO/variants/LERDGE/PeripheralPins.c View File

@@ -0,0 +1,418 @@
1
+/*
2
+ *******************************************************************************
3
+ * Copyright (c) 2019, STMicroelectronics
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above copyright notice,
10
+ *    this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ *    this list of conditions and the following disclaimer in the documentation
13
+ *    and/or other materials provided with the distribution.
14
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
15
+ *    may be used to endorse or promote products derived from this software
16
+ *    without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ *******************************************************************************
29
+ * Automatically generated from STM32F407Z(E-G)Tx.xml
30
+ */
31
+#include <Arduino.h>
32
+#include <PeripheralPins.h>
33
+
34
+/* =====
35
+ * Note: Commented lines are alternative possibilities which are not used per default.
36
+ *       If you change them, you will have to know what you do
37
+ * =====
38
+ */
39
+
40
+//*** ADC ***
41
+
42
+#ifdef HAL_ADC_MODULE_ENABLED
43
+const PinMap PinMap_ADC[] = {
44
+  {PA_0,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0
45
+  //{PA_0,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0
46
+  //{PA_0,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0
47
+  {PA_1,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1
48
+  //{PA_1,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1
49
+  //{PA_1,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1
50
+  //{PA_2,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2
51
+  {PA_2,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2
52
+  //{PA_2,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2
53
+  //{PA_3,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3
54
+  //{PA_3,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3
55
+  {PA_3,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3
56
+  {PA_4,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4
57
+  //{PA_4,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4
58
+  //{PA_5,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5
59
+  {PA_5,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5
60
+  {PA_6,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6
61
+  //{PA_6,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6
62
+  {PA_7,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7
63
+  //{PA_7,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7
64
+  //{PB_0,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8
65
+  {PB_0,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8
66
+  {PB_1,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9
67
+  //{PB_1,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9
68
+  //{PC_0,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10
69
+  //{PC_0,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10
70
+  {PC_0,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10
71
+  {PC_1,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11
72
+  //{PC_1,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11
73
+  //{PC_1,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11
74
+  //{PC_2,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12
75
+  {PC_2,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12
76
+  //{PC_2,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12
77
+  //{PC_3,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13
78
+  //{PC_3,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13
79
+  {PC_3,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13
80
+  //{PC_4,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14
81
+  {PC_4,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14
82
+  //{PC_5,  ADC1,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15
83
+  {PC_5,  ADC2,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15
84
+  {PF_3,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9
85
+  {PF_4,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC3_IN14
86
+  {PF_5,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_IN15
87
+  {PF_6,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4
88
+  {PF_7,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5
89
+  {PF_8,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6
90
+  //{PF_9,  ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC3_IN7
91
+  {PF_10, ADC3,  STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC3_IN8
92
+  {NC,    NP,    0}
93
+};
94
+#endif
95
+
96
+//*** DAC ***
97
+
98
+#ifdef HAL_DAC_MODULE_ENABLED
99
+const PinMap PinMap_DAC[] = {
100
+  {PA_4,  DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1
101
+  {PA_5,  DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2
102
+  {NC,    NP,    0}
103
+};
104
+#endif
105
+
106
+//*** I2C ***
107
+
108
+#ifdef HAL_I2C_MODULE_ENABLED
109
+const PinMap PinMap_I2C_SDA[] = {
110
+  {PB_7,  I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
111
+  {PB_9,  I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
112
+  {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
113
+  {PC_9,  I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
114
+  {PF_0,  I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
115
+  {NC,    NP,    0}
116
+};
117
+#endif
118
+
119
+#ifdef HAL_I2C_MODULE_ENABLED
120
+const PinMap PinMap_I2C_SCL[] = {
121
+  {PA_8,  I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)},
122
+  {PB_6,  I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
123
+  {PB_8,  I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
124
+  {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
125
+  {PF_1,  I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
126
+  {NC,    NP,    0}
127
+};
128
+#endif
129
+
130
+//*** PWM ***
131
+
132
+#ifdef HAL_TIM_MODULE_ENABLED
133
+const PinMap PinMap_PWM[] = {
134
+  {PA_0,  TIM2,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
135
+  //{PA_0,  TIM5,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1
136
+  {PA_1,  TIM2,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
137
+  //{PA_1,  TIM5,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2
138
+  {PA_2,  TIM2,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3
139
+  //{PA_2,  TIM5,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3
140
+  //{PA_2,  TIM9,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1
141
+  {PA_3,  TIM2,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4
142
+  //{PA_3,  TIM5,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4
143
+  //{PA_3,  TIM9,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2
144
+  {PA_5,  TIM2,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
145
+  //{PA_5,  TIM8,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N
146
+  {PA_6,  TIM3,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
147
+  //{PA_6,  TIM13,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1
148
+  //{PA_7,  TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
149
+  {PA_7,  TIM3,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
150
+  //{PA_7,  TIM8,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N
151
+  //{PA_7,  TIM14,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1
152
+  {PA_8,  TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
153
+  {PA_9,  TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2
154
+  {PA_10, TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3
155
+  {PA_11, TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
156
+  //{PA_15, TIM2,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1
157
+  //{PB_0,  TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
158
+  {PB_0,  TIM3,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
159
+  //{PB_0,  TIM8,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N
160
+  //{PB_1,  TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
161
+  {PB_1,  TIM3,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
162
+  //{PB_1,  TIM8,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N
163
+  //{PB_3,  TIM2,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2
164
+  {PB_4,  TIM3,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
165
+  {PB_5,  TIM3,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
166
+  {PB_6,  TIM4,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1
167
+  {PB_7,  TIM4,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2
168
+  {PB_8,  TIM4,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3
169
+  {PB_8,  TIM10,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1
170
+  {PB_9,  TIM4,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4
171
+  {PB_9,  TIM11,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1
172
+  {PB_10, TIM2,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3
173
+  {PB_11, TIM2,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4
174
+  {PB_13, TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
175
+  {PB_14, TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
176
+  {PB_14, TIM8,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N
177
+  {PB_14, TIM12,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1
178
+  {PB_15, TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
179
+  {PB_15, TIM8,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N
180
+  {PB_15, TIM12,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2
181
+  {PC_6,  TIM3,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1
182
+  {PC_6,  TIM8,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1
183
+  {PC_7,  TIM3,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2
184
+  {PC_7,  TIM8,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2
185
+  {PC_8,  TIM3,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3
186
+  {PC_8,  TIM8,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3
187
+  {PC_9,  TIM3,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4
188
+  {PC_9,  TIM8,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4
189
+  {PD_12, TIM4,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1
190
+  {PD_13, TIM4,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2
191
+  {PD_14, TIM4,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3
192
+  {PD_15, TIM4,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4
193
+  {PE_5,  TIM9,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1
194
+  {PE_6,  TIM9,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2
195
+  {PE_8,  TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N
196
+  {PE_9,  TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1
197
+  {PE_10, TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N
198
+  {PE_11, TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2
199
+  {PE_12, TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N
200
+  {PE_13, TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3
201
+  {PE_14, TIM1,   STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4
202
+  {PF_6,  TIM10,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1
203
+  {PF_7,  TIM11,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1
204
+  {PF_8,  TIM13,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1
205
+  {PF_9,  TIM14,  STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1
206
+  {NC,    NP,    0}
207
+};
208
+#endif
209
+
210
+//*** SERIAL ***
211
+
212
+#ifdef HAL_UART_MODULE_ENABLED
213
+const PinMap PinMap_UART_TX[] = {
214
+  {PA_0,  UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
215
+  {PA_2,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
216
+  {PA_9,  USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
217
+  {PB_6,  USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
218
+  {PB_10, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
219
+  {PC_6,  USART6,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
220
+  //{PC_10, UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
221
+  {PC_10, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
222
+  {PC_12, UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
223
+  {PD_5,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
224
+  {PD_8,  USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
225
+  {PG_14, USART6,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
226
+  {NC,    NP,    0}
227
+};
228
+#endif
229
+
230
+#ifdef HAL_UART_MODULE_ENABLED
231
+const PinMap PinMap_UART_RX[] = {
232
+  {PA_1,  UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
233
+  {PA_3,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
234
+  {PA_10, USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
235
+  {PB_7,  USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
236
+  {PB_11, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
237
+  {PC_7,  USART6,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
238
+  //{PC_11, UART4,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)},
239
+  {PC_11, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
240
+  {PD_2,  UART5,   STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)},
241
+  {PD_6,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
242
+  {PD_9,  USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
243
+  {PG_9,  USART6,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
244
+  {NC,    NP,    0}
245
+};
246
+#endif
247
+
248
+#ifdef HAL_UART_MODULE_ENABLED
249
+const PinMap PinMap_UART_RTS[] = {
250
+  {PA_1,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
251
+  {PA_12, USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
252
+  {PB_14, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
253
+  {PD_4,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
254
+  {PD_12, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
255
+  {PG_8,  USART6,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
256
+  {PG_12, USART6,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
257
+  {NC,    NP,    0}
258
+};
259
+#endif
260
+
261
+#ifdef HAL_UART_MODULE_ENABLED
262
+const PinMap PinMap_UART_CTS[] = {
263
+  {PA_0,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
264
+  {PA_11, USART1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
265
+  {PB_13, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
266
+  {PD_3,  USART2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
267
+  {PD_11, USART3,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
268
+  {PG_13, USART6,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
269
+  {PG_15, USART6,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)},
270
+  {NC,    NP,    0}
271
+};
272
+#endif
273
+
274
+//*** SPI ***
275
+
276
+#ifdef HAL_SPI_MODULE_ENABLED
277
+const PinMap PinMap_SPI_MOSI[] = {
278
+  {PA_7,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
279
+  {PB_5,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
280
+  {PB_5,  SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
281
+  {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
282
+  {PC_3,  SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
283
+  {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
284
+  {NC,    NP,    0}
285
+};
286
+#endif
287
+
288
+#ifdef HAL_SPI_MODULE_ENABLED
289
+const PinMap PinMap_SPI_MISO[] = {
290
+  {PA_6,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
291
+  {PB_4,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
292
+  {PB_4,  SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
293
+  {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
294
+  {PC_2,  SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
295
+  {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
296
+  {NC,    NP,    0}
297
+};
298
+#endif
299
+
300
+#ifdef HAL_SPI_MODULE_ENABLED
301
+const PinMap PinMap_SPI_SCLK[] = {
302
+  {PA_5,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
303
+  {PB_3,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
304
+  {PB_3,  SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
305
+  {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
306
+  {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
307
+  {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
308
+  {NC,    NP,    0}
309
+};
310
+#endif
311
+
312
+#ifdef HAL_SPI_MODULE_ENABLED
313
+const PinMap PinMap_SPI_SSEL[] = {
314
+  {PA_4,  SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
315
+  {PA_4,  SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
316
+  {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
317
+  {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
318
+  {PB_9,  SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
319
+  {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
320
+  {NC,    NP,    0}
321
+};
322
+#endif
323
+
324
+//*** CAN ***
325
+
326
+#ifdef HAL_CAN_MODULE_ENABLED
327
+const PinMap PinMap_CAN_RD[] = {
328
+  {PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
329
+  {PB_5,  CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
330
+  {PB_8,  CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
331
+  {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
332
+  {PD_0,  CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
333
+  {NC,    NP,    0}
334
+};
335
+#endif
336
+
337
+#ifdef HAL_CAN_MODULE_ENABLED
338
+const PinMap PinMap_CAN_TD[] = {
339
+  {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
340
+  {PB_6,  CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
341
+  {PB_9,  CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
342
+  {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
343
+  {PD_1,  CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
344
+  {NC,    NP,    0}
345
+};
346
+#endif
347
+
348
+//*** ETHERNET ***
349
+
350
+#ifdef HAL_ETH_MODULE_ENABLED
351
+const PinMap PinMap_Ethernet[] = {
352
+  {PA_0,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS
353
+  {PA_1,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_REF_CLK|ETH_RX_CLK
354
+  {PA_2,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDIO
355
+  {PA_3,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_COL
356
+  {PA_7,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS_DV|ETH_RX_DV
357
+  {PB_0,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD2
358
+  {PB_1,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD3
359
+  {PB_5,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT
360
+  {PB_8,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3
361
+  {PB_10, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_ER
362
+  {PB_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN
363
+  {PB_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0
364
+  {PB_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1
365
+  {PC_1,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDC
366
+  {PC_2,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD2
367
+  {PC_3,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_CLK
368
+  {PC_4,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD0
369
+  {PC_5,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD1
370
+  {PE_2,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3
371
+  {PG_8,  ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT
372
+  {PG_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN
373
+  {PG_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0
374
+  {PG_14, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1
375
+  {NC,    NP,    0}
376
+};
377
+#endif
378
+
379
+//*** No QUADSPI ***
380
+
381
+//*** USB ***
382
+
383
+#ifdef HAL_PCD_MODULE_ENABLED
384
+const PinMap PinMap_USB_OTG_FS[] = {
385
+  //{PA_8,  USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF
386
+  //{PA_9,  USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS
387
+  //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID
388
+  {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM
389
+  {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP
390
+  {NC,    NP,    0}
391
+};
392
+#endif
393
+
394
+#ifdef HAL_PCD_MODULE_ENABLED
395
+const PinMap PinMap_USB_OTG_HS[] = {
396
+#ifdef USE_USB_HS_IN_FS
397
+  {PA_4,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF
398
+  {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID
399
+  {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS
400
+  {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM
401
+  {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP
402
+#else
403
+  {PA_3,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0
404
+  {PA_5,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_CK
405
+  {PB_0,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1
406
+  {PB_1,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2
407
+  {PB_5,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7
408
+  {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3
409
+  {PB_11, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D4
410
+  {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5
411
+  {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6
412
+  {PC_0,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP
413
+  {PC_2,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR
414
+  {PC_3,  USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT
415
+#endif /* USE_USB_HS_IN_FS */
416
+  {NC,    NP,    0}
417
+};
418
+#endif

+ 50
- 0
buildroot/share/PlatformIO/variants/LERDGE/PinNamesVar.h View File

@@ -0,0 +1,50 @@
1
+/* SYS_WKUP */
2
+#ifdef PWR_WAKEUP_PIN1
3
+  SYS_WKUP1 = PA_0,
4
+#endif
5
+#ifdef PWR_WAKEUP_PIN2
6
+  SYS_WKUP2 = NC,
7
+#endif
8
+#ifdef PWR_WAKEUP_PIN3
9
+  SYS_WKUP3 = NC,
10
+#endif
11
+#ifdef PWR_WAKEUP_PIN4
12
+  SYS_WKUP4 = NC,
13
+#endif
14
+#ifdef PWR_WAKEUP_PIN5
15
+  SYS_WKUP5 = NC,
16
+#endif
17
+#ifdef PWR_WAKEUP_PIN6
18
+  SYS_WKUP6 = NC,
19
+#endif
20
+#ifdef PWR_WAKEUP_PIN7
21
+  SYS_WKUP7 = NC,
22
+#endif
23
+#ifdef PWR_WAKEUP_PIN8
24
+  SYS_WKUP8 = NC,
25
+#endif
26
+/* USB */
27
+#ifdef USBCON
28
+  USB_OTG_FS_SOF      = PA_8,
29
+  USB_OTG_FS_VBUS     = PA_9,
30
+  USB_OTG_FS_ID       = PA_10,
31
+  USB_OTG_FS_DM       = PA_11,
32
+  USB_OTG_FS_DP       = PA_12,
33
+  USB_OTG_HS_ULPI_D0  = PA_3,
34
+  USB_OTG_HS_SOF      = PA_4,
35
+  USB_OTG_HS_ULPI_CK  = PA_5,
36
+  USB_OTG_HS_ULPI_D1  = PB_0,
37
+  USB_OTG_HS_ULPI_D2  = PB_1,
38
+  USB_OTG_HS_ULPI_D7  = PB_5,
39
+  USB_OTG_HS_ULPI_D3  = PB_10,
40
+  USB_OTG_HS_ULPI_D4  = PB_11,
41
+  USB_OTG_HS_ID       = PB_12,
42
+  USB_OTG_HS_ULPI_D5  = PB_12,
43
+  USB_OTG_HS_ULPI_D6  = PB_13,
44
+  USB_OTG_HS_VBUS     = PB_13,
45
+  USB_OTG_HS_DM       = PB_14,
46
+  USB_OTG_HS_DP       = PB_15,
47
+  USB_OTG_HS_ULPI_STP = PC_0,
48
+  USB_OTG_HS_ULPI_DIR = PC_2,
49
+  USB_OTG_HS_ULPI_NXT = PC_3,
50
+#endif

+ 297
- 0
buildroot/share/PlatformIO/variants/LERDGE/variant.cpp View File

@@ -0,0 +1,297 @@
1
+/*
2
+ *******************************************************************************
3
+ * Copyright (c) 2017, STMicroelectronics
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above copyright notice,
10
+ *    this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ *    this list of conditions and the following disclaimer in the documentation
13
+ *    and/or other materials provided with the distribution.
14
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
15
+ *    may be used to endorse or promote products derived from this software
16
+ *    without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ *******************************************************************************
29
+ */
30
+
31
+#include "pins_arduino.h"
32
+
33
+#ifdef __cplusplus
34
+extern "C" {
35
+#endif
36
+
37
+
38
+const PinName digitalPin[] = {
39
+ PB_12,
40
+ PB_13,
41
+ PB_14,
42
+ PB_15,
43
+ PD_8,
44
+ PD_9,
45
+ PD_10,
46
+ PD_11,
47
+ PD_12,
48
+ PD_13,
49
+ PD_14,
50
+ PD_15,
51
+ PG_2,
52
+ PG_3,
53
+ PG_4,
54
+ PG_5,
55
+ PG_6,
56
+ PG_7,
57
+ PG_8,
58
+ PC_6,
59
+ PC_7,
60
+ PC_8,
61
+ PC_9,
62
+ PA_8,
63
+ PA_9,
64
+ PA_10,
65
+ PA_11,
66
+ PA_12,
67
+ PA_13,
68
+ PA_14,
69
+ PA_15,
70
+ PC_10,
71
+ PC_11,
72
+ PC_12,
73
+ PD_0,
74
+ PD_1,
75
+ PD_2,
76
+ PD_3,
77
+ PD_4,
78
+ PD_5,
79
+ PD_6,
80
+ PD_7,
81
+ PG_9,
82
+ PG_10,
83
+ PG_11,
84
+ PG_12,
85
+ PG_13,
86
+ PG_14,
87
+ PG_15,
88
+ PB_3,
89
+ PB_4,
90
+ PB_5,
91
+ PB_6,
92
+ PB_7,
93
+ PB_8,
94
+ PB_9,
95
+ PB_10,
96
+ PB_11,
97
+ PE_14,
98
+ PE_15,
99
+ PE_12,
100
+ PE_13,
101
+ PE_10,
102
+ PE_11,
103
+ PE_8,
104
+ PE_9,
105
+ PG_1,
106
+ PE_7,
107
+ PF_15,
108
+ PG_0,
109
+ PF_13,
110
+ PF_14,
111
+ PF_11,
112
+ PF_12,
113
+ PB_2,
114
+ PB_1,
115
+ PC_5,
116
+ PB_0,
117
+ PA_7,
118
+ PC_4,
119
+ PA_5,
120
+ PA_6,
121
+ PA_3,
122
+ PA_4,
123
+ PA_1,
124
+ PA_2,
125
+ PC_3,
126
+ PA_0,
127
+ PC_1,
128
+ PC_2,
129
+ PC_0,
130
+ PF_8,
131
+ PF_6,
132
+ PF_7,
133
+ PF_9,
134
+ PF_10,
135
+ PF_4,
136
+ PF_5,
137
+ PF_2,
138
+ PF_3,
139
+ PF_0,
140
+ PF_1,
141
+ PE_6,
142
+ PC_13,
143
+ PE_4,
144
+ PE_5,
145
+ PE_2,
146
+ PE_3,
147
+ PE_0,
148
+ PE_1,
149
+ PC_14,
150
+ PC_15,
151
+};
152
+
153
+#ifdef __cplusplus
154
+}
155
+#endif
156
+
157
+// ----------------------------------------------------------------------------
158
+
159
+#ifdef __cplusplus
160
+extern "C" {
161
+#endif
162
+
163
+#define __fatal_error(X)
164
+
165
+
166
+/**
167
+  * @brief  System Clock Configuration
168
+  *
169
+  *         The system Clock is configured for F4/F7 as follows:
170
+  *            System Clock source            = PLL (HSE)
171
+  *            SYSCLK(Hz)                     = 168000000
172
+  *            HCLK(Hz)                       = 168000000
173
+  *            AHB Prescaler                  = 1
174
+  *            APB1 Prescaler                 = 4
175
+  *            APB2 Prescaler                 = 2
176
+  *            HSE Frequency(Hz)              = HSE_VALUE
177
+  *            PLL_M                          = HSE_VALUE/1000000
178
+  *            PLL_N                          = 336
179
+  *            PLL_P                          = 2
180
+  *            PLL_Q                          = 7
181
+  *            VDD(V)                         = 3.3
182
+  *            Main regulator output voltage  = Scale1 mode
183
+  *            Flash Latency(WS)              = 5
184
+  *
185
+  *         The system Clock is configured for L4 as follows:
186
+  *            System Clock source            = PLL (MSI)
187
+  *            SYSCLK(Hz)                     = 80000000
188
+  *            HCLK(Hz)                       = 80000000
189
+  *            AHB Prescaler                  = 1
190
+  *            APB1 Prescaler                 = 1
191
+  *            APB2 Prescaler                 = 1
192
+  *            MSI Frequency(Hz)              = MSI_VALUE (4000000)
193
+  *            LSE Frequency(Hz)              = 32768
194
+  *            PLL_M                          = 1
195
+  *            PLL_N                          = 40
196
+  *            PLL_P                          = 7
197
+  *            PLL_Q                          = 2
198
+  *            PLL_R                          = 2 <= This is the source for SysClk, not as on F4/7 PLL_P
199
+  *            Flash Latency(WS)              = 4
200
+  * @param  None
201
+  * @retval None
202
+  *
203
+  * PLL is configured as follows:
204
+  *
205
+  *     VCO_IN
206
+  *         F4/F7 = HSE / M
207
+  *         L4    = MSI / M
208
+  *     VCO_OUT
209
+  *         F4/F7 = HSE / M * N
210
+  *         L4    = MSI / M * N
211
+  *     PLLCLK
212
+  *         F4/F7 = HSE / M * N / P
213
+  *         L4    = MSI / M * N / R
214
+  *     PLL48CK
215
+  *         F4/F7 = HSE / M * N / Q
216
+  *         L4    = MSI / M * N / Q  USB Clock is obtained over PLLSAI1
217
+  *
218
+  *     SYSCLK = PLLCLK
219
+  *     HCLK   = SYSCLK / AHB_PRESC
220
+  *     PCLKx  = HCLK / APBx_PRESC
221
+  *
222
+  * Constraints on parameters:
223
+  *
224
+  *     VCO_IN between 1MHz and 2MHz (2MHz recommended)
225
+  *     VCO_OUT between 192MHz and 432MHz
226
+  *     HSE = 8MHz
227
+  *     M = 2 .. 63 (inclusive)
228
+  *     N = 192 ... 432 (inclusive)
229
+  *     P = 2, 4, 6, 8
230
+  *     Q = 2 .. 15 (inclusive)
231
+  *
232
+  *     AHB_PRESC=1,2,4,8,16,64,128,256,512
233
+  *     APBx_PRESC=1,2,4,8,16
234
+  *
235
+  * Output clocks:
236
+  *
237
+  * CPU             SYSCLK      max 168MHz
238
+  * USB,RNG,SDIO    PLL48CK     must be 48MHz for USB
239
+  * AHB             HCLK        max 168MHz
240
+  * APB1            PCLK1       max 42MHz
241
+  * APB2            PCLK2       max 84MHz
242
+  *
243
+  * Timers run from APBx if APBx_PRESC=1, else 2x APBx
244
+  */
245
+void SystemClock_Config(void)
246
+{
247
+    RCC_ClkInitTypeDef RCC_ClkInitStruct;
248
+    RCC_OscInitTypeDef RCC_OscInitStruct;
249
+
250
+    __PWR_CLK_ENABLE();
251
+
252
+    /* The voltage scaling allows optimizing the power consumption when the device is
253
+       clocked below the maximum system frequency, to update the voltage scaling value
254
+       regarding system frequency refer to product datasheet.  */
255
+    __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
256
+
257
+    /* Enable HSE Oscillator and activate PLL with HSE as source */
258
+    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
259
+    RCC_OscInitStruct.HSEState = RCC_HSE_ON;
260
+    RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
261
+    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
262
+    /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
263
+     clocks dividers */
264
+    RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
265
+    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
266
+
267
+    RCC_OscInitStruct.PLL.PLLM = 25;
268
+    RCC_OscInitStruct.PLL.PLLN = 336;
269
+    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
270
+    RCC_OscInitStruct.PLL.PLLQ = 7;
271
+
272
+    RCC_ClkInitStruct.AHBCLKDivider  = RCC_SYSCLK_DIV1;
273
+    RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
274
+    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
275
+
276
+    if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
277
+      __fatal_error("HAL_RCC_OscConfig");
278
+    }
279
+
280
+    if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
281
+    {
282
+      __fatal_error("HAL_RCC_ClockConfig");
283
+    }
284
+
285
+    /**Configure the Systick interrupt time */
286
+    HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000);
287
+
288
+    /**Configure the Systick */
289
+    HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
290
+
291
+    /* SysTick_IRQn interrupt configuration */
292
+    HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
293
+}
294
+
295
+#ifdef __cplusplus
296
+}
297
+#endif

+ 238
- 0
buildroot/share/PlatformIO/variants/LERDGE/variant.h View File

@@ -0,0 +1,238 @@
1
+/*
2
+ *******************************************************************************
3
+ * Copyright (c) 2017, STMicroelectronics
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above copyright notice,
10
+ *    this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ *    this list of conditions and the following disclaimer in the documentation
13
+ *    and/or other materials provided with the distribution.
14
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
15
+ *    may be used to endorse or promote products derived from this software
16
+ *    without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ *******************************************************************************
29
+ */
30
+
31
+#pragma once
32
+
33
+#ifdef __cplusplus
34
+extern "C" {
35
+#endif // __cplusplus
36
+
37
+/*----------------------------------------------------------------------------
38
+ *        Pins
39
+ *----------------------------------------------------------------------------*/
40
+
41
+// Left Side
42
+#define PB12 0
43
+#define PB13 1
44
+#define PB14 2
45
+#define PB15 3
46
+#define PD8  4
47
+#define PD9  5
48
+#define PD10 6
49
+#define PD11 7
50
+#define PD12 8
51
+#define PD13 9
52
+#define PD14 10
53
+#define PD15 11
54
+#define PG2  12
55
+#define PG3  13
56
+#define PG4  14
57
+#define PG5  15
58
+#define PG6  16
59
+#define PG7  17
60
+#define PG8  18
61
+#define PC6  19
62
+#define PC7  20
63
+#define PC8  21
64
+#define PC9  22
65
+#define PA8  23
66
+#define PA9  24
67
+#define PA10 25
68
+#define PA11 26 // USB_DM
69
+#define PA12 27 // USB_DP
70
+#define PA13 28
71
+#define PA14 29
72
+#define PA15 30
73
+#define PC10 31
74
+#define PC11 32
75
+#define PC12 33
76
+#define PD0  34
77
+#define PD1  35
78
+#define PD2  36
79
+#define PD3  37
80
+#define PD4  38
81
+#define PD5  39
82
+#define PD6  40
83
+#define PD7  41
84
+#define PG9  42
85
+#define PG10 43
86
+#define PG11 44
87
+#define PG12 45
88
+#define PG13 46
89
+#define PG14 47
90
+#define PG15 48
91
+#define PB3  49
92
+#define PB4  50
93
+#define PB5  51
94
+#define PB6  52
95
+#define PB7  53
96
+#define PB8  54
97
+#define PB9  55
98
+
99
+// Right Side
100
+#define PB10 56
101
+#define PB11 57
102
+#define PE14 58
103
+#define PE15 59
104
+#define PE12 60
105
+#define PE13 61
106
+#define PE10 62
107
+#define PE11 63
108
+#define PE8  64
109
+#define PE9  65
110
+#define PG1  66
111
+#define PE7  67
112
+#define PF15 68
113
+#define PG0  69
114
+#define PF13 70
115
+#define PF14 71
116
+#define PF11 72
117
+#define PF12 73
118
+#define PB2  74
119
+#define PB1  75 // A0
120
+#define PC5  76 // A1
121
+#define PB0  77 // A2
122
+#define PA7  78 // A3
123
+#define PC4  79 // A4
124
+#define PA5  80 // A5
125
+#define PA6  81 // A6
126
+#define PA3  82 // A7
127
+#define PA4  83 // A8
128
+#define PA1  84 // A9
129
+#define PA2  85 // A10
130
+#define PC3  86 // A11
131
+#define PA0  87 // A12/PA_0(WK_UP): BUT K_UP)
132
+#define PC1  88 // A13
133
+#define PC2  89 // A14
134
+#define PC0  90 // A15
135
+#define PF8  91 // A16
136
+#define PF6  92 // A17
137
+#define PF7  93 // A18
138
+#define PF9  94 // LED D1 (active low)
139
+#define PF10 95 // LED D2 (active low)
140
+#define PF4  96
141
+#define PF5  97
142
+#define PF2  98
143
+#define PF3  99
144
+#define PF0  100
145
+#define PF1  101
146
+#define PE6  102
147
+#define PC13 103
148
+#define PE4  104 // BUT K0
149
+#define PE5  105 // BUT K1
150
+#define PE2  106
151
+#define PE3  107
152
+#define PE0  108
153
+#define PE1  109
154
+#define PC14  110
155
+#define PC15  111
156
+// This must be a literal
157
+#define NUM_DIGITAL_PINS        112
158
+// This must be a literal with a value less than or equal to MAX_ANALOG_INPUTS
159
+#define NUM_ANALOG_INPUTS       23
160
+#define NUM_ANALOG_FIRST        75
161
+
162
+
163
+// Below SPI and I2C definitions already done in the core
164
+// Could be redefined here if differs from the default one
165
+// SPI Definitions
166
+#define PIN_SPI_SS              PF11
167
+#define PIN_SPI_MOSI            PB15
168
+#define PIN_SPI_MISO            PB14
169
+#define PIN_SPI_SCK             PB13
170
+
171
+
172
+
173
+//max6675
174
+//#define PIN_SPI_SS              PA4
175
+//#define PIN_SPI_SCK             PA5
176
+//#define PIN_SPI_MISO            PA6
177
+//#define PIN_SPI_MOSI            PA7
178
+
179
+
180
+
181
+
182
+// I2C Definitions
183
+#define PIN_WIRE_SDA            PB7
184
+#define PIN_WIRE_SCL            PB6
185
+
186
+// Timer Definitions
187
+//Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c
188
+#define TIMER_TONE              TIM6
189
+
190
+// Do not use basic timer: OC is required
191
+#define TIMER_SERVO             TIM1  //TODO: advanced-control timers don't work
192
+
193
+// UART Definitions
194
+// Define here Serial instance number to map on Serial generic name
195
+#define SERIAL_UART_INSTANCE    1 //ex: 2 for Serial2 (USART2)
196
+// DEBUG_UART could be redefined to print on another instance than 'Serial'
197
+//#define DEBUG_UART              ((USART_TypeDef *) U(S)ARTX) // ex: USART3
198
+// DEBUG_UART baudrate, default: 9600 if not defined
199
+//#define DEBUG_UART_BAUDRATE     x
200
+// DEBUG_UART Tx pin name, default: the first one found in PinMap_UART_TX for DEBUG_UART
201
+//#define DEBUG_PINNAME_TX        PX_n // PinName used for TX
202
+
203
+// Default pin used for 'Serial' instance (ex: ST-Link)
204
+// Mandatory for Firmata
205
+#define PIN_SERIAL_RX           PA10
206
+#define PIN_SERIAL_TX           PA9
207
+
208
+/* Extra HAL modules */
209
+//#define HAL_DAC_MODULE_ENABLED
210
+#define HAL_SD_MODULE_ENABLED
211
+
212
+#ifdef __cplusplus
213
+} // extern "C"
214
+#endif
215
+/*----------------------------------------------------------------------------
216
+ *        Arduino objects - C++ only
217
+ *----------------------------------------------------------------------------*/
218
+
219
+#ifdef __cplusplus
220
+// These serial port names are intended to allow libraries and architecture-neutral
221
+// sketches to automatically default to the correct port name for a particular type
222
+// of use.  For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
223
+// the first hardware serial port whose RX/TX pins are not dedicated to another use.
224
+//
225
+// SERIAL_PORT_MONITOR        Port which normally prints to the Arduino Serial Monitor
226
+//
227
+// SERIAL_PORT_USBVIRTUAL     Port which is USB virtual serial
228
+//
229
+// SERIAL_PORT_LINUXBRIDGE    Port which connects to a Linux system via Bridge library
230
+//
231
+// SERIAL_PORT_HARDWARE       Hardware serial port, physical RX & TX pins.
232
+//
233
+// SERIAL_PORT_HARDWARE_OPEN  Hardware serial ports which are open for use.  Their RX & TX
234
+//                            pins are NOT connected to anything by default.
235
+#define SERIAL_PORT_MONITOR     Serial
236
+#define SERIAL_PORT_HARDWARE    Serial1
237
+#endif
238
+

+ 18
- 0
buildroot/tests/LERDGEX-tests View File

@@ -0,0 +1,18 @@
1
+#!/usr/bin/env bash
2
+#
3
+# Build tests for LERDGEX environment
4
+#
5
+
6
+# exit on first failure
7
+set -e
8
+
9
+#
10
+# Build with the default configurations
11
+#
12
+restore_configs
13
+opt_set MOTHERBOARD BOARD_LERDGE_X
14
+opt_set SERIAL_PORT 1
15
+exec_test $1 $2 "LERDGE X with Default Configuration"
16
+
17
+# clean up
18
+restore_configs

+ 40
- 0
platformio.ini View File

@@ -822,6 +822,46 @@ extra_scripts     = pre:buildroot/share/PlatformIO/scripts/generic_create_varian
822 822
 lib_ignore        = Adafruit NeoPixel, SailfishLCD, SlowSoftI2CMaster, SoftwareSerial
823 823
 
824 824
 #
825
+# Lerdge base
826
+#
827
+[lerdge_common]
828
+platform           = ${common_stm32.platform}
829
+extends            = common_stm32
830
+board              = LERDGE
831
+board_build.offset = 0x10000
832
+extra_scripts      = pre:buildroot/share/PlatformIO/scripts/copy_marlin_variant_to_framework.py
833
+                     buildroot/share/PlatformIO/scripts/stm32_bootloader.py
834
+                     buildroot/share/PlatformIO/scripts/lerdge.py
835
+build_flags        = ${common_stm32.build_flags}
836
+  -DSTM32F4 -DSTM32F4xx -DTARGET_STM32F4
837
+  -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 -DARDUINO_LERDGE
838
+  -DTRANSFER_CLOCK_DIV=8
839
+build_unflags      = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483
840
+
841
+#
842
+# Lerdge X
843
+#
844
+[env:LERDGEX]
845
+extends              = lerdge_common
846
+board_build.firmware = Lerdge_X_firmware_force.bin
847
+
848
+#
849
+# Lerdge S
850
+#
851
+[env:LERDGES]
852
+extends              = lerdge_common
853
+board_build.firmware = Lerdge_firmware_force.bin
854
+
855
+#
856
+# Lerdge K
857
+#
858
+[env:LERDGEK]
859
+extends              = lerdge_common
860
+board_build.firmware = Lerdge_K_firmware_force.bin
861
+build_flags          = ${lerdge_common.build_flags}
862
+  -DLERDGEK
863
+
864
+#
825 865
 # RUMBA32
826 866
 #
827 867
 [env:rumba32]

Loading…
Cancel
Save