diff options
-rw-r--r-- | GNUmakefile | 2 | ||||
-rw-r--r-- | src/machine/board_mksnanov3.go | 109 | ||||
-rw-r--r-- | targets/mksnanov3.json | 12 |
3 files changed, 123 insertions, 0 deletions
diff --git a/GNUmakefile b/GNUmakefile index bac1691cb..050399264 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -717,6 +717,8 @@ ifneq ($(STM32), 0) @$(MD5SUM) test.hex $(TINYGO) build -size short -o test.hex -target=swan examples/blinky1 @$(MD5SUM) test.hex + $(TINYGO) build -size short -o test.hex -target=mksnanov3 examples/blinky1 + @$(MD5SUM) test.hex endif $(TINYGO) build -size short -o test.hex -target=atmega328pb examples/blinkm @$(MD5SUM) test.hex diff --git a/src/machine/board_mksnanov3.go b/src/machine/board_mksnanov3.go new file mode 100644 index 000000000..9a9d906fe --- /dev/null +++ b/src/machine/board_mksnanov3.go @@ -0,0 +1,109 @@ +//go:build mksnanov3 + +// The MKS Robin Nano V3.X board. +// Documented at https://github.com/makerbase-mks/MKS-Robin-Nano-V3.X. + +package machine + +import ( + "device/stm32" + "runtime/interrupt" +) + +// LED is also wired to the SD card card detect (CD) pin. +const LED = PD12 + +// UART pins +const ( + UART_TX_PIN = PB10 + UART_RX_PIN = PB11 +) + +// EXP1 and EXP2 expansion ports for connecting +// the MKS TS35 V2.0 expansion board. +const ( + BEEPER = EXP1_1 + + // LCD pins. + LCD_DC = EXP1_8 + LCD_CS = EXP1_7 + LCD_RS = EXP1_4 + LCD_BACKLIGHT = EXP1_3 + + // Touch pins. Note that some pins are shared with the + // LCD SPI1 interface. + TOUCH_CLK = EXP2_2 + TOUCH_CS = EXP1_5 + TOUCH_DIN = EXP2_6 + TOUCH_DOUT = EXP2_1 + TOUCH_IRQ = EXP1_6 + + BUTTON = BUTTON_JOG + BUTTON_JOG = EXP1_2 + BUTTON_JOG_CCW = EXP2_3 + BUTTON_JOG_CW = EXP2_5 + + EXP1_1 = PC5 + EXP1_2 = PE13 + EXP1_3 = PD13 + EXP1_4 = PC6 + EXP1_5 = PE14 + EXP1_6 = PE15 + EXP1_7 = PD11 + EXP1_8 = PD10 + + EXP2_1 = PA6 + EXP2_2 = PA5 + EXP2_3 = PE8 + EXP2_4 = PE10 + EXP2_5 = PE11 + EXP2_6 = PA7 + EXP2_7 = PE12 +) + +var ( + UART3 = &_UART3 + _UART3 = UART{ + Buffer: NewRingBuffer(), + Bus: stm32.USART3, + TxAltFuncSelector: AF7_USART1_2_3, + RxAltFuncSelector: AF7_USART1_2_3, + } + DefaultUART = UART3 +) + +// set up RX IRQ handler. Follow similar pattern for other UARTx instances +func init() { + UART3.Interrupt = interrupt.New(stm32.IRQ_USART3, _UART3.handleInterrupt) +} + +// SPI pins +const ( + SPI1_SCK_PIN = EXP2_2 + SPI1_SDI_PIN = EXP2_1 + SPI1_SDO_PIN = EXP2_6 + SPI0_SCK_PIN = SPI1_SCK_PIN + SPI0_SDI_PIN = SPI1_SDI_PIN + SPI0_SDO_PIN = SPI1_SDO_PIN +) + +// Since the first interface is named SPI1, both SPI0 and SPI1 refer to SPI1. +var ( + SPI0 = SPI{ + Bus: stm32.SPI1, + AltFuncSelector: AF5_SPI1_SPI2, + } + SPI1 = &SPI0 +) + +const ( + I2C0_SCL_PIN = PB6 + I2C0_SDA_PIN = PB7 +) + +var ( + I2C0 = &I2C{ + Bus: stm32.I2C1, + AltFuncSelector: AF4_I2C1_2_3, + } +) diff --git a/targets/mksnanov3.json b/targets/mksnanov3.json new file mode 100644 index 000000000..9b202d3ab --- /dev/null +++ b/targets/mksnanov3.json @@ -0,0 +1,12 @@ +{ + "inherits": ["cortex-m4"], + "build-tags": ["mksnanov3", "stm32f407", "stm32f4", "stm32"], + "serial": "uart", + "linkerscript": "targets/stm32f407.ld", + "extra-files": [ + "src/device/stm32/stm32f407.s" + ], + "flash-method": "openocd", + "openocd-interface": "stlink-v2", + "openocd-target": "stm32f4x" +} |