cpu: efm32: add support for non-standard UART modes.
This commit is contained in:
parent
63ca613012
commit
0c47233f97
@ -1,3 +1,5 @@
|
|||||||
|
include $(RIOTCPU)/efm32/efm32-features.mk
|
||||||
|
|
||||||
FEATURES_PROVIDED += periph_cpuid
|
FEATURES_PROVIDED += periph_cpuid
|
||||||
FEATURES_PROVIDED += periph_flashpage
|
FEATURES_PROVIDED += periph_flashpage
|
||||||
|
|
||||||
@ -8,4 +10,8 @@ ifeq (1,$(EFM32_TNRG))
|
|||||||
FEATURES_PROVIDED += periph_hwrng
|
FEATURES_PROVIDED += periph_hwrng
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq (1,$(EFM32_UART_MODES))
|
||||||
|
export CFLAGS += -DEFM32_UART_MODES=1
|
||||||
|
endif
|
||||||
|
|
||||||
include $(RIOTCPU)/cortexm_common/Makefile.features
|
include $(RIOTCPU)/cortexm_common/Makefile.features
|
||||||
|
|||||||
4
cpu/efm32/efm32-features.mk
Normal file
4
cpu/efm32/efm32-features.mk
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# This file provides defaults for additional EFM32-specific features. You
|
||||||
|
# should override them from the command line, or in your Makefile. Note that
|
||||||
|
# some features may not be applicable to all EFM32 boards or CPUs.
|
||||||
|
export EFM32_UART_MODES ?= 0
|
||||||
@ -359,6 +359,20 @@ typedef struct {
|
|||||||
} timer_conf_t;
|
} timer_conf_t;
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal macro for combining UART modes data bits (x), stop bits
|
||||||
|
* (y, in half bits) and parity (z).
|
||||||
|
*/
|
||||||
|
#define UART_MODE(x, y, z) ((z << 8) | ((y * 2) << 4) | x)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Internal, pre-defined UART modes.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define UART_MODE_8N1 UART_MODE(8, 1, 0)
|
||||||
|
#define UART_MODE_8E1 UART_MODE(8, 1, 2)
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief UART device configuration.
|
* @brief UART device configuration.
|
||||||
*/
|
*/
|
||||||
@ -366,7 +380,10 @@ typedef struct {
|
|||||||
void *dev; /**< UART, USART or LEUART device used */
|
void *dev; /**< UART, USART or LEUART device used */
|
||||||
gpio_t rx_pin; /**< pin used for RX */
|
gpio_t rx_pin; /**< pin used for RX */
|
||||||
gpio_t tx_pin; /**< pin used for TX */
|
gpio_t tx_pin; /**< pin used for TX */
|
||||||
uint32_t loc; /**< location of USART pins */
|
uint32_t loc; /**< location of UART pins */
|
||||||
|
#if EFM32_UART_MODES
|
||||||
|
uint32_t mode; /**< UART mode of operation */
|
||||||
|
#endif
|
||||||
CMU_Clock_TypeDef cmu; /**< the device CMU channel */
|
CMU_Clock_TypeDef cmu; /**< the device CMU channel */
|
||||||
IRQn_Type irq; /**< the devices base IRQ channel */
|
IRQn_Type irq; /**< the devices base IRQ channel */
|
||||||
} uart_conf_t;
|
} uart_conf_t;
|
||||||
|
|||||||
@ -26,8 +26,10 @@
|
|||||||
#include "periph/gpio.h"
|
#include "periph/gpio.h"
|
||||||
|
|
||||||
#include "em_usart.h"
|
#include "em_usart.h"
|
||||||
|
#include "em_usart_utils.h"
|
||||||
#if LOW_POWER_ENABLED && defined(LEUART_COUNT) && LEUART_COUNT > 0
|
#if LOW_POWER_ENABLED && defined(LEUART_COUNT) && LEUART_COUNT > 0
|
||||||
#include "em_leuart.h"
|
#include "em_leuart.h"
|
||||||
|
#include "em_leuart_utils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,6 +75,11 @@ int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
|||||||
|
|
||||||
init.enable = usartDisable;
|
init.enable = usartDisable;
|
||||||
init.baudrate = baudrate;
|
init.baudrate = baudrate;
|
||||||
|
#if EFM32_UART_MODES
|
||||||
|
init.databits = USART_DataBits2Def((uart_config[dev].mode >> 0) & 0xf);
|
||||||
|
init.stopbits = USART_StopBits2Def((uart_config[dev].mode >> 4) & 0xf);
|
||||||
|
init.parity = USART_Parity2Def((uart_config[dev].mode >> 8) & 0xf);
|
||||||
|
#endif
|
||||||
|
|
||||||
USART_InitAsync(uart, &init);
|
USART_InitAsync(uart, &init);
|
||||||
|
|
||||||
@ -104,6 +111,11 @@ int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
|||||||
|
|
||||||
init.enable = leuartDisable;
|
init.enable = leuartDisable;
|
||||||
init.baudrate = baudrate;
|
init.baudrate = baudrate;
|
||||||
|
#if EFM32_UART_MODES
|
||||||
|
init.databits = LEUART_DataBits2Def((uart_config[dev].mode >> 0) & 0xf);
|
||||||
|
init.stopbits = LEUART_StopBits2Def((uart_config[dev].mode >> 4) & 0xf);
|
||||||
|
init.parity = LEUART_Parity2Def((uart_config[dev].mode >> 8) & 0xf);
|
||||||
|
#endif
|
||||||
|
|
||||||
LEUART_Init(leuart, &init);
|
LEUART_Init(leuart, &init);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user