Skip to content

Commit 2a8fd75

Browse files
rhapsodyvthinkyhead
authored andcommitted
MKS Robin Nano V3 and STM32F4x0Vx Variant (MarlinFirmware#20430)
1 parent 6f40f6e commit 2a8fd75

File tree

11 files changed

+2078
-0
lines changed

11 files changed

+2078
-0
lines changed

Marlin/src/core/boards.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@
367367
#define BOARD_FLYF407ZG 4217 // FLYF407ZG board (STM32F407ZG)
368368
#define BOARD_MKS_ROBIN2 4218 // MKS_ROBIN2 (STM32F407ZE)
369369
#define BOARD_MKS_ROBIN_PRO_V2 4219 // MKS Robin Pro V2 (STM32F407VE)
370+
#define BOARD_MKS_ROBIN_NANO_V3 4220 // MKS Robin Nano V3 (STM32F407VG)
370371

371372
//
372373
// ARM Cortex M7

Marlin/src/pins/pins.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,8 @@
592592
#include "stm32f4/pins_MKS_ROBIN2.h" // STM32F4 env:MKS_ROBIN2
593593
#elif MB(MKS_ROBIN_PRO_V2)
594594
#include "stm32f4/pins_MKS_ROBIN_PRO_V2.h" // STM32F4 env:mks_robin_pro2
595+
#elif MB(MKS_ROBIN_NANO_V3)
596+
#include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3
595597

596598
//
597599
// ARM Cortex M7
Lines changed: 367 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,367 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
#pragma once
23+
24+
#if NOT_TARGET(STM32F4, STM32F4xx)
25+
#error "Oops! Select an STM32F4 board in 'Tools > Board.'"
26+
#elif HOTENDS > 2 || E_STEPPERS > 2
27+
#error "MKS Robin Nano V3 supports up to 2 hotends / E-steppers."
28+
#elif HAS_FSMC_TFT
29+
#error "MKS Robin Nano V3 doesn't support FSMC-based TFT displays."
30+
#endif
31+
32+
#define BOARD_INFO_NAME "MKS Robin Nano V3"
33+
34+
// Use one of these or SDCard-based Emulation will be used
35+
//#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation
36+
//#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation
37+
#define I2C_EEPROM
38+
39+
//
40+
// Release PB4 (Z_DIR_PIN) from JTAG NRST role
41+
//
42+
43+
//
44+
// Limit Switches
45+
//
46+
#define X_DIAG_PIN PD15
47+
#define Y_DIAG_PIN PD2
48+
#define Z_DIAG_PIN PC8
49+
#define E0_DIAG_PIN PC4
50+
#define E1_DIAG_PIN PE7
51+
52+
//
53+
#define X_STOP_PIN PA15
54+
#define Y_STOP_PIN PD2
55+
#define Z_MIN_PIN PC8
56+
#define Z_MAX_PIN PC4
57+
58+
//
59+
// Steppers
60+
//
61+
#define X_ENABLE_PIN PE4
62+
#define X_STEP_PIN PE3
63+
#define X_DIR_PIN PE2
64+
#ifndef X_CS_PIN
65+
#define X_CS_PIN PD5
66+
#endif
67+
68+
#define Y_ENABLE_PIN PE1
69+
#define Y_STEP_PIN PE0
70+
#define Y_DIR_PIN PB9
71+
#ifndef Y_CS_PIN
72+
#define Y_CS_PIN PD7
73+
#endif
74+
75+
#define Z_ENABLE_PIN PB8
76+
#define Z_STEP_PIN PB5
77+
#define Z_DIR_PIN PB4
78+
#ifndef Z_CS_PIN
79+
#define Z_CS_PIN PD4
80+
#endif
81+
82+
#define E0_ENABLE_PIN PB3
83+
#define E0_STEP_PIN PD6
84+
#define E0_DIR_PIN PD3
85+
#ifndef E0_CS_PIN
86+
#define E0_CS_PIN PD9
87+
#endif
88+
89+
#define E1_ENABLE_PIN PA3
90+
#define E1_STEP_PIN PD15
91+
#define E1_DIR_PIN PA1
92+
#ifndef E1_CS_PIN
93+
#define E1_CS_PIN PD8
94+
#endif
95+
96+
//
97+
// Software SPI pins for TMC2130 stepper drivers
98+
//
99+
// This board only support SW SPI for stepper drivers
100+
#if HAS_TMC_SPI
101+
#define TMC_USE_SW_SPI
102+
#endif
103+
#if ENABLED(TMC_USE_SW_SPI)
104+
#if !defined(TMC_SW_MOSI) || TMC_SW_MOSI == -1
105+
#define TMC_SW_MOSI PD14
106+
#endif
107+
#if !defined(TMC_SW_MISO) || TMC_SW_MISO == -1
108+
#define TMC_SW_MISO PD1
109+
#endif
110+
#if !defined(TMC_SW_SCK) || TMC_SW_SCK == -1
111+
#define TMC_SW_SCK PD0
112+
#endif
113+
#endif
114+
115+
#if HAS_TMC_UART
116+
//
117+
// Software serial
118+
// No Hardware serial for steppers
119+
//
120+
#define X_SERIAL_TX_PIN PD5
121+
#define X_SERIAL_RX_PIN PD5
122+
123+
#define Y_SERIAL_TX_PIN PD7
124+
#define Y_SERIAL_RX_PIN PD7
125+
126+
#define Z_SERIAL_TX_PIN PD4
127+
#define Z_SERIAL_RX_PIN PD4
128+
129+
#define E0_SERIAL_TX_PIN PD9
130+
#define E0_SERIAL_RX_PIN PD9
131+
132+
#define E1_SERIAL_TX_PIN PD8
133+
#define E1_SERIAL_RX_PIN PD8
134+
135+
// Reduce baud rate to improve software serial reliability
136+
#define TMC_BAUD_RATE 19200
137+
#endif
138+
139+
//
140+
// Temperature Sensors
141+
//
142+
#define TEMP_0_PIN PC1 // TH1
143+
#define TEMP_1_PIN PA2 // TH2
144+
#define TEMP_BED_PIN PC0 // TB1
145+
146+
//
147+
// Heaters / Fans
148+
//
149+
#define HEATER_0_PIN PE5 // HEATER1
150+
#define HEATER_1_PIN PB0 // HEATER2
151+
#define HEATER_BED_PIN PA0 // HOT BED
152+
153+
#define FAN_PIN PB1 // FAN
154+
#define FAN1_PIN PC14 // FAN1
155+
156+
//
157+
// Thermocouples
158+
//
159+
//#define MAX6675_SS_PIN HEATER_0_PIN // TC1 - CS1
160+
//#define MAX6675_SS_PIN HEATER_1_PIN // TC2 - CS2
161+
162+
//
163+
// Misc. Functions
164+
//
165+
#define MT_DET_1 PA4
166+
#define MT_DET_2 PE6
167+
#define PW_DET PA13
168+
#define PW_OFF PB2
169+
170+
#ifndef FIL_RUNOUT_PIN
171+
#define FIL_RUNOUT_PIN MT_DET_1
172+
#endif
173+
#ifndef FIL_RUNOUT2_PIN
174+
#define FIL_RUNOUT2_PIN MT_DET_2
175+
#endif
176+
177+
#define POWER_LOSS_PIN PW_DET
178+
#define PS_ON_PIN PW_OFF
179+
//
180+
// Enable MKSPWC support
181+
//
182+
//#define SUICIDE_PIN PB2
183+
//#define KILL_PIN PA2
184+
//#define KILL_PIN_INVERTING true
185+
186+
#define SERVO0_PIN PA8 // Enable BLTOUCH support
187+
//#define LED_PIN PB2
188+
189+
// Random Info
190+
#define USB_SERIAL -1 //Usb Serial
191+
#define WIFI_SERIAL 3 //USART3
192+
#define MKS_WIFI_MODULE_SERIAL 1 //USART1
193+
#define MKS_WIFI_MODULE_SPI 2 //SPI2
194+
195+
#ifndef SDCARD_CONNECTION
196+
#define SDCARD_CONNECTION ONBOARD
197+
#endif
198+
199+
//
200+
// Onboard SD card
201+
//
202+
// detect pin dont work when ONBOARD and NO_SD_HOST_DRIVE disabled
203+
#if SD_CONNECTION_IS(ONBOARD)
204+
#define CUSTOM_SPI_PINS // TODO: needed because is the only way to set SPI3 for SD on STM32 (by now)
205+
#if ENABLED(CUSTOM_SPI_PINS)
206+
#define ENABLE_SPI3
207+
#define SS_PIN -1
208+
#define SDSS PC9
209+
#define SCK_PIN PC10
210+
#define MISO_PIN PC11
211+
#define MOSI_PIN PC12
212+
#define SD_DETECT_PIN PD12
213+
#endif
214+
#endif
215+
216+
//
217+
// LCD SD
218+
//
219+
#if SD_CONNECTION_IS(LCD)
220+
#define CUSTOM_SPI_PINS
221+
#if ENABLED(CUSTOM_SPI_PINS)
222+
#define ENABLE_SPI1
223+
#define SDSS PE10
224+
#define SCK_PIN PA5
225+
#define MISO_PIN PA6
226+
#define MOSI_PIN PA7
227+
#define SD_DETECT_PIN PE12
228+
#endif
229+
#endif
230+
231+
//
232+
// LCD / Controller
233+
#define SPI_FLASH
234+
#define HAS_SPI_FLASH 1
235+
#define SPI_DEVICE 2
236+
#define SPI_FLASH_SIZE 0x1000000
237+
#if ENABLED(SPI_FLASH)
238+
#define W25QXX_CS_PIN PB12
239+
#define W25QXX_MOSI_PIN PC3
240+
#define W25QXX_MISO_PIN PC2
241+
#define W25QXX_SCK_PIN PB13
242+
#endif
243+
244+
/**
245+
* _____ _____
246+
* (BEEPER)PC5 | · · | PE13(BTN_ENC) (SPI1 MISO) PA6 | · · | PA5 (SPI1 SCK)
247+
* (LCD_EN)PD13 | · · | PC6(LCD_RS) (BTN_EN1) PE8 | · · | PE10 (SPI1 CS)
248+
* (LCD_D4)PE14 | · · PE15(LCD_D5) (BTN_EN2) PE11 | · · PA7 (SPI1 MOSI)
249+
* (LCD_D6)PD11 | · · | PD10(LCD_D7) (SPI1_RS) PE12 | · · | RESET
250+
* GND | · · | 5V GND | · · | 3.3V
251+
*  ̄ ̄ ̄  ̄ ̄ ̄
252+
* EXP1 EXP2
253+
*/
254+
255+
#if EITHER(TFT_480x320_SPI, TFT_LVGL_UI_SPI)
256+
#ifndef TOUCH_CALIBRATION_X
257+
#define TOUCH_CALIBRATION_X -17253
258+
#endif
259+
#ifndef TOUCH_CALIBRATION_Y
260+
#define TOUCH_CALIBRATION_Y 11579
261+
#endif
262+
#ifndef TOUCH_OFFSET_X
263+
#define TOUCH_OFFSET_X 514
264+
#endif
265+
#ifndef TOUCH_OFFSET_Y
266+
#define TOUCH_OFFSET_Y -24
267+
#endif
268+
#ifndef TOUCH_ORIENTATION
269+
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
270+
#endif
271+
272+
#define TFT_CS_PIN PD11
273+
#define TFT_SCK_PIN PA5
274+
#define TFT_MISO_PIN PA6
275+
#define TFT_MOSI_PIN PA7
276+
#define TFT_DC_PIN PD10
277+
#define TFT_RST_PIN PC6
278+
#define TFT_A0_PIN TFT_DC_PIN
279+
280+
#define TFT_RESET_PIN PC6
281+
#define TFT_BACKLIGHT_PIN PD13
282+
283+
#define TOUCH_BUTTONS_HW_SPI
284+
#define TOUCH_BUTTONS_HW_SPI_DEVICE 1
285+
286+
#define LCD_BACKLIGHT_PIN PD13
287+
#ifndef TFT_WIDTH
288+
#define TFT_WIDTH 480
289+
#endif
290+
#ifndef TFT_HEIGHT
291+
#define TFT_HEIGHT 320
292+
#endif
293+
294+
#define TOUCH_CS_PIN PE14 // SPI1_NSS
295+
#define TOUCH_SCK_PIN PA5 // SPI1_SCK
296+
#define TOUCH_MISO_PIN PA6 // SPI1_MISO
297+
#define TOUCH_MOSI_PIN PA7 // SPI1_MOSI
298+
299+
#define BTN_EN1 PE8
300+
#define BTN_EN2 PE11
301+
#define BEEPER_PIN PC5
302+
#define BTN_ENC PE13
303+
304+
#define LCD_READ_ID 0xD3
305+
#define LCD_USE_DMA_SPI
306+
307+
#define TFT_BUFFER_SIZE 14400
308+
309+
#elif HAS_SPI_LCD
310+
#define BEEPER_PIN PC5
311+
#define BTN_ENC PE13
312+
#define LCD_PINS_ENABLE PD13
313+
#define LCD_PINS_RS PC6
314+
#define BTN_EN1 PE8
315+
#define BTN_EN2 PE11
316+
#define LCD_BACKLIGHT_PIN -1
317+
318+
// MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor)
319+
#if ENABLED(MKS_MINI_12864)
320+
//#define LCD_BACKLIGHT_PIN -1
321+
//#define LCD_RESET_PIN -1
322+
#define DOGLCD_A0 PD11
323+
#define DOGLCD_CS PE15
324+
//#define DOGLCD_SCK PA5
325+
//#define DOGLCD_MOSI PA7
326+
327+
// Required for MKS_MINI_12864 with this board
328+
//#define MKS_LCD12864B
329+
//#undef SHOW_BOOTSCREEN
330+
331+
#else // !MKS_MINI_12864
332+
333+
#define LCD_PINS_D4 PE14
334+
#if ENABLED(ULTIPANEL)
335+
#define LCD_PINS_D5 PE15
336+
#define LCD_PINS_D6 PD11
337+
#define LCD_PINS_D7 PD10
338+
#endif
339+
340+
#define BOARD_ST7920_DELAY_1 DELAY_NS(96)
341+
#define BOARD_ST7920_DELAY_2 DELAY_NS(48)
342+
#define BOARD_ST7920_DELAY_3 DELAY_NS(600)
343+
344+
#endif // !MKS_MINI_12864
345+
346+
#elif ENABLED(SPI_GRAPHICAL_TFT)
347+
#define SPI_TFT_CS_PIN PD11
348+
#define SPI_TFT_SCK_PIN PA5
349+
#define SPI_TFT_MISO_PIN PA6
350+
#define SPI_TFT_MOSI_PIN PA7
351+
#define SPI_TFT_DC_PIN PD10
352+
#define SPI_TFT_RST_PIN PC6
353+
354+
#define LCD_BACKLIGHT_PIN PD13
355+
356+
#define TOUCH_CS_PIN PE14 // SPI1_NSS
357+
#define TOUCH_SCK_PIN PA5 // SPI1_SCK
358+
#define TOUCH_MISO_PIN PA6 // SPI1_MISO
359+
#define TOUCH_MOSI_PIN PA7 // SPI1_MOSI
360+
361+
#define BTN_EN1 PE8
362+
#define BTN_EN2 PE11
363+
#define BEEPER_PIN PC5
364+
#define BTN_ENC PE13
365+
#endif // HAS_SPI_LCD
366+
367+
#define HAS_OTG_USB_HOST_SUPPORT

0 commit comments

Comments
 (0)