github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/machine/board_pybadge.go (about) 1 //go:build pybadge 2 3 package machine 4 5 // used to reset into bootloader 6 const resetMagicValue = 0xf01669ef 7 8 // GPIO Pins 9 const ( 10 D0 = PB17 // UART0 RX/PWM available 11 D1 = PB16 // UART0 TX/PWM available 12 D2 = PB03 13 D3 = PB02 14 D4 = PA14 // PWM available 15 D5 = PA16 // PWM available 16 D6 = PA18 // PWM available 17 D7 = PB14 18 D8 = PA15 // built-in neopixel 19 D9 = PA19 // PWM available 20 D10 = PA20 // can be used for PWM or UART1 TX 21 D11 = PA21 // can be used for PWM or UART1 RX 22 D12 = PA22 // PWM available 23 D13 = PA23 // PWM available 24 ) 25 26 // Analog pins 27 const ( 28 A0 = PA02 // ADC/AIN[0] 29 A1 = PA05 // ADC/AIN[2] 30 A2 = PB08 // ADC/AIN[3] 31 A3 = PB09 // ADC/AIN[4] 32 A4 = PA04 // ADC/AIN[5] 33 A5 = PA06 // ADC/AIN[6] 34 A6 = PB01 // ADC/AIN[12]/VMEAS 35 A7 = PB04 // ADC/AIN[6]/LIGHT 36 A8 = D2 // ADC/AIN[14] 37 A9 = D3 // ADC/AIN[15] 38 ) 39 40 const ( 41 LED = D13 42 NEOPIXELS = D8 43 WS2812 = D8 44 45 LIGHTSENSOR = A7 46 47 BUTTON_LATCH = PB00 48 BUTTON_OUT = PB30 49 BUTTON_CLK = PB31 50 51 TFT_DC = PB05 52 TFT_CS = PB07 53 TFT_RST = PA00 54 TFT_LITE = PA01 55 56 SPEAKER_ENABLE = PA27 57 ) 58 59 const ( 60 BUTTON_LEFT_MASK = 1 61 BUTTON_UP_MASK = 2 62 BUTTON_DOWN_MASK = 4 63 BUTTON_RIGHT_MASK = 8 64 BUTTON_SELECT_MASK = 16 65 BUTTON_START_MASK = 32 66 BUTTON_A_MASK = 64 67 BUTTON_B_MASK = 128 68 ) 69 70 // USBCDC pins 71 const ( 72 USBCDC_DM_PIN = PA24 73 USBCDC_DP_PIN = PA25 74 ) 75 76 // UART1 pins 77 const ( 78 UART_TX_PIN = D1 79 UART_RX_PIN = D0 80 ) 81 82 const ( 83 UART2_TX_PIN = A4 84 UART2_RX_PIN = A5 85 ) 86 87 var ( 88 UART1 = &sercomUSART5 89 UART2 = &sercomUSART0 90 91 DefaultUART = UART1 92 ) 93 94 // I2C pins 95 const ( 96 SDA_PIN = PA12 // SDA: SERCOM2/PAD[0] 97 SCL_PIN = PA13 // SCL: SERCOM2/PAD[1] 98 ) 99 100 // I2C on the ItsyBitsy M4. 101 var I2C0 = sercomI2CM2 102 103 // SPI pins 104 const ( 105 SPI0_SCK_PIN = PA17 // SCK: SERCOM1/PAD[1] 106 SPI0_SDO_PIN = PB23 // SDO: SERCOM1/PAD[3] 107 SPI0_SDI_PIN = PB22 // SDI: SERCOM1/PAD[2] 108 ) 109 110 // TFT SPI pins 111 const ( 112 SPI1_SCK_PIN = PB13 // SCK: SERCOM4/PAD[1] 113 SPI1_SDO_PIN = PB15 // SDO: SERCOM4/PAD[3] 114 SPI1_SDI_PIN = NoPin 115 ) 116 117 // SPI on the PyBadge. 118 var SPI0 = sercomSPIM1 119 120 // TFT SPI on the PyBadge. 121 var SPI1 = sercomSPIM4 122 123 // USB CDC identifiers 124 const ( 125 usb_STRING_PRODUCT = "Adafruit pyBadge M4" 126 usb_STRING_MANUFACTURER = "Adafruit" 127 ) 128 129 var ( 130 usb_VID uint16 = 0x239A 131 usb_PID uint16 = 0x8033 132 ) 133 134 // NINA-W102 settings when using AirLift WiFi FeatherWing 135 const ( 136 NINA_BAUDRATE = 115200 137 NINA_RESET_INVERTED = true 138 NINA_SOFT_FLOWCONTROL = true 139 ) 140 141 const ( 142 NINA_CS = D13 143 NINA_ACK = D11 144 NINA_GPIO0 = D10 145 NINA_RESETN = D12 146 147 // pins used for the ESP32 connection do not allow hardware 148 // flow control, which is required. have to emulate with software. 149 NINA_TX = UART_TX_PIN 150 NINA_RX = UART_RX_PIN 151 NINA_CTS = NINA_ACK 152 NINA_RTS = NINA_GPIO0 153 154 NINA_SDO = SPI0_SDO_PIN 155 NINA_SDI = SPI0_SDI_PIN 156 NINA_SCK = SPI0_SCK_PIN 157 ) 158 159 var ( 160 NINA_SPI = SPI0 161 UART_NINA = UART1 162 )