drivers: serial: nrfx_uarte: Rework Kconfig to use instance template
Rework Kconfig to improve handling of multiple UART instances by using Kconfig template file. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
ad788ad511
commit
26fd55e0a7
3 changed files with 101 additions and 299 deletions
|
@ -36,291 +36,25 @@ config UART_ASYNC_TX_CACHE_SIZE
|
|||
in RAM, because EasyDMA in UARTE peripherals can only transfer data
|
||||
from RAM.
|
||||
|
||||
# ----------------- port 0 -----------------
|
||||
if HAS_HW_NRF_UART0 || HAS_HW_NRF_UARTE0
|
||||
nrfx_uart_num = 0
|
||||
rsource "Kconfig.nrfx_uart_instance"
|
||||
endif
|
||||
|
||||
config UART_0_ENHANCED_POLL_OUT
|
||||
bool "Efficient poll out on port 0"
|
||||
default y
|
||||
depends on HAS_HW_NRF_UARTE0
|
||||
help
|
||||
When enabled, polling out does not trigger interrupt which stops TX.
|
||||
Feature uses a PPI channel.
|
||||
|
||||
config UART_0_INTERRUPT_DRIVEN
|
||||
bool "Interrupt support on port 0"
|
||||
depends on UART_INTERRUPT_DRIVEN
|
||||
default y
|
||||
help
|
||||
This option enables UART interrupt support on port 0.
|
||||
|
||||
config UART_0_ASYNC
|
||||
bool "Asynchronous API support on port 0"
|
||||
depends on UART_ASYNC_API && !UART_0_INTERRUPT_DRIVEN
|
||||
default y
|
||||
help
|
||||
This option enables UART Asynchronous API support on port 0.
|
||||
|
||||
config UART_0_NRF_PARITY_BIT
|
||||
bool "Parity bit"
|
||||
help
|
||||
Enable parity bit.
|
||||
|
||||
config UART_0_NRF_TX_BUFFER_SIZE
|
||||
int "Size of RAM buffer"
|
||||
depends on HAS_HW_NRF_UARTE0
|
||||
range 1 65535
|
||||
default 32
|
||||
help
|
||||
Size of the transmit buffer for API function: fifo_fill.
|
||||
This value is limited by range of TXD.MAXCNT register for
|
||||
particular SoC.
|
||||
|
||||
config UART_0_NRF_HW_ASYNC
|
||||
bool "Use hardware RX byte counting"
|
||||
depends on HAS_HW_NRF_UARTE0
|
||||
depends on UART_ASYNC_API
|
||||
help
|
||||
If default driver uses interrupts to count incoming bytes, it is possible
|
||||
that with higher speeds and/or high cpu load some data can be lost.
|
||||
It is recommended to use hardware byte counting in such scenarios.
|
||||
Hardware RX byte counting requires timer instance and one PPI channel
|
||||
|
||||
config UART_0_NRF_ASYNC_LOW_POWER
|
||||
bool "Low power mode"
|
||||
depends on HAS_HW_NRF_UARTE0
|
||||
depends on UART_ASYNC_API
|
||||
help
|
||||
When enabled, UARTE is enabled before each TX or RX usage and disabled
|
||||
when not used. Disabling UARTE while in idle allows to achieve lowest
|
||||
power consumption. It is only feasible if receiver is not always on.
|
||||
|
||||
config UART_0_NRF_HW_ASYNC_TIMER
|
||||
int "Timer instance"
|
||||
depends on UART_0_NRF_HW_ASYNC
|
||||
|
||||
config UART_0_GPIO_MANAGEMENT
|
||||
bool "GPIO management on port 0"
|
||||
depends on PM_DEVICE
|
||||
default y
|
||||
help
|
||||
If enabled, the driver will configure the GPIOs used by the uart to
|
||||
their default configuration when device is powered down. The GPIOs
|
||||
will be configured back to correct state when UART is powered up.
|
||||
|
||||
endif # HAS_HW_NRF_UART0 || HAS_HW_NRF_UARTE0
|
||||
|
||||
# ----------------- port 1 -----------------
|
||||
if HAS_HW_NRF_UARTE1
|
||||
nrfx_uart_num = 1
|
||||
rsource "Kconfig.nrfx_uart_instance"
|
||||
endif
|
||||
|
||||
config UART_1_INTERRUPT_DRIVEN
|
||||
bool "Interrupt support on port 1"
|
||||
depends on UART_INTERRUPT_DRIVEN
|
||||
default y
|
||||
help
|
||||
This option enables UART interrupt support on port 1.
|
||||
|
||||
config UART_1_ASYNC
|
||||
bool "Asynchronous API support on port 1"
|
||||
depends on UART_ASYNC_API && !UART_1_INTERRUPT_DRIVEN
|
||||
default y
|
||||
help
|
||||
This option enables UART Asynchronous API support on port 1.
|
||||
|
||||
config UART_1_ENHANCED_POLL_OUT
|
||||
bool "Efficient poll out on port 1"
|
||||
default y
|
||||
help
|
||||
When enabled, polling out does not trigger interrupt which stops TX.
|
||||
Feature uses a PPI channel.
|
||||
|
||||
config UART_1_NRF_PARITY_BIT
|
||||
bool "Parity bit"
|
||||
help
|
||||
Enable parity bit.
|
||||
|
||||
config UART_1_NRF_TX_BUFFER_SIZE
|
||||
int "Size of RAM buffer"
|
||||
depends on UART_INTERRUPT_DRIVEN
|
||||
range 1 65535
|
||||
default 32
|
||||
help
|
||||
Size of the transmit buffer for API function: fifo_fill.
|
||||
This value is limited by range of TXD.MAXCNT register for
|
||||
particular SoC.
|
||||
|
||||
config UART_1_NRF_HW_ASYNC
|
||||
bool "Use hardware RX byte counting"
|
||||
depends on UART_1_ASYNC
|
||||
help
|
||||
If default driver uses interrupts to count incoming bytes, it is possible
|
||||
that with higher speeds and/or high cpu load some data can be lost.
|
||||
It is recommended to use hardware byte counting in such scenarios.
|
||||
Hardware RX byte counting requires timer instance and one PPI channel
|
||||
|
||||
config UART_1_NRF_ASYNC_LOW_POWER
|
||||
bool "Low power mode"
|
||||
depends on UART_ASYNC_API
|
||||
help
|
||||
When enabled, UARTE is enabled before each TX or RX usage and disabled
|
||||
when not used. Disabling UARTE while in idle allows to achieve lowest
|
||||
power consumption. It is only feasible if receiver is not always on.
|
||||
|
||||
config UART_1_NRF_HW_ASYNC_TIMER
|
||||
int "Timer instance"
|
||||
depends on UART_1_NRF_HW_ASYNC
|
||||
|
||||
config UART_1_GPIO_MANAGEMENT
|
||||
bool "GPIO management on port 1"
|
||||
depends on PM_DEVICE
|
||||
default y
|
||||
help
|
||||
If enabled, the driver will configure the GPIOs used by the uart to
|
||||
their default configuration when device is powered down. The GPIOs
|
||||
will be configured back to correct state when UART is powered up.
|
||||
|
||||
endif # HAS_HW_NRF_UARTE1
|
||||
|
||||
# ----------------- port 2 -----------------
|
||||
if HAS_HW_NRF_UARTE2
|
||||
nrfx_uart_num = 2
|
||||
rsource "Kconfig.nrfx_uart_instance"
|
||||
endif
|
||||
|
||||
config UART_2_INTERRUPT_DRIVEN
|
||||
bool "Interrupt support on port 2"
|
||||
depends on UART_INTERRUPT_DRIVEN
|
||||
default y
|
||||
help
|
||||
This option enables UART interrupt support on port 2.
|
||||
|
||||
config UART_2_ASYNC
|
||||
bool "Asynchronous API support on port 2"
|
||||
depends on UART_ASYNC_API && !UART_2_INTERRUPT_DRIVEN
|
||||
default y
|
||||
help
|
||||
This option enables UART Asynchronous API support on port 2.
|
||||
|
||||
config UART_2_ENHANCED_POLL_OUT
|
||||
bool "Efficient poll out on port 2"
|
||||
default y
|
||||
help
|
||||
When enabled, polling out does not trigger interrupt which stops TX.
|
||||
Feature uses a PPI channel.
|
||||
|
||||
config UART_2_NRF_PARITY_BIT
|
||||
bool "Parity bit"
|
||||
help
|
||||
Enable parity bit.
|
||||
|
||||
config UART_2_NRF_TX_BUFFER_SIZE
|
||||
int "Size of RAM buffer"
|
||||
range 1 65535
|
||||
default 32
|
||||
help
|
||||
Size of the transmit buffer for API function: fifo_fill.
|
||||
This value is limited by range of TXD.MAXCNT register for
|
||||
particular SoC.
|
||||
|
||||
config UART_2_NRF_HW_ASYNC
|
||||
bool "Use hardware RX byte counting"
|
||||
depends on UART_2_ASYNC
|
||||
help
|
||||
If default driver uses interrupts to count incoming bytes, it is possible
|
||||
that with higher speeds and/or high cpu load some data can be lost.
|
||||
It is recommended to use hardware byte counting in such scenarios.
|
||||
Hardware RX byte counting requires timer instance and one PPI channel
|
||||
|
||||
config UART_2_NRF_ASYNC_LOW_POWER
|
||||
bool "Low power mode"
|
||||
depends on UART_ASYNC_API
|
||||
help
|
||||
When enabled, UARTE is enabled before each TX or RX usage and disabled
|
||||
when not used. Disabling UARTE while in idle allows to achieve lowest
|
||||
power consumption. It is only feasible if receiver is not always on.
|
||||
|
||||
config UART_2_NRF_HW_ASYNC_TIMER
|
||||
int "Timer instance"
|
||||
depends on UART_2_NRF_HW_ASYNC
|
||||
|
||||
config UART_2_GPIO_MANAGEMENT
|
||||
bool "GPIO management on port 2"
|
||||
depends on PM_DEVICE
|
||||
default y
|
||||
help
|
||||
If enabled, the driver will configure the GPIOs used by the uart to
|
||||
their default configuration when device is powered down. The GPIOs
|
||||
will be configured back to correct state when UART is powered up.
|
||||
|
||||
endif # HAS_HW_NRF_UARTE2
|
||||
|
||||
# ----------------- port 3 -----------------
|
||||
if HAS_HW_NRF_UARTE3
|
||||
|
||||
config UART_3_INTERRUPT_DRIVEN
|
||||
bool "Interrupt support on port 3"
|
||||
depends on UART_INTERRUPT_DRIVEN
|
||||
default y
|
||||
help
|
||||
This option enables UART interrupt support on port 3.
|
||||
|
||||
config UART_3_ASYNC
|
||||
bool "Asynchronous API support on port 3"
|
||||
depends on UART_ASYNC_API && !UART_3_INTERRUPT_DRIVEN
|
||||
default y
|
||||
help
|
||||
This option enables UART Asynchronous API support on port 3.
|
||||
|
||||
config UART_3_ENHANCED_POLL_OUT
|
||||
bool "Efficient poll out on port 3"
|
||||
default y
|
||||
help
|
||||
When enabled, polling out does not trigger interrupt which stops TX.
|
||||
Feature uses a PPI channel.
|
||||
|
||||
config UART_3_NRF_PARITY_BIT
|
||||
bool "Parity bit"
|
||||
help
|
||||
Enable parity bit.
|
||||
|
||||
config UART_3_NRF_TX_BUFFER_SIZE
|
||||
int "Size of RAM buffer"
|
||||
range 1 65535
|
||||
default 32
|
||||
help
|
||||
Size of the transmit buffer for API function: fifo_fill.
|
||||
This value is limited by range of TXD.MAXCNT register for
|
||||
particular SoC.
|
||||
|
||||
config UART_3_NRF_HW_ASYNC
|
||||
bool "Use hardware RX byte counting"
|
||||
depends on UART_3_ASYNC
|
||||
help
|
||||
If default driver uses interrupts to count incoming bytes, it is possible
|
||||
that with higher speeds and/or high cpu load some data can be lost.
|
||||
It is recommended to use hardware byte counting in such scenarios.
|
||||
Hardware RX byte counting requires timer instance and one PPI channel
|
||||
|
||||
config UART_3_NRF_ASYNC_LOW_POWER
|
||||
bool "Low power mode"
|
||||
depends on UART_ASYNC_API
|
||||
help
|
||||
When enabled, UARTE is enabled before each TX or RX usage and disabled
|
||||
when not used. Disabling UARTE while in idle allows to achieve lowest
|
||||
power consumption. It is only feasible if receiver is not always on.
|
||||
|
||||
config UART_3_NRF_HW_ASYNC_TIMER
|
||||
int "Timer instance"
|
||||
depends on UART_3_NRF_HW_ASYNC
|
||||
|
||||
config UART_3_GPIO_MANAGEMENT
|
||||
bool "GPIO management on port 3"
|
||||
depends on PM_DEVICE
|
||||
default y
|
||||
help
|
||||
If enabled, the driver will configure the GPIOs used by the uart to
|
||||
their default configuration when device is powered down. The GPIOs
|
||||
will be configured back to correct state when UART is powered up.
|
||||
|
||||
endif # HAS_HW_NRF_UARTE3
|
||||
|
||||
nrfx_uart_num = 3
|
||||
rsource "Kconfig.nrfx_uart_instance"
|
||||
endif
|
||||
|
||||
config NRFX_TIMER0
|
||||
default y
|
||||
|
@ -357,23 +91,4 @@ config NRFX_TIMER4
|
|||
|| UART_2_NRF_HW_ASYNC_TIMER = 4 \
|
||||
|| UART_3_NRF_HW_ASYNC_TIMER = 4
|
||||
|
||||
|
||||
config UARTE_NRF_HW_ASYNC
|
||||
def_bool y
|
||||
depends on UART_0_NRF_HW_ASYNC \
|
||||
|| UART_1_NRF_HW_ASYNC \
|
||||
|| UART_2_NRF_HW_ASYNC \
|
||||
|| UART_3_NRF_HW_ASYNC
|
||||
select NRFX_PPI if HAS_HW_NRF_PPI
|
||||
select NRFX_DPPI if HAS_HW_NRF_DPPIC
|
||||
|
||||
config UART_ENHANCED_POLL_OUT
|
||||
def_bool y
|
||||
depends on UART_0_ENHANCED_POLL_OUT \
|
||||
|| UART_1_ENHANCED_POLL_OUT \
|
||||
|| UART_2_ENHANCED_POLL_OUT \
|
||||
|| UART_3_ENHANCED_POLL_OUT
|
||||
select NRFX_PPI if HAS_HW_NRF_PPI
|
||||
select NRFX_DPPI if HAS_HW_NRF_DPPIC
|
||||
|
||||
endif # UART_NRFX
|
||||
|
|
77
drivers/serial/Kconfig.nrfx_uart_instance
Normal file
77
drivers/serial/Kconfig.nrfx_uart_instance
Normal file
|
@ -0,0 +1,77 @@
|
|||
#nRF UART(E) instance configuration
|
||||
|
||||
# Copyright (c) 2023 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config UART_$(nrfx_uart_num)_INTERRUPT_DRIVEN
|
||||
bool "Interrupt support on port $(nrfx_uart_num)"
|
||||
depends on UART_INTERRUPT_DRIVEN
|
||||
default y
|
||||
help
|
||||
This option enables UART interrupt support on port $(nrfx_uart_num).
|
||||
|
||||
config UART_$(nrfx_uart_num)_ASYNC
|
||||
bool "Asynchronous API support on port $(nrfx_uart_num)"
|
||||
depends on UART_ASYNC_API && !UART_$(nrfx_uart_num)_INTERRUPT_DRIVEN
|
||||
default y
|
||||
help
|
||||
This option enables UART Asynchronous API support on port $(nrfx_uart_num).
|
||||
|
||||
config UART_$(nrfx_uart_num)_ENHANCED_POLL_OUT
|
||||
bool "Efficient poll out on port $(nrfx_uart_num)"
|
||||
default y
|
||||
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
|
||||
select NRFX_PPI if HAS_HW_NRF_PPI
|
||||
select NRFX_DPPI if HAS_HW_NRF_DPPIC
|
||||
help
|
||||
When enabled, polling out does not trigger interrupt which stops TX.
|
||||
Feature uses a PPI channel.
|
||||
|
||||
config UART_$(nrfx_uart_num)_NRF_PARITY_BIT
|
||||
bool "Parity bit"
|
||||
help
|
||||
Enable parity bit.
|
||||
|
||||
config UART_$(nrfx_uart_num)_NRF_TX_BUFFER_SIZE
|
||||
int "Size of RAM buffer"
|
||||
depends on UART_INTERRUPT_DRIVEN
|
||||
range 1 65535
|
||||
default 32
|
||||
help
|
||||
Size of the transmit buffer for API function: fifo_fill.
|
||||
This value is limited by range of TXD.MAXCNT register for
|
||||
particular SoC.
|
||||
|
||||
config UART_$(nrfx_uart_num)_NRF_HW_ASYNC
|
||||
bool "Use hardware RX byte counting"
|
||||
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
|
||||
depends on UART_ASYNC_API
|
||||
select NRFX_PPI if HAS_HW_NRF_PPI
|
||||
select NRFX_DPPI if HAS_HW_NRF_DPPIC
|
||||
help
|
||||
If default driver uses interrupts to count incoming bytes, it is possible
|
||||
that with higher speeds and/or high cpu load some data can be lost.
|
||||
It is recommended to use hardware byte counting in such scenarios.
|
||||
Hardware RX byte counting requires timer instance and one PPI channel.
|
||||
|
||||
config UART_$(nrfx_uart_num)_NRF_ASYNC_LOW_POWER
|
||||
bool "Low power mode"
|
||||
depends on HAS_HW_NRF_UARTE$(nrfx_uart_num)
|
||||
depends on UART_ASYNC_API
|
||||
help
|
||||
When enabled, UARTE is enabled before each TX or RX usage and disabled
|
||||
when not used. Disabling UARTE while in idle allows to achieve lowest
|
||||
power consumption. It is only feasible if receiver is not always on.
|
||||
|
||||
config UART_$(nrfx_uart_num)_NRF_HW_ASYNC_TIMER
|
||||
int "Timer instance"
|
||||
depends on UART_$(nrfx_uart_num)_NRF_HW_ASYNC
|
||||
|
||||
config UART_$(nrfx_uart_num)_GPIO_MANAGEMENT
|
||||
bool "GPIO management on port $(nrfx_uart_num)"
|
||||
depends on PM_DEVICE
|
||||
default y
|
||||
help
|
||||
If enabled, the driver will configure the GPIOs used by the uart to
|
||||
their default configuration when device is powered down. The GPIOs
|
||||
will be configured back to correct state when UART is powered up.
|
|
@ -65,6 +65,16 @@ LOG_MODULE_REGISTER(uart_nrfx_uarte, CONFIG_UART_LOG_LEVEL);
|
|||
#define UARTE_ANY_ASYNC 1
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_UART_0_NRF_HW_ASYNC) || defined(CONFIG_UART_1_NRF_HW_ASYNC) || \
|
||||
defined(CONFIG_UART_2_NRF_HW_ASYNC) || defined(CONFIG_UART_3_NRF_HW_ASYNC)
|
||||
#define UARTE_HW_ASYNC 1
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_UART_0_ENHANCED_POLL_OUT) || defined(CONFIG_UART_1_ENHANCED_POLL_OUT) || \
|
||||
defined(CONFIG_UART_2_ENHANCED_POLL_OUT) || defined(CONFIG_UART_3_ENHANCED_POLL_OUT)
|
||||
#define UARTE_ENHANCED_POLL_OUT 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* RX timeout is divided into time slabs, this define tells how many divisions
|
||||
* should be made. More divisions - higher timeout accuracy and processor usage.
|
||||
|
@ -498,7 +508,7 @@ static int wait_tx_ready(const struct device *dev)
|
|||
* where static inline fails on linking.
|
||||
*/
|
||||
#define HW_RX_COUNTING_ENABLED(data) \
|
||||
(IS_ENABLED(CONFIG_UARTE_NRF_HW_ASYNC) ? data->async->hw_rx_counting : false)
|
||||
(IS_ENABLED(UARTE_HW_ASYNC) ? data->async->hw_rx_counting : false)
|
||||
|
||||
#endif /* UARTE_ANY_ASYNC */
|
||||
|
||||
|
@ -1745,7 +1755,7 @@ static int uarte_instance_init(const struct device *dev,
|
|||
return err;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_UART_ENHANCED_POLL_OUT) &&
|
||||
if (IS_ENABLED(UARTE_ENHANCED_POLL_OUT) &&
|
||||
cfg->flags & UARTE_CFG_FLAG_PPI_ENDTX) {
|
||||
err = endtx_stoptx_ppi_init(uarte, data);
|
||||
if (err < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue