From bdef52ad62c0b8e7897e0b93fa99f85575d3ab75 Mon Sep 17 00:00:00 2001 From: Wojtek Siudzinski Date: Sun, 16 Feb 2020 15:54:07 +0100 Subject: [PATCH] Allow changing the UART pins --- src/machine/machine_nrf.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/machine/machine_nrf.go b/src/machine/machine_nrf.go index a5ecb0e98..6c927d8f8 100644 --- a/src/machine/machine_nrf.go +++ b/src/machine/machine_nrf.go @@ -79,8 +79,14 @@ func (uart UART) Configure(config UARTConfig) { uart.SetBaudRate(config.BaudRate) - // Set TX and RX pins from board. - uart.setPins(UART_TX_PIN, UART_RX_PIN) + // Set TX and RX pins + if config.TX == 0 && config.RX == 0 { + // Use default pins + uart.setPins(UART_TX_PIN, UART_RX_PIN) + } else { + uart.setPins(config.TX, config.RX) + } + nrf.UART0.ENABLE.Set(nrf.UART_ENABLE_ENABLE_Enabled) nrf.UART0.TASKS_STARTTX.Set(1)