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

     1  //go:build swan
     2  
     3  package machine
     4  
     5  import (
     6  	"device/stm32"
     7  	"runtime/interrupt"
     8  )
     9  
    10  const (
    11  	// LED on the SWAN
    12  	LED = PE2
    13  
    14  	// UART pins
    15  	//    PA9 and PA10 are connected to the SWAN Tx/Rx
    16  	UART_TX_PIN = PA9
    17  	UART_RX_PIN = PA10
    18  
    19  	// I2C pins
    20  	//    PB6 is SCL
    21  	//    PB7 is SDA
    22  	I2C0_SCL_PIN = PB6
    23  	I2C0_SDA_PIN = PB7
    24  
    25  	// SPI pins
    26  	SPI1_SCK_PIN = PD1
    27  	SPI1_SDI_PIN = PB14
    28  	SPI1_SDO_PIN = PB15
    29  	SPI0_SCK_PIN = SPI1_SCK_PIN
    30  	SPI0_SDI_PIN = SPI1_SDI_PIN
    31  	SPI0_SDO_PIN = SPI1_SDO_PIN
    32  )
    33  
    34  var (
    35  	// USART1 is connected to the TX/RX pins
    36  	UART1  = &_UART1
    37  	_UART1 = UART{
    38  		Buffer:            NewRingBuffer(),
    39  		Bus:               stm32.USART1,
    40  		TxAltFuncSelector: 7,
    41  		RxAltFuncSelector: 7,
    42  	}
    43  	DefaultUART = UART1
    44  
    45  	// I2C1 is documented, alias to I2C0 as well
    46  	I2C1 = &I2C{
    47  		Bus:             stm32.I2C1,
    48  		AltFuncSelector: 4,
    49  	}
    50  	I2C0 = I2C1
    51  
    52  	// SPI1 is documented, alias to SPI0 as well
    53  	SPI1 = &SPI{
    54  		Bus:             stm32.SPI2,
    55  		AltFuncSelector: 5,
    56  	}
    57  	SPI0 = SPI1
    58  )
    59  
    60  func init() {
    61  	UART1.Interrupt = interrupt.New(stm32.IRQ_USART1, _UART1.handleInterrupt)
    62  }