cpu: efm32: move LOW_POWER_ENABLED to efm32-features.mk
This commit is contained in:
parent
6cbb7ad1a0
commit
b2769c0857
@ -15,4 +15,8 @@ ifeq (1,$(EFM32_UART_MODES))
|
|||||||
CFLAGS += -DEFM32_UART_MODES=1
|
CFLAGS += -DEFM32_UART_MODES=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq (1,$(EFM32_LEUART_ENABLED))
|
||||||
|
CFLAGS += -DEFM32_LEUART_ENABLED=1
|
||||||
|
endif
|
||||||
|
|
||||||
include $(RIOTCPU)/cortexm_common/Makefile.features
|
include $(RIOTCPU)/cortexm_common/Makefile.features
|
||||||
|
|||||||
@ -62,7 +62,12 @@
|
|||||||
* =======================
|
* =======================
|
||||||
*
|
*
|
||||||
* The EFM32/EFR32/EZR32 MCUs have support for low-power peripherals. Support
|
* The EFM32/EFR32/EZR32 MCUs have support for low-power peripherals. Support
|
||||||
* is enabled by default, but can be disabled by setting LOW_POWER_ENABLED=0.
|
* is enabled by default, but can be disabled if not used.
|
||||||
|
*
|
||||||
|
* - Setting `EFM32_LEUART_ENABLED=0` will disable support for the LEUART
|
||||||
|
* in the UART driver peripheral and save approximately 400 bytes.
|
||||||
|
*
|
||||||
|
* Refer to `cpu/efm32/efm32-features.mk` for more options.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2,3 +2,4 @@
|
|||||||
# should override them from the command line, or in your Makefile. Note that
|
# 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.
|
# some features may not be applicable to all EFM32 boards or CPUs.
|
||||||
export EFM32_UART_MODES ?= 0
|
export EFM32_UART_MODES ?= 0
|
||||||
|
export EFM32_LEUART_ENABLED ?= 1
|
||||||
|
|||||||
@ -38,15 +38,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable support for Low-power peripherals (if supported by CPU).
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#ifndef LOW_POWER_ENABLED
|
|
||||||
#define LOW_POWER_ENABLED (1)
|
|
||||||
#endif
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Internal macro for combining ADC resolution (x) with number of
|
* @brief Internal macro for combining ADC resolution (x) with number of
|
||||||
* shifts (y).
|
* shifts (y).
|
||||||
|
|||||||
@ -27,7 +27,15 @@
|
|||||||
|
|
||||||
#include "em_usart.h"
|
#include "em_usart.h"
|
||||||
#include "em_usart_utils.h"
|
#include "em_usart_utils.h"
|
||||||
#if LOW_POWER_ENABLED && defined(LEUART_COUNT) && LEUART_COUNT > 0
|
|
||||||
|
/**
|
||||||
|
* @brief Defines whether LEUART is enabled and supported
|
||||||
|
*/
|
||||||
|
#if EFM32_LEUART_ENABLED && defined(LEUART_COUNT) && LEUART_COUNT > 0
|
||||||
|
#define USE_LEUART
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_LEUART
|
||||||
#include "em_leuart.h"
|
#include "em_leuart.h"
|
||||||
#include "em_leuart_utils.h"
|
#include "em_leuart_utils.h"
|
||||||
#endif
|
#endif
|
||||||
@ -37,6 +45,7 @@
|
|||||||
*/
|
*/
|
||||||
static uart_isr_ctx_t isr_ctx[UART_NUMOF];
|
static uart_isr_ctx_t isr_ctx[UART_NUMOF];
|
||||||
|
|
||||||
|
#ifdef USE_LEUART
|
||||||
/**
|
/**
|
||||||
* @brief Check if device is a U(S)ART device.
|
* @brief Check if device is a U(S)ART device.
|
||||||
*/
|
*/
|
||||||
@ -44,6 +53,7 @@ static inline bool _is_usart(uart_t dev)
|
|||||||
{
|
{
|
||||||
return ((uint32_t) uart_config[dev].dev) < LEUART0_BASE;
|
return ((uint32_t) uart_config[dev].dev) < LEUART0_BASE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
||||||
{
|
{
|
||||||
@ -61,7 +71,7 @@ int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
|||||||
gpio_init(uart_config[dev].tx_pin, GPIO_OUT);
|
gpio_init(uart_config[dev].tx_pin, GPIO_OUT);
|
||||||
|
|
||||||
/* initialize the UART/USART/LEUART device */
|
/* initialize the UART/USART/LEUART device */
|
||||||
#if LOW_POWER_ENABLED && defined(LEUART_COUNT) && LEUART_COUNT > 0
|
#ifdef USE_LEUART
|
||||||
if (_is_usart(dev)) {
|
if (_is_usart(dev)) {
|
||||||
#endif
|
#endif
|
||||||
USART_TypeDef *uart = (USART_TypeDef *) uart_config[dev].dev;
|
USART_TypeDef *uart = (USART_TypeDef *) uart_config[dev].dev;
|
||||||
@ -98,7 +108,7 @@ int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
|||||||
|
|
||||||
/* enable peripheral */
|
/* enable peripheral */
|
||||||
USART_Enable(uart, usartEnable);
|
USART_Enable(uart, usartEnable);
|
||||||
#if LOW_POWER_ENABLED && defined(LEUART_COUNT) && LEUART_COUNT > 0
|
#ifdef USE_LEUART
|
||||||
} else {
|
} else {
|
||||||
LEUART_TypeDef *leuart = (LEUART_TypeDef *) uart_config[dev].dev;
|
LEUART_TypeDef *leuart = (LEUART_TypeDef *) uart_config[dev].dev;
|
||||||
|
|
||||||
@ -146,13 +156,13 @@ int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
|||||||
|
|
||||||
void uart_write(uart_t dev, const uint8_t *data, size_t len)
|
void uart_write(uart_t dev, const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
#if LOW_POWER_ENABLED && defined(LEUART_COUNT) && LEUART_COUNT > 0
|
#ifdef USE_LEUART
|
||||||
if (_is_usart(dev)) {
|
if (_is_usart(dev)) {
|
||||||
#endif
|
#endif
|
||||||
while (len--) {
|
while (len--) {
|
||||||
USART_Tx(uart_config[dev].dev, *(data++));
|
USART_Tx(uart_config[dev].dev, *(data++));
|
||||||
}
|
}
|
||||||
#if LOW_POWER_ENABLED && defined(LEUART_COUNT) && LEUART_COUNT > 0
|
#ifdef USE_LEUART
|
||||||
} else {
|
} else {
|
||||||
while (len--) {
|
while (len--) {
|
||||||
LEUART_Tx(uart_config[dev].dev, *(data++));
|
LEUART_Tx(uart_config[dev].dev, *(data++));
|
||||||
@ -173,13 +183,13 @@ void uart_poweroff(uart_t dev)
|
|||||||
|
|
||||||
static void rx_irq(uart_t dev)
|
static void rx_irq(uart_t dev)
|
||||||
{
|
{
|
||||||
#if LOW_POWER_ENABLED && defined(LEUART_COUNT) && LEUART_COUNT > 0
|
#ifdef USE_LEUART
|
||||||
if (_is_usart(dev)) {
|
if (_is_usart(dev)) {
|
||||||
#endif
|
#endif
|
||||||
if (USART_IntGet(uart_config[dev].dev) & USART_IF_RXDATAV) {
|
if (USART_IntGet(uart_config[dev].dev) & USART_IF_RXDATAV) {
|
||||||
isr_ctx[dev].rx_cb(isr_ctx[dev].arg, USART_RxDataGet(uart_config[dev].dev));
|
isr_ctx[dev].rx_cb(isr_ctx[dev].arg, USART_RxDataGet(uart_config[dev].dev));
|
||||||
}
|
}
|
||||||
#if LOW_POWER_ENABLED && defined(LEUART_COUNT) && LEUART_COUNT > 0
|
#ifdef USE_LEUART
|
||||||
} else {
|
} else {
|
||||||
if (LEUART_IntGet(uart_config[dev].dev) & LEUART_IF_RXDATAV) {
|
if (LEUART_IntGet(uart_config[dev].dev) & LEUART_IF_RXDATAV) {
|
||||||
isr_ctx[dev].rx_cb(isr_ctx[dev].arg, LEUART_RxDataGet(uart_config[dev].dev));
|
isr_ctx[dev].rx_cb(isr_ctx[dev].arg, LEUART_RxDataGet(uart_config[dev].dev));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user