nrf: use machine.UART0 as stdout
Этот коммит содержится в:
родитель
b36b9c24a2
коммит
f37d409855
1 изменённых файлов: 3 добавлений и 13 удалений
|
@ -5,6 +5,7 @@ package runtime
|
||||||
import (
|
import (
|
||||||
"device/arm"
|
"device/arm"
|
||||||
"device/nrf"
|
"device/nrf"
|
||||||
|
"machine"
|
||||||
)
|
)
|
||||||
|
|
||||||
type timeUnit int64
|
type timeUnit int64
|
||||||
|
@ -21,19 +22,11 @@ func handleReset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
initUART()
|
machine.UART0.Configure(machine.UARTConfig{})
|
||||||
initLFCLK()
|
initLFCLK()
|
||||||
initRTC()
|
initRTC()
|
||||||
}
|
}
|
||||||
|
|
||||||
func initUART() {
|
|
||||||
nrf.UART0.ENABLE = nrf.UART_ENABLE_ENABLE_Enabled
|
|
||||||
nrf.UART0.BAUDRATE = nrf.UART_BAUDRATE_BAUDRATE_Baud115200
|
|
||||||
nrf.UART0.TASKS_STARTTX = 1
|
|
||||||
nrf.UART0.PSELTXD = 6 // pin 6 for NRF52840-DK
|
|
||||||
nrf.UART0.PSELRXD = 8 // pin 8 for NRF52840-DK
|
|
||||||
}
|
|
||||||
|
|
||||||
func initLFCLK() {
|
func initLFCLK() {
|
||||||
nrf.CLOCK.LFCLKSRC = nrf.CLOCK_LFCLKSTAT_SRC_Xtal
|
nrf.CLOCK.LFCLKSRC = nrf.CLOCK_LFCLKSTAT_SRC_Xtal
|
||||||
nrf.CLOCK.TASKS_LFCLKSTART = 1
|
nrf.CLOCK.TASKS_LFCLKSTART = 1
|
||||||
|
@ -49,10 +42,7 @@ func initRTC() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func putchar(c byte) {
|
func putchar(c byte) {
|
||||||
nrf.UART0.TXD = nrf.RegValue(c)
|
machine.UART0.WriteByte(c)
|
||||||
for nrf.UART0.EVENTS_TXDRDY == 0 {
|
|
||||||
}
|
|
||||||
nrf.UART0.EVENTS_TXDRDY = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func sleepTicks(d timeUnit) {
|
func sleepTicks(d timeUnit) {
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче