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

     1  //go:build bluepill
     2  
     3  package machine
     4  
     5  import (
     6  	"device/stm32"
     7  	"runtime/interrupt"
     8  )
     9  
    10  // Pins printed on the silkscreen
    11  const (
    12  	C13 = PC13
    13  	C14 = PC14
    14  	C15 = PC15
    15  	A0  = PA0
    16  	A1  = PA1
    17  	A2  = PA2
    18  	A3  = PA3
    19  	A4  = PA4
    20  	A5  = PA5
    21  	A6  = PA6
    22  	A7  = PA7
    23  	B0  = PB0
    24  	B1  = PB1
    25  	B10 = PB10
    26  	B11 = PB11
    27  	B12 = PB12
    28  	B13 = PB13
    29  	B14 = PB14
    30  	B15 = PB15
    31  	A8  = PA8
    32  	A9  = PA9
    33  	A10 = PA10
    34  	A11 = PA11
    35  	A12 = PA12
    36  	A13 = PA13
    37  	A14 = PA14
    38  	A15 = PA15
    39  	B3  = PB3
    40  	B4  = PB4
    41  	B5  = PB5
    42  	B6  = PB6
    43  	B7  = PB7
    44  	B8  = PB8
    45  	B9  = PB9
    46  )
    47  
    48  // Analog Pins
    49  const (
    50  	ADC0 = PA0
    51  	ADC1 = PA1
    52  	ADC2 = PA2
    53  	ADC3 = PA3
    54  	ADC4 = PA4
    55  	ADC5 = PA5
    56  	ADC6 = PA6
    57  	ADC7 = PA7
    58  	ADC8 = PB0
    59  	ADC9 = PB1
    60  )
    61  
    62  const (
    63  	// This board does not have a user button, so
    64  	// use first GPIO pin by default
    65  	BUTTON = PA0
    66  
    67  	LED = PC13
    68  )
    69  
    70  var DefaultUART = UART1
    71  
    72  // UART pins
    73  const (
    74  	UART_TX_PIN     = PA9
    75  	UART_RX_PIN     = PA10
    76  	UART_ALT_TX_PIN = PB6
    77  	UART_ALT_RX_PIN = PB7
    78  )
    79  
    80  var (
    81  	// USART1 is the first hardware serial port on the STM32.
    82  	UART1  = &_UART1
    83  	_UART1 = UART{
    84  		Buffer: NewRingBuffer(),
    85  		Bus:    stm32.USART1,
    86  	}
    87  	UART2  = &_UART2
    88  	_UART2 = UART{
    89  		Buffer: NewRingBuffer(),
    90  		Bus:    stm32.USART2,
    91  	}
    92  )
    93  
    94  func init() {
    95  	UART1.Interrupt = interrupt.New(stm32.IRQ_USART1, _UART1.handleInterrupt)
    96  	UART2.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART2.handleInterrupt)
    97  }
    98  
    99  // SPI pins
   100  const (
   101  	SPI0_SCK_PIN = PA5
   102  	SPI0_SDO_PIN = PA7
   103  	SPI0_SDI_PIN = PA6
   104  )
   105  
   106  // I2C pins
   107  const (
   108  	I2C0_SDA_PIN = PB7
   109  	I2C0_SCL_PIN = PB6
   110  )