
Previously, the machine.UART0 object had two meanings: - it was the first UART on the chip - it was the default output for println These two meanings conflict, and resulted in workarounds like: - Defining UART0 to refer to the USB-CDC interface (atsamd21, atsamd51, nrf52840), even though that clearly isn't an UART. - Defining NRF_UART0 to avoid a conflict with UART0 (which was redefined as a USB-CDC interface). - Defining aliases like UART0 = UART1, which refer to the same hardware peripheral (stm32). This commit changes this to use a new machine.Serial object for the default serial port. It might refer to the first or second UART depending on the board, or even to the USB-CDC interface. Also, UART0 now really refers to the first UART on the chip, no longer to a USB-CDC interface. The changes in the runtime package are all just search+replace. The changes in the machine package are a mixture of search+replace and manual modifications. This commit does not affect binary size, in fact it doesn't affect the resulting binary at all.
111 строки
1,6 КиБ
Go
111 строки
1,6 КиБ
Go
// +build microbit_v2
|
|
|
|
package machine
|
|
|
|
// The micro:bit does not have a 32kHz crystal on board.
|
|
const HasLowFrequencyCrystal = false
|
|
|
|
// Buttons on the micro:bit v2 (A and B)
|
|
const (
|
|
BUTTON Pin = BUTTONA
|
|
BUTTONA Pin = P5
|
|
BUTTONB Pin = P11
|
|
)
|
|
|
|
var Serial = UART0
|
|
|
|
// UART pins
|
|
const (
|
|
UART_TX_PIN Pin = P34
|
|
UART_RX_PIN Pin = P33
|
|
)
|
|
|
|
// ADC pins
|
|
const (
|
|
ADC0 Pin = P0
|
|
ADC1 Pin = P1
|
|
ADC2 Pin = P2
|
|
)
|
|
|
|
// I2C0 (internal) pins
|
|
const (
|
|
SDA_PIN Pin = SDA0_PIN
|
|
SCL_PIN Pin = SCL0_PIN
|
|
SDA0_PIN Pin = P30
|
|
SCL0_PIN Pin = P31
|
|
)
|
|
|
|
// I2C1 (external) pins
|
|
const (
|
|
SDA1_PIN Pin = P20
|
|
SCL1_PIN Pin = P19
|
|
)
|
|
|
|
// SPI pins
|
|
const (
|
|
SPI0_SCK_PIN Pin = P13
|
|
SPI0_SDO_PIN Pin = P15
|
|
SPI0_SDI_PIN Pin = P14
|
|
)
|
|
|
|
// GPIO/Analog pins
|
|
const (
|
|
P0 Pin = 2
|
|
P1 Pin = 3
|
|
P2 Pin = 4
|
|
P3 Pin = 31
|
|
P4 Pin = 28
|
|
P5 Pin = 14
|
|
P6 Pin = 37
|
|
P7 Pin = 11
|
|
P8 Pin = 10
|
|
P9 Pin = 9
|
|
P10 Pin = 30
|
|
P11 Pin = 23
|
|
P12 Pin = 12
|
|
P13 Pin = 17
|
|
P14 Pin = 1
|
|
P15 Pin = 13
|
|
P16 Pin = 34
|
|
P19 Pin = 26
|
|
P20 Pin = 32
|
|
P21 Pin = 21
|
|
P22 Pin = 22
|
|
P23 Pin = 15
|
|
P24 Pin = 24
|
|
P25 Pin = 19
|
|
P26 Pin = 36
|
|
P27 Pin = 0
|
|
P28 Pin = 20
|
|
P29 Pin = 5
|
|
P30 Pin = 16
|
|
P31 Pin = 8
|
|
P32 Pin = 25
|
|
P33 Pin = 40
|
|
P34 Pin = 6
|
|
)
|
|
|
|
// LED matrix pins
|
|
const (
|
|
LED_COL_1 Pin = P0_28
|
|
LED_COL_2 Pin = P0_11
|
|
LED_COL_3 Pin = P0_31
|
|
LED_COL_4 Pin = P1_05
|
|
LED_COL_5 Pin = P0_30
|
|
LED_ROW_1 Pin = P0_21
|
|
LED_ROW_2 Pin = P0_22
|
|
LED_ROW_3 Pin = P0_15
|
|
LED_ROW_4 Pin = P0_24
|
|
LED_ROW_5 Pin = P0_19
|
|
)
|
|
|
|
// USB CDC identifiers
|
|
const (
|
|
usb_STRING_PRODUCT = "BBC micro:bit V2"
|
|
usb_STRING_MANUFACTURER = "BBC"
|
|
)
|
|
|
|
var (
|
|
usb_VID uint16 = 0x0d28
|
|
usb_PID uint16 = 0x0204
|
|
)
|