github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/machine/board_mksnanov3.go (about)

     1  //go:build mksnanov3
     2  
     3  // The MKS Robin Nano V3.X board.
     4  // Documented at https://github.com/makerbase-mks/MKS-Robin-Nano-V3.X.
     5  
     6  package machine
     7  
     8  import (
     9  	"device/stm32"
    10  	"runtime/interrupt"
    11  )
    12  
    13  // LED is also wired to the SD card card detect (CD) pin.
    14  const LED = PD12
    15  
    16  // UART pins
    17  const (
    18  	UART_TX_PIN = PB10
    19  	UART_RX_PIN = PB11
    20  )
    21  
    22  // EXP1 and EXP2 expansion ports for connecting
    23  // the MKS TS35 V2.0 expansion board.
    24  const (
    25  	BEEPER = EXP1_1
    26  
    27  	// LCD pins.
    28  	LCD_DC        = EXP1_8
    29  	LCD_CS        = EXP1_7
    30  	LCD_RS        = EXP1_4
    31  	LCD_BACKLIGHT = EXP1_3
    32  
    33  	// Touch pins. Note that some pins are shared with the
    34  	// LCD SPI1 interface.
    35  	TOUCH_CLK  = EXP2_2
    36  	TOUCH_CS   = EXP1_5
    37  	TOUCH_DIN  = EXP2_6
    38  	TOUCH_DOUT = EXP2_1
    39  	TOUCH_IRQ  = EXP1_6
    40  
    41  	BUTTON         = BUTTON_JOG
    42  	BUTTON_JOG     = EXP1_2
    43  	BUTTON_JOG_CCW = EXP2_3
    44  	BUTTON_JOG_CW  = EXP2_5
    45  
    46  	EXP1_1 = PC5
    47  	EXP1_2 = PE13
    48  	EXP1_3 = PD13
    49  	EXP1_4 = PC6
    50  	EXP1_5 = PE14
    51  	EXP1_6 = PE15
    52  	EXP1_7 = PD11
    53  	EXP1_8 = PD10
    54  
    55  	EXP2_1 = PA6
    56  	EXP2_2 = PA5
    57  	EXP2_3 = PE8
    58  	EXP2_4 = PE10
    59  	EXP2_5 = PE11
    60  	EXP2_6 = PA7
    61  	EXP2_7 = PE12
    62  )
    63  
    64  var (
    65  	UART3  = &_UART3
    66  	_UART3 = UART{
    67  		Buffer:            NewRingBuffer(),
    68  		Bus:               stm32.USART3,
    69  		TxAltFuncSelector: AF7_USART1_2_3,
    70  		RxAltFuncSelector: AF7_USART1_2_3,
    71  	}
    72  	DefaultUART = UART3
    73  )
    74  
    75  // set up RX IRQ handler. Follow similar pattern for other UARTx instances
    76  func init() {
    77  	UART3.Interrupt = interrupt.New(stm32.IRQ_USART3, _UART3.handleInterrupt)
    78  }
    79  
    80  // SPI pins
    81  const (
    82  	SPI1_SCK_PIN = EXP2_2
    83  	SPI1_SDI_PIN = EXP2_1
    84  	SPI1_SDO_PIN = EXP2_6
    85  	SPI0_SCK_PIN = SPI1_SCK_PIN
    86  	SPI0_SDI_PIN = SPI1_SDI_PIN
    87  	SPI0_SDO_PIN = SPI1_SDO_PIN
    88  )
    89  
    90  // Since the first interface is named SPI1, both SPI0 and SPI1 refer to SPI1.
    91  var (
    92  	SPI0 = SPI{
    93  		Bus:             stm32.SPI1,
    94  		AltFuncSelector: AF5_SPI1_SPI2,
    95  	}
    96  	SPI1 = &SPI0
    97  )
    98  
    99  const (
   100  	I2C0_SCL_PIN = PB6
   101  	I2C0_SDA_PIN = PB7
   102  )
   103  
   104  var (
   105  	I2C0 = &I2C{
   106  		Bus:             stm32.I2C1,
   107  		AltFuncSelector: AF4_I2C1_2_3,
   108  	}
   109  )
   110  
   111  // Motor control pins.
   112  const (
   113  	X_ENABLE = PE4
   114  	X_STEP   = PE3
   115  	X_DIR    = PE2
   116  	X_DIAG   = PA15
   117  	X_UART   = PD5
   118  
   119  	Y_ENABLE = PE1
   120  	Y_STEP   = PE0
   121  	Y_DIR    = PB9
   122  	Y_DIAG   = PD2
   123  	Y_UART   = PD7
   124  
   125  	Z_ENABLE = PB8
   126  	Z_STEP   = PB5
   127  	Z_DIR    = PB4
   128  	Z_DIAG   = PC8
   129  	Z_UART   = PD4
   130  
   131  	E0_ENABLE = PB3
   132  	E0_STEP   = PD6
   133  	E0_DIR    = PD3
   134  	E0_DIAG   = PC4
   135  	E0_UART   = PD9
   136  
   137  	E1_ENABLE = PA3
   138  	E1_STEP   = PD15
   139  	E1_DIR    = PA1
   140  	E1_DIAG   = PE7
   141  	E1_UART   = PD8
   142  )