github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/machine/board_nucleol432kc.go (about) 1 //go:build nucleol432kc 2 3 package machine 4 5 import ( 6 "device/stm32" 7 "runtime/interrupt" 8 ) 9 10 const ( 11 // Arduino Pins 12 A0 = PA0 13 A1 = PA1 14 A2 = PA3 15 A3 = PA4 16 A4 = PA5 17 A5 = PA6 18 A6 = PA7 19 A7 = PA2 20 21 D0 = PA10 22 D1 = PA9 23 D2 = PA12 24 D3 = PB0 25 D4 = PB7 26 D5 = PB6 27 D6 = PB1 28 D7 = PC14 29 D8 = PC15 30 D9 = PA8 31 D10 = PA11 32 D11 = PB5 33 D12 = PB4 34 D13 = PB3 35 ) 36 37 const ( 38 LED = LED_BUILTIN 39 LED_BUILTIN = LED_GREEN 40 LED_GREEN = PB3 41 ) 42 43 const ( 44 // This board does not have a user button, so 45 // use first GPIO pin by default 46 BUTTON = PA0 47 ) 48 49 const ( 50 // UART pins 51 // PA2 and PA15 are connected to the ST-Link Virtual Com Port (VCP) 52 UART_TX_PIN = PA2 53 UART_RX_PIN = PA15 54 55 // I2C pins 56 // With default solder bridge settings: 57 // PB6 / Arduino D5 / CN3 Pin 8 is SCL 58 // PB7 / Arduino D4 / CN3 Pin 7 is SDA 59 I2C0_SCL_PIN = PB6 60 I2C0_SDA_PIN = PB7 61 62 // SPI pins 63 SPI1_SCK_PIN = PB3 64 SPI1_SDI_PIN = PB5 65 SPI1_SDO_PIN = PB4 66 SPI0_SCK_PIN = SPI1_SCK_PIN 67 SPI0_SDI_PIN = SPI1_SDI_PIN 68 SPI0_SDO_PIN = SPI1_SDO_PIN 69 ) 70 71 var ( 72 // USART2 is the hardware serial port connected to the onboard ST-LINK 73 // debugger to be exposed as virtual COM port over USB on Nucleo boards. 74 UART1 = &_UART1 75 _UART1 = UART{ 76 Buffer: NewRingBuffer(), 77 Bus: stm32.USART2, 78 TxAltFuncSelector: 7, 79 RxAltFuncSelector: 3, 80 } 81 DefaultUART = UART1 82 83 // I2C1 is documented, alias to I2C0 as well 84 I2C1 = &I2C{ 85 Bus: stm32.I2C1, 86 AltFuncSelector: 4, 87 } 88 I2C0 = I2C1 89 90 // SPI1 is documented, alias to SPI0 as well 91 SPI1 = &SPI{ 92 Bus: stm32.SPI1, 93 AltFuncSelector: 5, 94 } 95 SPI0 = SPI1 96 ) 97 98 func init() { 99 UART1.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART1.handleInterrupt) 100 }