github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/machine/board_feather-m4-can.go (about) 1 //go:build feather_m4_can 2 3 package machine 4 5 import ( 6 "device/sam" 7 ) 8 9 // used to reset into bootloader 10 const resetMagicValue = 0xf01669ef 11 12 // GPIO Pins 13 const ( 14 D0 = PB17 // UART0 RX/PWM available 15 D1 = PB16 // UART0 TX/PWM available 16 D4 = PA14 // PWM available 17 D5 = PA16 // PWM available 18 D6 = PA18 // PWM available 19 D7 = PB03 // neopixel power 20 D8 = PB02 // built-in neopixel 21 D9 = PA19 // PWM available 22 D10 = PA20 // can be used for PWM or UART1 TX 23 D11 = PA21 // can be used for PWM or UART1 RX 24 D12 = PA22 // PWM available 25 D13 = PA23 // PWM available 26 D21 = PA13 // PWM available 27 D22 = PA12 // PWM available 28 D23 = PB22 // PWM available 29 D24 = PB23 // PWM available 30 D25 = PA17 // PWM available 31 ) 32 33 // Analog pins 34 const ( 35 A0 = PA02 // ADC/AIN[0] 36 A1 = PA05 // ADC/AIN[2] 37 A2 = PB08 // ADC/AIN[3] 38 A3 = PB09 // ADC/AIN[4] 39 A4 = PA04 // ADC/AIN[5] 40 A5 = PA06 // ADC/AIN[10] 41 ) 42 43 const ( 44 LED = D13 45 NEOPIXELS = D8 46 WS2812 = D8 47 ) 48 49 // USBCDC pins 50 const ( 51 USBCDC_DM_PIN = PA24 52 USBCDC_DP_PIN = PA25 53 ) 54 55 const ( 56 UART_TX_PIN = D1 57 UART_RX_PIN = D0 58 ) 59 60 const ( 61 UART2_TX_PIN = A4 62 UART2_RX_PIN = A5 63 ) 64 65 // I2C pins 66 const ( 67 SDA_PIN = D22 // SDA: SERCOM2/PAD[0] 68 SCL_PIN = D21 // SCL: SERCOM2/PAD[1] 69 ) 70 71 // SPI pins 72 const ( 73 SPI0_SCK_PIN = D25 // SCK: SERCOM1/PAD[1] 74 SPI0_SDO_PIN = D24 // SDO: SERCOM1/PAD[3] 75 SPI0_SDI_PIN = D23 // SDI: SERCOM1/PAD[2] 76 ) 77 78 // CAN pins 79 const ( 80 CAN0_TX = PA22 81 CAN0_RX = PA23 82 83 CAN1_STANDBY = PB12 84 CAN1_TX = PB14 85 CAN1_RX = PB15 86 BOOST_EN = PB13 // power control of CAN1's TCAN1051HGV (H: enable) 87 88 CAN_STANDBY = CAN1_STANDBY 89 CAN_S = CAN1_STANDBY 90 CAN_TX = CAN1_TX 91 CAN_RX = CAN1_RX 92 ) 93 94 // USB CDC identifiers 95 const ( 96 usb_STRING_PRODUCT = "Adafruit Feather M4 CAN" 97 usb_STRING_MANUFACTURER = "Adafruit" 98 ) 99 100 var ( 101 usb_VID uint16 = 0x239A 102 usb_PID uint16 = 0x80CD 103 ) 104 105 var ( 106 UART1 = &sercomUSART5 107 108 UART2 = &sercomUSART0 109 ) 110 111 func init() { 112 // turn on neopixel 113 D7.Configure(PinConfig{Mode: PinOutput}) 114 D7.High() 115 } 116 117 // I2C on the Feather M4 CAN. 118 var ( 119 I2C0 = sercomI2CM2 120 ) 121 122 // SPI on the Feather M4 CAN. 123 var SPI0 = sercomSPIM1 124 125 // CAN on the Feather M4 CAN. 126 var ( 127 CAN0 = CAN{ 128 Bus: sam.CAN0, 129 } 130 131 CAN1 = CAN{ 132 Bus: sam.CAN1, 133 } 134 ) 135 136 var ( 137 DefaultUART = UART1 138 )