github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/machine/board_lorae5.go (about) 1 //go:build lorae5 2 3 package machine 4 5 import ( 6 "device/stm32" 7 "runtime/interrupt" 8 ) 9 10 const ( 11 // We assume a LED is connected on PB5 12 LED = PB5 // Default LED 13 14 // Set the POWER_EN3V3 pin to high to turn 15 // on the 3.3V power for all peripherals 16 POWER_EN3V3 = PA9 17 18 // Set the POWER_EN5V pin to high to turn 19 // on the 5V bus power for all peripherals 20 POWER_EN5V = PB10 21 ) 22 23 // SubGhz (SPI3) 24 const ( 25 SPI0_NSS_PIN = PA4 26 SPI0_SCK_PIN = PA5 27 SPI0_SDO_PIN = PA6 28 SPI0_SDI_PIN = PA7 29 ) 30 31 // UARTS 32 const ( 33 // MCU USART1 34 UART1_TX_PIN = PB6 35 UART1_RX_PIN = PB7 36 37 // MCU USART2 38 UART2_TX_PIN = PA2 39 UART2_RX_PIN = PA3 40 41 // DEFAULT USART 42 UART_TX_PIN = UART1_TX_PIN 43 UART_RX_PIN = UART1_RX_PIN 44 45 // I2C2 pins 46 I2C2_SCL_PIN = PB15 47 I2C2_SDA_PIN = PA15 48 I2C2_ALT_FUNC = 4 49 50 // I2C0 alias for I2C2 51 I2C0_SDA_PIN = I2C2_SDA_PIN 52 I2C0_SCL_PIN = I2C2_SCL_PIN 53 ) 54 55 var ( 56 // Console UART 57 UART0 = &_UART0 58 _UART0 = UART{ 59 Buffer: NewRingBuffer(), 60 Bus: stm32.USART1, 61 TxAltFuncSelector: AF7_USART1_2, 62 RxAltFuncSelector: AF7_USART1_2, 63 } 64 DefaultUART = UART0 65 66 // Since we treat UART1 as zero, let's also call it by the real name 67 UART1 = UART0 68 69 // UART2 70 UART2 = &_UART2 71 _UART2 = UART{ 72 Buffer: NewRingBuffer(), 73 Bus: stm32.USART2, 74 TxAltFuncSelector: AF7_USART1_2, 75 RxAltFuncSelector: AF7_USART1_2, 76 } 77 78 // I2C Busses 79 I2C2 = &I2C{ 80 Bus: stm32.I2C2, 81 AltFuncSelector: I2C2_ALT_FUNC, 82 } 83 84 // Set "default" I2C bus to I2C2 85 I2C0 = I2C2 86 87 // SPI 88 SPI3 = SPI{ 89 Bus: stm32.SPI3, 90 } 91 ) 92 93 func init() { 94 // Enable UARTs Interrupts 95 UART0.Interrupt = interrupt.New(stm32.IRQ_USART1, _UART0.handleInterrupt) 96 UART2.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART2.handleInterrupt) 97 }