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

     1  //go:build nucleol552ze
     2  
     3  package machine
     4  
     5  import (
     6  	"device/stm32"
     7  	"runtime/interrupt"
     8  )
     9  
    10  const (
    11  	LED_GREEN   = PC7
    12  	LED_BLUE    = PB7
    13  	LED_RED     = PA9
    14  	LED_BUILTIN = LED_GREEN
    15  	LED         = LED_BUILTIN
    16  )
    17  
    18  const (
    19  	BUTTON      = BUTTON_USER
    20  	BUTTON_USER = PC13
    21  )
    22  
    23  // UART pins
    24  const (
    25  	// PG7 and PG8 are connected to the ST-Link Virtual Com Port (VCP)
    26  	UART_TX_PIN = PG7
    27  	UART_RX_PIN = PG8
    28  	UART_ALT_FN = 8 // GPIO_AF8_LPUART1
    29  )
    30  
    31  var (
    32  	// LPUART1 is the hardware serial port connected to the onboard ST-LINK
    33  	// debugger to be exposed as virtual COM port over USB on Nucleo boards.
    34  	UART1  = &_UART1
    35  	_UART1 = UART{
    36  		Buffer:            NewRingBuffer(),
    37  		Bus:               stm32.LPUART1,
    38  		TxAltFuncSelector: UART_ALT_FN,
    39  		RxAltFuncSelector: UART_ALT_FN,
    40  	}
    41  	DefaultUART = UART1
    42  )
    43  
    44  const (
    45  	I2C0_SCL_PIN = PB8
    46  	I2C0_SDA_PIN = PB9
    47  )
    48  
    49  var (
    50  	// I2C1 is documented, alias to I2C0 as well
    51  	I2C1 = &I2C{
    52  		Bus:             stm32.I2C1,
    53  		AltFuncSelector: 4,
    54  	}
    55  	I2C0 = I2C1
    56  )
    57  
    58  func init() {
    59  	UART1.Interrupt = interrupt.New(stm32.IRQ_LPUART1, _UART1.handleInterrupt)
    60  }