From f37d4098551aae62a6ece43cbdd03df67699f59c Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 4 Oct 2018 13:36:15 +0200 Subject: [PATCH] nrf: use machine.UART0 as stdout --- src/runtime/runtime_nrf.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/runtime/runtime_nrf.go b/src/runtime/runtime_nrf.go index 61755ba0..06754950 100644 --- a/src/runtime/runtime_nrf.go +++ b/src/runtime/runtime_nrf.go @@ -5,6 +5,7 @@ package runtime import ( "device/arm" "device/nrf" + "machine" ) type timeUnit int64 @@ -21,19 +22,11 @@ func handleReset() { } func init() { - initUART() + machine.UART0.Configure(machine.UARTConfig{}) initLFCLK() 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() { nrf.CLOCK.LFCLKSRC = nrf.CLOCK_LFCLKSTAT_SRC_Xtal nrf.CLOCK.TASKS_LFCLKSTART = 1 @@ -49,10 +42,7 @@ func initRTC() { } func putchar(c byte) { - nrf.UART0.TXD = nrf.RegValue(c) - for nrf.UART0.EVENTS_TXDRDY == 0 { - } - nrf.UART0.EVENTS_TXDRDY = 0 + machine.UART0.WriteByte(c) } func sleepTicks(d timeUnit) {