github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/machine/board_gnse.go (about) 1 //go:build gnse 2 3 package machine 4 5 import ( 6 "device/stm32" 7 "runtime/interrupt" 8 ) 9 10 const ( 11 LED_RED = PB5 12 LED_GREEN = PB6 13 LED_BLUE = PB7 14 LED1 = LED_RED // Red 15 LED2 = LED_GREEN // Green 16 LED3 = LED_BLUE // Blue 17 LED = LED_GREEN // Default 18 19 BUTTON = PB3 20 BUZZER = PA15 21 VBATT_ADC = PB2 22 SENSOR_EN = PB12 23 FLASH_EN = PC13 24 25 // SPI0 26 SPI0_NSS_PIN = PA4 27 SPI0_SCK_PIN = PA5 28 SPI0_SDO_PIN = PA6 29 SPI0_SDI_PIN = PA7 30 31 //MCU USART2 32 UART2_RX_PIN = PA3 33 UART2_TX_PIN = PA2 34 35 // DEFAULT USART 36 UART_RX_PIN = UART2_RX_PIN 37 UART_TX_PIN = UART2_TX_PIN 38 39 // I2C1 pins 40 // I2C1 is connected to Flash, Accelerometer, Env. Sensor, Crypto Element) 41 I2C1_SCL_PIN = PA9 42 I2C1_SDA_PIN = PA10 43 I2C1_ALT_FUNC = 4 44 45 // I2C2 pins 46 // I2C2 is expansion J10 QWIIC Connector 47 I2C2_SCL_PIN = PA12 48 I2C2_SDA_PIN = PA11 49 I2C2_ALT_FUNC = 4 50 51 // I2C0 alias for I2C1 52 I2C0_SDA_PIN = I2C1_SDA_PIN 53 I2C0_SCL_PIN = I2C1_SCL_PIN 54 ) 55 56 var ( 57 // STM32 UART2 is connected to the embedded STLINKV3 Virtual Com Port 58 UART0 = &_UART0 59 _UART0 = UART{ 60 Buffer: NewRingBuffer(), 61 Bus: stm32.USART2, 62 TxAltFuncSelector: 7, 63 RxAltFuncSelector: 7, 64 } 65 66 DefaultUART = UART0 67 68 // I2C Busses 69 I2C1 = &I2C{ 70 Bus: stm32.I2C1, 71 AltFuncSelector: I2C1_ALT_FUNC, 72 } 73 I2C2 = &I2C{ 74 Bus: stm32.I2C2, 75 AltFuncSelector: I2C2_ALT_FUNC, 76 } 77 I2C0 = I2C1 78 79 // SPI 80 SPI3 = SPI{ 81 Bus: stm32.SPI3, 82 } 83 ) 84 85 func init() { 86 // Enable UARTs Interrupts 87 UART0.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART0.handleInterrupt) 88 }