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

     1  //go:build pyportal
     2  
     3  package machine
     4  
     5  // used to reset into bootloader
     6  const resetMagicValue = 0xf01669ef
     7  
     8  // GPIO Pins
     9  const (
    10  	D0  = PB13 // NINA_RX
    11  	D1  = PB12 // NINA_TX
    12  	D2  = PB22 // built-in neopixel
    13  	D3  = PA04 // PWM available
    14  	D4  = PA05 // PWM available
    15  	D5  = PB16 // NINA_ACK
    16  	D6  = PB15 // NINA_GPIO0
    17  	D7  = PB17 // NINA_RESETN
    18  	D8  = PB14 // NINA_CS
    19  	D9  = PB04 // TFT_RD
    20  	D10 = PB05 // TFT_DC
    21  	D11 = PB06 // TFT_CS
    22  	D12 = PB07 // TFT_TE
    23  	D13 = PB23 // built-in LED
    24  	D24 = PA00 // TFT_RESET
    25  	D25 = PB31 // TFT_BACKLIGHT
    26  	D26 = PB09 // TFT_WR
    27  	D27 = PB02 // SDA
    28  	D28 = PB03 // SCL
    29  	D29 = PA12 // SDO
    30  	D30 = PA13 // SCK
    31  	D31 = PA14 // SDI
    32  	D32 = PB30 // SD_CS
    33  	D33 = PA01 // SD_CARD_DETECT
    34  	D34 = PA16 // LCD_DATA0
    35  	D35 = PA17 // LCD_DATA1
    36  	D36 = PA18 // LCD_DATA2
    37  	D37 = PA19 // LCD_DATA3
    38  	D38 = PA20 // LCD_DATA4
    39  	D39 = PA21 // LCD_DATA5
    40  	D40 = PA22 // LCD_DATA6
    41  	D41 = PA23 // LCD_DATA7
    42  	D42 = PB10 // QSPI
    43  	D43 = PB11 // QSPI
    44  	D44 = PA08 // QSPI
    45  	D45 = PA09 // QSPI
    46  	D46 = PA10 // QSPI
    47  	D47 = PA11 // QSPI
    48  	D50 = PA02 // speaker amplifier shutdown
    49  	D51 = PA15 // NINA_RTS
    50  
    51  	NINA_CS     = D8
    52  	NINA_ACK    = D5
    53  	NINA_GPIO0  = D6
    54  	NINA_RESETN = D7
    55  
    56  	// pins used for the ESP32 connection do not allow hardware
    57  	// flow control, which is required. have to emulate with software.
    58  	NINA_TX  = D1
    59  	NINA_RX  = D0
    60  	NINA_CTS = NINA_ACK
    61  	NINA_RTS = NINA_GPIO0
    62  
    63  	LCD_DATA0 = D34
    64  
    65  	TFT_RD        = D9
    66  	TFT_DC        = D10
    67  	TFT_CS        = D11
    68  	TFT_TE        = D12
    69  	TFT_RESET     = D24
    70  	TFT_BACKLIGHT = D25
    71  	TFT_WR        = D26
    72  
    73  	NEOPIXEL = D2
    74  	WS2812   = D2
    75  	SPK_SD   = D50
    76  )
    77  
    78  // Analog pins
    79  const (
    80  	A0 = PA02 // ADC0/AIN[0]
    81  	A1 = D3   // ADC0/AIN[4]
    82  	A2 = PA07 // ADC0/AIN[7]
    83  	A3 = D4   // ADC0/AIN[5]
    84  	A4 = PB00 // ADC0/AIN[12]
    85  	A5 = PB01 // ADC0/AIN[13]
    86  	A6 = PA06 // ADC0/AIN[6]
    87  	A7 = PB08 // ADC1/AIN[0]
    88  
    89  	AUDIO_OUT = A0
    90  	LIGHT     = A2
    91  	TOUCH_YD  = A4
    92  	TOUCH_XL  = A5
    93  	TOUCH_YU  = A6
    94  	TOUCH_XR  = A7
    95  )
    96  
    97  const (
    98  	LED = D13
    99  )
   100  
   101  // USBCDC pins
   102  const (
   103  	USBCDC_DM_PIN = PA24
   104  	USBCDC_DP_PIN = PA25
   105  )
   106  
   107  // UART1 aka NINA_TX/NINA_RX
   108  const (
   109  	UART_TX_PIN = D1
   110  	UART_RX_PIN = D0
   111  )
   112  
   113  var (
   114  	UART1 = &sercomUSART4
   115  
   116  	DefaultUART = UART1
   117  
   118  	UART_NINA = UART1
   119  )
   120  
   121  // NINA-W102 settings
   122  const (
   123  	NINA_BAUDRATE         = 115200
   124  	NINA_RESET_INVERTED   = true
   125  	NINA_SOFT_FLOWCONTROL = true
   126  )
   127  
   128  // I2C pins
   129  const (
   130  	SDA_PIN = PB02 // SDA: SERCOM2/PAD[0]
   131  	SCL_PIN = PB03 // SCL: SERCOM2/PAD[1]
   132  )
   133  
   134  // I2C on the PyPortal.
   135  var (
   136  	I2C0 = sercomI2CM5
   137  )
   138  
   139  // SPI pins
   140  const (
   141  	SPI0_SCK_PIN = PA13 // SCK: SERCOM1/PAD[1]
   142  	SPI0_SDO_PIN = PA12 // SDO: SERCOM1/PAD[3]
   143  	SPI0_SDI_PIN = PA14 // SDI: SERCOM1/PAD[2]
   144  
   145  	NINA_SDO = SPI0_SDO_PIN
   146  	NINA_SDI = SPI0_SDI_PIN
   147  	NINA_SCK = SPI0_SCK_PIN
   148  )
   149  
   150  // SPI on the PyPortal.
   151  var (
   152  	SPI0     = sercomSPIM2
   153  	NINA_SPI = SPI0
   154  )
   155  
   156  // USB CDC identifiers
   157  const (
   158  	usb_STRING_PRODUCT      = "Adafruit PyPortal M4"
   159  	usb_STRING_MANUFACTURER = "Adafruit"
   160  )
   161  
   162  var (
   163  	usb_VID uint16 = 0x239A
   164  	usb_PID uint16 = 0x8035
   165  )