From 3371cf1831e011f05ba462eb789a81af8b8301b6 Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sat, 28 Sep 2019 12:06:19 +0200 Subject: [PATCH 1/4] boards+efm32: remove non-standard uart modes feature --- boards/ikea-tradfri/include/periph_conf.h | 3 --- boards/slstk3401a/include/periph_conf.h | 9 --------- boards/slstk3402a/include/periph_conf.h | 6 ------ boards/sltb001a/include/periph_conf.h | 9 --------- boards/slwstk6000b/include/periph_conf.h | 3 --- boards/stk3600/include/periph_conf.h | 9 --------- boards/stk3700/include/periph_conf.h | 9 --------- 7 files changed, 48 deletions(-) diff --git a/boards/ikea-tradfri/include/periph_conf.h b/boards/ikea-tradfri/include/periph_conf.h index 74974dc6984f..cc4c56f5d29d 100644 --- a/boards/ikea-tradfri/include/periph_conf.h +++ b/boards/ikea-tradfri/include/periph_conf.h @@ -121,9 +121,6 @@ static const uart_conf_t uart_config[] = { .tx_pin = GPIO_PIN(PB, 14), .loc = USART_ROUTELOC0_RXLOC_LOC9 | USART_ROUTELOC0_TXLOC_LOC9, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_USART0, .irq = USART0_RX_IRQn } diff --git a/boards/slstk3401a/include/periph_conf.h b/boards/slstk3401a/include/periph_conf.h index 8345b394b3f1..595eb1833bdc 100644 --- a/boards/slstk3401a/include/periph_conf.h +++ b/boards/slstk3401a/include/periph_conf.h @@ -180,9 +180,6 @@ static const uart_conf_t uart_config[] = { .tx_pin = GPIO_PIN(PA, 0), .loc = USART_ROUTELOC0_RXLOC_LOC0 | USART_ROUTELOC0_TXLOC_LOC0, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_USART0, .irq = USART0_RX_IRQn }, @@ -192,9 +189,6 @@ static const uart_conf_t uart_config[] = { .tx_pin = GPIO_PIN(PC, 6), .loc = USART_ROUTELOC0_RXLOC_LOC11 | USART_ROUTELOC0_TXLOC_LOC11, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_USART1, .irq = USART1_RX_IRQn }, @@ -204,9 +198,6 @@ static const uart_conf_t uart_config[] = { .tx_pin = GPIO_PIN(PD, 10), .loc = LEUART_ROUTELOC0_RXLOC_LOC18 | LEUART_ROUTELOC0_TXLOC_LOC18, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_LEUART0, .irq = LEUART0_IRQn } diff --git a/boards/slstk3402a/include/periph_conf.h b/boards/slstk3402a/include/periph_conf.h index 8fbea50d64ee..10b2c7d9455a 100644 --- a/boards/slstk3402a/include/periph_conf.h +++ b/boards/slstk3402a/include/periph_conf.h @@ -171,9 +171,6 @@ static const uart_conf_t uart_config[] = { .tx_pin = GPIO_PIN(PA, 0), .loc = USART_ROUTELOC0_RXLOC_LOC0 | USART_ROUTELOC0_TXLOC_LOC0, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_USART0, .irq = USART0_RX_IRQn }, @@ -183,9 +180,6 @@ static const uart_conf_t uart_config[] = { .tx_pin = GPIO_PIN(PD, 10), .loc = LEUART_ROUTELOC0_RXLOC_LOC18 | LEUART_ROUTELOC0_TXLOC_LOC18, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_LEUART0, .irq = LEUART0_IRQn } diff --git a/boards/sltb001a/include/periph_conf.h b/boards/sltb001a/include/periph_conf.h index a41053bd13f5..ccc312992621 100644 --- a/boards/sltb001a/include/periph_conf.h +++ b/boards/sltb001a/include/periph_conf.h @@ -180,9 +180,6 @@ static const uart_conf_t uart_config[] = { .tx_pin = GPIO_PIN(PA, 0), .loc = USART_ROUTELOC0_RXLOC_LOC0 | USART_ROUTELOC0_TXLOC_LOC0, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_USART0, .irq = USART0_RX_IRQn }, @@ -192,9 +189,6 @@ static const uart_conf_t uart_config[] = { .tx_pin = GPIO_PIN(PC, 7), .loc = USART_ROUTELOC0_RXLOC_LOC11 | USART_ROUTELOC0_TXLOC_LOC11, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_USART1, .irq = USART1_RX_IRQn }, @@ -204,9 +198,6 @@ static const uart_conf_t uart_config[] = { .tx_pin = GPIO_PIN(PD, 10), .loc = LEUART_ROUTELOC0_RXLOC_LOC18 | LEUART_ROUTELOC0_TXLOC_LOC18, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_LEUART0, .irq = LEUART0_IRQn } diff --git a/boards/slwstk6000b/include/periph_conf.h b/boards/slwstk6000b/include/periph_conf.h index 2e680a30a4f9..ee5ef981782b 100644 --- a/boards/slwstk6000b/include/periph_conf.h +++ b/boards/slwstk6000b/include/periph_conf.h @@ -173,9 +173,6 @@ static const uart_conf_t uart_config[] = { .tx_pin = MODULE_PIN_F6, .loc = USART_ROUTELOC0_RXLOC_LOC0 | USART_ROUTELOC0_TXLOC_LOC0, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_USART0, .irq = USART0_RX_IRQn } diff --git a/boards/stk3600/include/periph_conf.h b/boards/stk3600/include/periph_conf.h index 51d468195223..c3002a5e897e 100644 --- a/boards/stk3600/include/periph_conf.h +++ b/boards/stk3600/include/periph_conf.h @@ -234,9 +234,6 @@ static const uart_conf_t uart_config[] = { .rx_pin = GPIO_PIN(PE, 1), .tx_pin = GPIO_PIN(PE, 0), .loc = UART_ROUTE_LOCATION_LOC1, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_UART0, .irq = UART0_RX_IRQn }, @@ -245,9 +242,6 @@ static const uart_conf_t uart_config[] = { .rx_pin = GPIO_PIN(PD, 1), .tx_pin = GPIO_PIN(PD, 0), .loc = USART_ROUTE_LOCATION_LOC1, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_USART1, .irq = USART1_RX_IRQn }, @@ -256,9 +250,6 @@ static const uart_conf_t uart_config[] = { .rx_pin = GPIO_PIN(PD, 5), .tx_pin = GPIO_PIN(PD, 4), .loc = LEUART_ROUTE_LOCATION_LOC0, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_LEUART0, .irq = LEUART0_IRQn } diff --git a/boards/stk3700/include/periph_conf.h b/boards/stk3700/include/periph_conf.h index c1212e065915..30c8428d1161 100644 --- a/boards/stk3700/include/periph_conf.h +++ b/boards/stk3700/include/periph_conf.h @@ -234,9 +234,6 @@ static const uart_conf_t uart_config[] = { .rx_pin = GPIO_PIN(PE, 1), .tx_pin = GPIO_PIN(PE, 0), .loc = UART_ROUTE_LOCATION_LOC1, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_UART0, .irq = UART0_RX_IRQn }, @@ -245,9 +242,6 @@ static const uart_conf_t uart_config[] = { .rx_pin = GPIO_PIN(PD, 1), .tx_pin = GPIO_PIN(PD, 0), .loc = USART_ROUTE_LOCATION_LOC1, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_USART1, .irq = USART1_RX_IRQn }, @@ -256,9 +250,6 @@ static const uart_conf_t uart_config[] = { .rx_pin = GPIO_PIN(PD, 5), .tx_pin = GPIO_PIN(PD, 4), .loc = LEUART_ROUTE_LOCATION_LOC0, -#if EFM32_UART_MODES - .mode = UART_MODE_8N1, -#endif .cmu = cmuClock_LEUART0, .irq = LEUART0_IRQn } From 8fa920d04c9846379ffc5a09e0b4228f3f24a8f1 Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sat, 28 Sep 2019 12:02:58 +0200 Subject: [PATCH 2/4] pkg/gecko_sdk: update to newer version --- pkg/gecko_sdk/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/gecko_sdk/Makefile b/pkg/gecko_sdk/Makefile index 0d5f3b4c9e7e..551abab679fa 100644 --- a/pkg/gecko_sdk/Makefile +++ b/pkg/gecko_sdk/Makefile @@ -1,6 +1,6 @@ PKG_NAME=gecko_sdk PKG_URL=https://github.com/basilfx/RIOT-gecko-sdk -PKG_VERSION=50996be7377cec885954312b7d4caf61788aaa40 +PKG_VERSION=755f5430c05d95812603524f9aa7516964dd5758 PKG_LICENSE=Zlib ifneq ($(CPU),efm32) From 4e6b46ca20326a409481f7878bcb4daaa84a445b Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sat, 28 Sep 2019 12:03:35 +0200 Subject: [PATCH 3/4] cpu/efm32: implement uart_mode --- cpu/efm32/include/periph_cpu.h | 40 ++++++++++++++++++++++++++++++++++ cpu/efm32/periph/uart.c | 36 ++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/cpu/efm32/include/periph_cpu.h b/cpu/efm32/include/periph_cpu.h index a024187215ea..ca52b522f620 100644 --- a/cpu/efm32/include/periph_cpu.h +++ b/cpu/efm32/include/periph_cpu.h @@ -376,6 +376,46 @@ typedef struct { /** * @brief UART device configuration. */ +#ifndef DOXYGEN +/** + * @brief Override parity values + * @{ + */ +#define HAVE_UART_PARITY_T +typedef enum { + UART_PARITY_NONE = 0, + UART_PARITY_ODD = 1, + UART_PARITY_EVEN = 2, + UART_PARITY_MARK = 3, + UART_PARITY_SPACE = 4, +} uart_parity_t; +/** @} */ + +/** + * @brief Override data bits length values + * @{ + */ +#define HAVE_UART_DATA_BITS_T +typedef enum { + UART_DATA_BITS_5 = 5, + UART_DATA_BITS_6 = 6, + UART_DATA_BITS_7 = 7, + UART_DATA_BITS_8 = 8, +} uart_data_bits_t; +/** @} */ + +/** + * @brief Override stop bits length values + * @{ + */ +#define HAVE_UART_STOP_BITS_T +typedef enum { + UART_STOP_BITS_1 = 2, + UART_STOP_BITS_2 = 4, +} uart_stop_bits_t; +/** @} */ +#endif /* ndef DOXYGEN */ + typedef struct { void *dev; /**< UART, USART or LEUART device used */ gpio_t rx_pin; /**< pin used for RX */ diff --git a/cpu/efm32/periph/uart.c b/cpu/efm32/periph/uart.c index 8d0d5f72e14d..17f428400c46 100644 --- a/cpu/efm32/periph/uart.c +++ b/cpu/efm32/periph/uart.c @@ -154,6 +154,42 @@ int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg) return 0; } +#ifdef MODULE_PERIPH_UART_MODECFG +int uart_mode(uart_t dev, uart_data_bits_t data_bits, uart_parity_t parity, + uart_stop_bits_t stop_bits) +{ + if (parity == UART_PARITY_MARK || parity == UART_PARITY_SPACE) { + return UART_NOMODE; + } + +#ifdef USE_LEUART + if (_is_usart(dev)) { +#endif + USART_TypeDef *uart = (USART_TypeDef *) uart_config[dev].dev; + + USART_FrameSet(uart, + USART_DataBits2Def(data_bits), + USART_StopBits2Def(stop_bits), + USART_Parity2Def(parity)); +#ifdef USE_LEUART + } else { + if (data_bits != UART_DATA_BITS_8) { + return UART_NOMODE; + } + + LEUART_TypeDef *leuart = (LEUART_TypeDef *) uart_config[dev].dev; + + LEUART_FrameSet(leuart, + LEUART_DataBits2Def(data_bits), + LEUART_StopBits2Def(stop_bits), + LEUART_Parity2Def(parity)); + } +#endif + + return UART_OK; +} +#endif + void uart_write(uart_t dev, const uint8_t *data, size_t len) { #ifdef USE_LEUART From 559fc1fe04382ac34c77eb5efb56c707cc017ee3 Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sat, 28 Sep 2019 12:06:40 +0200 Subject: [PATCH 4/4] boards+efm32: provide periph_uart_modecfg --- boards/ikea-tradfri/Makefile.features | 2 +- boards/slstk3401a/Makefile.features | 2 +- boards/slstk3402a/Makefile.features | 2 +- boards/sltb001a/Makefile.features | 2 +- boards/slwstk6000b/Makefile.features | 2 +- boards/stk3600/Makefile.features | 2 +- boards/stk3700/Makefile.features | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/boards/ikea-tradfri/Makefile.features b/boards/ikea-tradfri/Makefile.features index a869a893f960..d03b3183b67f 100644 --- a/boards/ikea-tradfri/Makefile.features +++ b/boards/ikea-tradfri/Makefile.features @@ -7,4 +7,4 @@ FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer -FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += periph_uart periph_uart_modecfg diff --git a/boards/slstk3401a/Makefile.features b/boards/slstk3401a/Makefile.features index c062c756c941..5f4f50a88afa 100644 --- a/boards/slstk3401a/Makefile.features +++ b/boards/slstk3401a/Makefile.features @@ -9,6 +9,6 @@ FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer -FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += periph_uart periph_uart_modecfg include $(RIOTBOARD)/common/silabs/Makefile.features diff --git a/boards/slstk3402a/Makefile.features b/boards/slstk3402a/Makefile.features index 39f5c017bc79..64146736b0d7 100644 --- a/boards/slstk3402a/Makefile.features +++ b/boards/slstk3402a/Makefile.features @@ -9,6 +9,6 @@ FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer -FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += periph_uart periph_uart_modecfg include $(RIOTBOARD)/common/silabs/Makefile.features diff --git a/boards/sltb001a/Makefile.features b/boards/sltb001a/Makefile.features index 63a8013ec990..94136df1345d 100644 --- a/boards/sltb001a/Makefile.features +++ b/boards/sltb001a/Makefile.features @@ -9,6 +9,6 @@ FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer -FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += periph_uart periph_uart_modecfg include $(RIOTBOARD)/common/silabs/Makefile.features diff --git a/boards/slwstk6000b/Makefile.features b/boards/slwstk6000b/Makefile.features index 9266cb0b4303..aa52fa205f5e 100644 --- a/boards/slwstk6000b/Makefile.features +++ b/boards/slwstk6000b/Makefile.features @@ -6,7 +6,7 @@ FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer -FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += periph_uart periph_uart_modecfg include $(RIOTBOARD)/common/silabs/Makefile.features diff --git a/boards/stk3600/Makefile.features b/boards/stk3600/Makefile.features index 02dd454c3281..1f8d45238bd9 100644 --- a/boards/stk3600/Makefile.features +++ b/boards/stk3600/Makefile.features @@ -11,6 +11,6 @@ FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer -FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += periph_uart periph_uart_modecfg include $(RIOTBOARD)/common/silabs/Makefile.features diff --git a/boards/stk3700/Makefile.features b/boards/stk3700/Makefile.features index d6453d65eec3..38405db99427 100644 --- a/boards/stk3700/Makefile.features +++ b/boards/stk3700/Makefile.features @@ -11,6 +11,6 @@ FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer -FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += periph_uart periph_uart_modecfg include $(RIOTBOARD)/common/silabs/Makefile.features