nrf51: define and use P0_xx constants
This makes nrf51 consistent with nrf52 and other chips, which do provide constants for hardware pin numbers. I've also added the microbit to the smoketest because it is used on play.tinygo.org. And removed PCA10040 and PCA10056 because they aren't provided on play.tinygo.org anymore.
Этот коммит содержится в:
родитель
926c02b6ff
коммит
20a46e1b28
5 изменённых файлов: 96 добавлений и 58 удалений
4
Makefile
4
Makefile
|
@ -454,9 +454,7 @@ ifneq ($(WASM), 0)
|
|||
@$(MD5SUM) test.wasm
|
||||
$(TINYGO) build -size short -o test.wasm -tags=reelboard examples/blinky1
|
||||
@$(MD5SUM) test.wasm
|
||||
$(TINYGO) build -size short -o test.wasm -tags=pca10040 examples/blinky2
|
||||
@$(MD5SUM) test.wasm
|
||||
$(TINYGO) build -size short -o test.wasm -tags=pca10056 examples/blinky2
|
||||
$(TINYGO) build -size short -o test.wasm -tags=microbit examples/microbit-blink
|
||||
@$(MD5SUM) test.wasm
|
||||
$(TINYGO) build -size short -o test.wasm -tags=circuitplay_express examples/blinky1
|
||||
@$(MD5SUM) test.wasm
|
||||
|
|
|
@ -8,72 +8,72 @@ const HasLowFrequencyCrystal = false
|
|||
|
||||
// Buttons on the micro:bit (A and B)
|
||||
const (
|
||||
BUTTON Pin = BUTTONA
|
||||
BUTTONA Pin = 17
|
||||
BUTTONB Pin = 26
|
||||
BUTTON = BUTTONA
|
||||
BUTTONA = P0_17
|
||||
BUTTONB = P0_26
|
||||
)
|
||||
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART pins
|
||||
const (
|
||||
UART_TX_PIN Pin = 24
|
||||
UART_RX_PIN Pin = 25
|
||||
UART_TX_PIN = P0_24
|
||||
UART_RX_PIN = P0_25
|
||||
)
|
||||
|
||||
// ADC pins
|
||||
const (
|
||||
ADC0 Pin = 3 // P0 on the board
|
||||
ADC1 Pin = 2 // P1 on the board
|
||||
ADC2 Pin = 1 // P2 on the board
|
||||
ADC0 = P0_03 // P0 on the board
|
||||
ADC1 = P0_02 // P1 on the board
|
||||
ADC2 = P0_01 // P2 on the board
|
||||
)
|
||||
|
||||
// I2C pins
|
||||
const (
|
||||
SDA_PIN Pin = 30 // P20 on the board
|
||||
SCL_PIN Pin = 0 // P19 on the board
|
||||
SDA_PIN = P0_30 // P20 on the board
|
||||
SCL_PIN = P0_00 // P19 on the board
|
||||
)
|
||||
|
||||
// SPI pins
|
||||
const (
|
||||
SPI0_SCK_PIN Pin = 23 // P13 on the board
|
||||
SPI0_SDO_PIN Pin = 21 // P15 on the board
|
||||
SPI0_SDI_PIN Pin = 22 // P14 on the board
|
||||
SPI0_SCK_PIN = P0_23 // P13 on the board
|
||||
SPI0_SDO_PIN = P0_21 // P15 on the board
|
||||
SPI0_SDI_PIN = P0_22 // P14 on the board
|
||||
)
|
||||
|
||||
// GPIO/Analog pins
|
||||
const (
|
||||
P0 Pin = 3
|
||||
P1 Pin = 2
|
||||
P2 Pin = 1
|
||||
P3 Pin = 4
|
||||
P4 Pin = 5
|
||||
P5 Pin = 17
|
||||
P6 Pin = 12
|
||||
P7 Pin = 11
|
||||
P8 Pin = 18
|
||||
P9 Pin = 10
|
||||
P10 Pin = 6
|
||||
P11 Pin = 26
|
||||
P12 Pin = 20
|
||||
P13 Pin = 23
|
||||
P14 Pin = 22
|
||||
P15 Pin = 21
|
||||
P16 Pin = 16
|
||||
P0 = P0_03
|
||||
P1 = P0_02
|
||||
P2 = P0_01
|
||||
P3 = P0_04
|
||||
P4 = P0_05
|
||||
P5 = P0_17
|
||||
P6 = P0_12
|
||||
P7 = P0_11
|
||||
P8 = P0_18
|
||||
P9 = P0_10
|
||||
P10 = P0_06
|
||||
P11 = P0_26
|
||||
P12 = P0_20
|
||||
P13 = P0_23
|
||||
P14 = P0_22
|
||||
P15 = P0_21
|
||||
P16 = P0_16
|
||||
)
|
||||
|
||||
// LED matrix pins
|
||||
const (
|
||||
LED_COL_1 Pin = 4
|
||||
LED_COL_2 Pin = 5
|
||||
LED_COL_3 Pin = 6
|
||||
LED_COL_4 Pin = 7
|
||||
LED_COL_5 Pin = 8
|
||||
LED_COL_6 Pin = 9
|
||||
LED_COL_7 Pin = 10
|
||||
LED_COL_8 Pin = 11
|
||||
LED_COL_9 Pin = 12
|
||||
LED_ROW_1 Pin = 13
|
||||
LED_ROW_2 Pin = 14
|
||||
LED_ROW_3 Pin = 15
|
||||
LED_COL_1 = P0_04
|
||||
LED_COL_2 = P0_05
|
||||
LED_COL_3 = P0_06
|
||||
LED_COL_4 = P0_07
|
||||
LED_COL_5 = P0_08
|
||||
LED_COL_6 = P0_09
|
||||
LED_COL_7 = P0_10
|
||||
LED_COL_8 = P0_11
|
||||
LED_COL_9 = P0_12
|
||||
LED_ROW_1 = P0_13
|
||||
LED_ROW_2 = P0_14
|
||||
LED_ROW_3 = P0_15
|
||||
)
|
||||
|
|
44
src/machine/board_nrf51.go
Обычный файл
44
src/machine/board_nrf51.go
Обычный файл
|
@ -0,0 +1,44 @@
|
|||
//go:build nrf51 || microbit
|
||||
// +build nrf51 microbit
|
||||
|
||||
package machine
|
||||
|
||||
func CPUFrequency() uint32 {
|
||||
return 16000000
|
||||
}
|
||||
|
||||
// Hardware pins
|
||||
const (
|
||||
P0_00 Pin = 0
|
||||
P0_01 Pin = 1
|
||||
P0_02 Pin = 2
|
||||
P0_03 Pin = 3
|
||||
P0_04 Pin = 4
|
||||
P0_05 Pin = 5
|
||||
P0_06 Pin = 6
|
||||
P0_07 Pin = 7
|
||||
P0_08 Pin = 8
|
||||
P0_09 Pin = 9
|
||||
P0_10 Pin = 10
|
||||
P0_11 Pin = 11
|
||||
P0_12 Pin = 12
|
||||
P0_13 Pin = 13
|
||||
P0_14 Pin = 14
|
||||
P0_15 Pin = 15
|
||||
P0_16 Pin = 16
|
||||
P0_17 Pin = 17
|
||||
P0_18 Pin = 18
|
||||
P0_19 Pin = 19
|
||||
P0_20 Pin = 20
|
||||
P0_21 Pin = 21
|
||||
P0_22 Pin = 22
|
||||
P0_23 Pin = 23
|
||||
P0_24 Pin = 24
|
||||
P0_25 Pin = 25
|
||||
P0_26 Pin = 26
|
||||
P0_27 Pin = 27
|
||||
P0_28 Pin = 28
|
||||
P0_29 Pin = 29
|
||||
P0_30 Pin = 30
|
||||
P0_31 Pin = 31
|
||||
)
|
|
@ -11,21 +11,21 @@ const HasLowFrequencyCrystal = true
|
|||
|
||||
// LED on the pca10031
|
||||
const (
|
||||
LED Pin = LED_RED
|
||||
LED1 Pin = LED_RED
|
||||
LED2 Pin = LED_GREEN
|
||||
LED3 Pin = LED_BLUE
|
||||
LED_RED Pin = 21
|
||||
LED_GREEN Pin = 22
|
||||
LED_BLUE Pin = 23
|
||||
LED = LED_RED
|
||||
LED1 = LED_RED
|
||||
LED2 = LED_GREEN
|
||||
LED3 = LED_BLUE
|
||||
LED_RED = P0_21
|
||||
LED_GREEN = P0_22
|
||||
LED_BLUE = P0_23
|
||||
)
|
||||
|
||||
var DefaultUART = UART0
|
||||
|
||||
// UART pins
|
||||
const (
|
||||
UART_TX_PIN Pin = 9
|
||||
UART_RX_PIN Pin = 11
|
||||
UART_TX_PIN = P0_09
|
||||
UART_RX_PIN = P0_11
|
||||
)
|
||||
|
||||
// I2C pins (disabled)
|
||||
|
|
|
@ -7,10 +7,6 @@ import (
|
|||
"device/nrf"
|
||||
)
|
||||
|
||||
func CPUFrequency() uint32 {
|
||||
return 16000000
|
||||
}
|
||||
|
||||
// Get peripheral and pin number for this GPIO pin.
|
||||
func (p Pin) getPortPin() (*nrf.GPIO_Type, uint32) {
|
||||
return nrf.GPIO, uint32(p)
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче