From ea8b90fa5fbfa85391ddaff9ad8822775dda249b Mon Sep 17 00:00:00 2001 From: Kees Bakker <kees@sodaq.com> Date: Tue, 2 Aug 2016 22:29:36 +0200 Subject: [PATCH] cpu/samd21: uart: now using padd setting from board config Notice the extra fields in uart_conf_t for rx_pad and tx_pad. --- boards/samr21-xpro/include/periph_conf.h | 4 ++-- cpu/samd21/periph/uart.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/boards/samr21-xpro/include/periph_conf.h b/boards/samr21-xpro/include/periph_conf.h index acfccece08..395ce073da 100644 --- a/boards/samr21-xpro/include/periph_conf.h +++ b/boards/samr21-xpro/include/periph_conf.h @@ -105,8 +105,8 @@ extern "C" { */ static const uart_conf_t uart_config[] = { /* device, RX pin, TX pin, mux */ - {&SERCOM0->USART, GPIO_PIN(PA,5), GPIO_PIN(PA,4), GPIO_MUX_D}, - {&SERCOM5->USART, GPIO_PIN(PA,23), GPIO_PIN(PA,22), GPIO_MUX_D}, + {&SERCOM0->USART, GPIO_PIN(PA,5), GPIO_PIN(PA,4), GPIO_MUX_D, SERCOM_RX_PAD_1, UART_TX_PAD_0}, + {&SERCOM5->USART, GPIO_PIN(PA,23), GPIO_PIN(PA,22), GPIO_MUX_D, SERCOM_RX_PAD_1, UART_TX_PAD_0}, }; /* interrupt function name mapping */ diff --git a/cpu/samd21/periph/uart.c b/cpu/samd21/periph/uart.c index 44efebba46..62bd6152d7 100644 --- a/cpu/samd21/periph/uart.c +++ b/cpu/samd21/periph/uart.c @@ -86,11 +86,12 @@ static int init_base(uart_t uart, uint32_t baudrate) /* reset the UART device */ dev->CTRLA.reg = SERCOM_USART_CTRLA_SWRST; while (dev->SYNCBUSY.reg & SERCOM_USART_SYNCBUSY_SWRST) {} - /* set asynchronous mode w/o parity, LSB first, PAD0 to TX, PAD1 to RX and + /* set asynchronous mode w/o parity, LSB first, PADn to TX, PADn to RX and * use internal clock */ dev->CTRLA.reg = (SERCOM_USART_CTRLA_DORD | - SERCOM_USART_CTRLA_RXPO(0x1) | - SERCOM_USART_CTRLA_SAMPR(0x1) | + SERCOM_USART_CTRLA_TXPO(uart_config[uart].tx_pad) | + SERCOM_USART_CTRLA_RXPO(uart_config[uart].rx_pad) | + SERCOM_USART_CTRLA_SAMPR(0x1) | // 1: x16 sample rate SERCOM_USART_CTRLA_MODE_USART_INT_CLK); /* set baudrate */ dev->BAUD.FRAC.FP = (baud % 10); -- GitLab