Skip to content

Commit 26fd55e

Browse files
nordic-krchcarlescufi
authored andcommitted
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 <[email protected]>
1 parent ad788ad commit 26fd55e

File tree

3 files changed

+101
-299
lines changed

3 files changed

+101
-299
lines changed

drivers/serial/Kconfig.nrfx

Lines changed: 12 additions & 297 deletions
Original file line numberDiff line numberDiff line change
@@ -36,291 +36,25 @@ config UART_ASYNC_TX_CACHE_SIZE
3636
in RAM, because EasyDMA in UARTE peripherals can only transfer data
3737
from RAM.
3838

39-
# ----------------- port 0 -----------------
4039
if HAS_HW_NRF_UART0 || HAS_HW_NRF_UARTE0
40+
nrfx_uart_num = 0
41+
rsource "Kconfig.nrfx_uart_instance"
42+
endif
4143

42-
config UART_0_ENHANCED_POLL_OUT
43-
bool "Efficient poll out on port 0"
44-
default y
45-
depends on HAS_HW_NRF_UARTE0
46-
help
47-
When enabled, polling out does not trigger interrupt which stops TX.
48-
Feature uses a PPI channel.
49-
50-
config UART_0_INTERRUPT_DRIVEN
51-
bool "Interrupt support on port 0"
52-
depends on UART_INTERRUPT_DRIVEN
53-
default y
54-
help
55-
This option enables UART interrupt support on port 0.
56-
57-
config UART_0_ASYNC
58-
bool "Asynchronous API support on port 0"
59-
depends on UART_ASYNC_API && !UART_0_INTERRUPT_DRIVEN
60-
default y
61-
help
62-
This option enables UART Asynchronous API support on port 0.
63-
64-
config UART_0_NRF_PARITY_BIT
65-
bool "Parity bit"
66-
help
67-
Enable parity bit.
68-
69-
config UART_0_NRF_TX_BUFFER_SIZE
70-
int "Size of RAM buffer"
71-
depends on HAS_HW_NRF_UARTE0
72-
range 1 65535
73-
default 32
74-
help
75-
Size of the transmit buffer for API function: fifo_fill.
76-
This value is limited by range of TXD.MAXCNT register for
77-
particular SoC.
78-
79-
config UART_0_NRF_HW_ASYNC
80-
bool "Use hardware RX byte counting"
81-
depends on HAS_HW_NRF_UARTE0
82-
depends on UART_ASYNC_API
83-
help
84-
If default driver uses interrupts to count incoming bytes, it is possible
85-
that with higher speeds and/or high cpu load some data can be lost.
86-
It is recommended to use hardware byte counting in such scenarios.
87-
Hardware RX byte counting requires timer instance and one PPI channel
88-
89-
config UART_0_NRF_ASYNC_LOW_POWER
90-
bool "Low power mode"
91-
depends on HAS_HW_NRF_UARTE0
92-
depends on UART_ASYNC_API
93-
help
94-
When enabled, UARTE is enabled before each TX or RX usage and disabled
95-
when not used. Disabling UARTE while in idle allows to achieve lowest
96-
power consumption. It is only feasible if receiver is not always on.
97-
98-
config UART_0_NRF_HW_ASYNC_TIMER
99-
int "Timer instance"
100-
depends on UART_0_NRF_HW_ASYNC
101-
102-
config UART_0_GPIO_MANAGEMENT
103-
bool "GPIO management on port 0"
104-
depends on PM_DEVICE
105-
default y
106-
help
107-
If enabled, the driver will configure the GPIOs used by the uart to
108-
their default configuration when device is powered down. The GPIOs
109-
will be configured back to correct state when UART is powered up.
110-
111-
endif # HAS_HW_NRF_UART0 || HAS_HW_NRF_UARTE0
112-
113-
# ----------------- port 1 -----------------
11444
if HAS_HW_NRF_UARTE1
45+
nrfx_uart_num = 1
46+
rsource "Kconfig.nrfx_uart_instance"
47+
endif
11548

116-
config UART_1_INTERRUPT_DRIVEN
117-
bool "Interrupt support on port 1"
118-
depends on UART_INTERRUPT_DRIVEN
119-
default y
120-
help
121-
This option enables UART interrupt support on port 1.
122-
123-
config UART_1_ASYNC
124-
bool "Asynchronous API support on port 1"
125-
depends on UART_ASYNC_API && !UART_1_INTERRUPT_DRIVEN
126-
default y
127-
help
128-
This option enables UART Asynchronous API support on port 1.
129-
130-
config UART_1_ENHANCED_POLL_OUT
131-
bool "Efficient poll out on port 1"
132-
default y
133-
help
134-
When enabled, polling out does not trigger interrupt which stops TX.
135-
Feature uses a PPI channel.
136-
137-
config UART_1_NRF_PARITY_BIT
138-
bool "Parity bit"
139-
help
140-
Enable parity bit.
141-
142-
config UART_1_NRF_TX_BUFFER_SIZE
143-
int "Size of RAM buffer"
144-
depends on UART_INTERRUPT_DRIVEN
145-
range 1 65535
146-
default 32
147-
help
148-
Size of the transmit buffer for API function: fifo_fill.
149-
This value is limited by range of TXD.MAXCNT register for
150-
particular SoC.
151-
152-
config UART_1_NRF_HW_ASYNC
153-
bool "Use hardware RX byte counting"
154-
depends on UART_1_ASYNC
155-
help
156-
If default driver uses interrupts to count incoming bytes, it is possible
157-
that with higher speeds and/or high cpu load some data can be lost.
158-
It is recommended to use hardware byte counting in such scenarios.
159-
Hardware RX byte counting requires timer instance and one PPI channel
160-
161-
config UART_1_NRF_ASYNC_LOW_POWER
162-
bool "Low power mode"
163-
depends on UART_ASYNC_API
164-
help
165-
When enabled, UARTE is enabled before each TX or RX usage and disabled
166-
when not used. Disabling UARTE while in idle allows to achieve lowest
167-
power consumption. It is only feasible if receiver is not always on.
168-
169-
config UART_1_NRF_HW_ASYNC_TIMER
170-
int "Timer instance"
171-
depends on UART_1_NRF_HW_ASYNC
172-
173-
config UART_1_GPIO_MANAGEMENT
174-
bool "GPIO management on port 1"
175-
depends on PM_DEVICE
176-
default y
177-
help
178-
If enabled, the driver will configure the GPIOs used by the uart to
179-
their default configuration when device is powered down. The GPIOs
180-
will be configured back to correct state when UART is powered up.
181-
182-
endif # HAS_HW_NRF_UARTE1
183-
184-
# ----------------- port 2 -----------------
18549
if HAS_HW_NRF_UARTE2
50+
nrfx_uart_num = 2
51+
rsource "Kconfig.nrfx_uart_instance"
52+
endif
18653

187-
config UART_2_INTERRUPT_DRIVEN
188-
bool "Interrupt support on port 2"
189-
depends on UART_INTERRUPT_DRIVEN
190-
default y
191-
help
192-
This option enables UART interrupt support on port 2.
193-
194-
config UART_2_ASYNC
195-
bool "Asynchronous API support on port 2"
196-
depends on UART_ASYNC_API && !UART_2_INTERRUPT_DRIVEN
197-
default y
198-
help
199-
This option enables UART Asynchronous API support on port 2.
200-
201-
config UART_2_ENHANCED_POLL_OUT
202-
bool "Efficient poll out on port 2"
203-
default y
204-
help
205-
When enabled, polling out does not trigger interrupt which stops TX.
206-
Feature uses a PPI channel.
207-
208-
config UART_2_NRF_PARITY_BIT
209-
bool "Parity bit"
210-
help
211-
Enable parity bit.
212-
213-
config UART_2_NRF_TX_BUFFER_SIZE
214-
int "Size of RAM buffer"
215-
range 1 65535
216-
default 32
217-
help
218-
Size of the transmit buffer for API function: fifo_fill.
219-
This value is limited by range of TXD.MAXCNT register for
220-
particular SoC.
221-
222-
config UART_2_NRF_HW_ASYNC
223-
bool "Use hardware RX byte counting"
224-
depends on UART_2_ASYNC
225-
help
226-
If default driver uses interrupts to count incoming bytes, it is possible
227-
that with higher speeds and/or high cpu load some data can be lost.
228-
It is recommended to use hardware byte counting in such scenarios.
229-
Hardware RX byte counting requires timer instance and one PPI channel
230-
231-
config UART_2_NRF_ASYNC_LOW_POWER
232-
bool "Low power mode"
233-
depends on UART_ASYNC_API
234-
help
235-
When enabled, UARTE is enabled before each TX or RX usage and disabled
236-
when not used. Disabling UARTE while in idle allows to achieve lowest
237-
power consumption. It is only feasible if receiver is not always on.
238-
239-
config UART_2_NRF_HW_ASYNC_TIMER
240-
int "Timer instance"
241-
depends on UART_2_NRF_HW_ASYNC
242-
243-
config UART_2_GPIO_MANAGEMENT
244-
bool "GPIO management on port 2"
245-
depends on PM_DEVICE
246-
default y
247-
help
248-
If enabled, the driver will configure the GPIOs used by the uart to
249-
their default configuration when device is powered down. The GPIOs
250-
will be configured back to correct state when UART is powered up.
251-
252-
endif # HAS_HW_NRF_UARTE2
253-
254-
# ----------------- port 3 -----------------
25554
if HAS_HW_NRF_UARTE3
256-
257-
config UART_3_INTERRUPT_DRIVEN
258-
bool "Interrupt support on port 3"
259-
depends on UART_INTERRUPT_DRIVEN
260-
default y
261-
help
262-
This option enables UART interrupt support on port 3.
263-
264-
config UART_3_ASYNC
265-
bool "Asynchronous API support on port 3"
266-
depends on UART_ASYNC_API && !UART_3_INTERRUPT_DRIVEN
267-
default y
268-
help
269-
This option enables UART Asynchronous API support on port 3.
270-
271-
config UART_3_ENHANCED_POLL_OUT
272-
bool "Efficient poll out on port 3"
273-
default y
274-
help
275-
When enabled, polling out does not trigger interrupt which stops TX.
276-
Feature uses a PPI channel.
277-
278-
config UART_3_NRF_PARITY_BIT
279-
bool "Parity bit"
280-
help
281-
Enable parity bit.
282-
283-
config UART_3_NRF_TX_BUFFER_SIZE
284-
int "Size of RAM buffer"
285-
range 1 65535
286-
default 32
287-
help
288-
Size of the transmit buffer for API function: fifo_fill.
289-
This value is limited by range of TXD.MAXCNT register for
290-
particular SoC.
291-
292-
config UART_3_NRF_HW_ASYNC
293-
bool "Use hardware RX byte counting"
294-
depends on UART_3_ASYNC
295-
help
296-
If default driver uses interrupts to count incoming bytes, it is possible
297-
that with higher speeds and/or high cpu load some data can be lost.
298-
It is recommended to use hardware byte counting in such scenarios.
299-
Hardware RX byte counting requires timer instance and one PPI channel
300-
301-
config UART_3_NRF_ASYNC_LOW_POWER
302-
bool "Low power mode"
303-
depends on UART_ASYNC_API
304-
help
305-
When enabled, UARTE is enabled before each TX or RX usage and disabled
306-
when not used. Disabling UARTE while in idle allows to achieve lowest
307-
power consumption. It is only feasible if receiver is not always on.
308-
309-
config UART_3_NRF_HW_ASYNC_TIMER
310-
int "Timer instance"
311-
depends on UART_3_NRF_HW_ASYNC
312-
313-
config UART_3_GPIO_MANAGEMENT
314-
bool "GPIO management on port 3"
315-
depends on PM_DEVICE
316-
default y
317-
help
318-
If enabled, the driver will configure the GPIOs used by the uart to
319-
their default configuration when device is powered down. The GPIOs
320-
will be configured back to correct state when UART is powered up.
321-
322-
endif # HAS_HW_NRF_UARTE3
323-
55+
nrfx_uart_num = 3
56+
rsource "Kconfig.nrfx_uart_instance"
57+
endif
32458

32559
config NRFX_TIMER0
32660
default y
@@ -357,23 +91,4 @@ config NRFX_TIMER4
35791
|| UART_2_NRF_HW_ASYNC_TIMER = 4 \
35892
|| UART_3_NRF_HW_ASYNC_TIMER = 4
35993

360-
361-
config UARTE_NRF_HW_ASYNC
362-
def_bool y
363-
depends on UART_0_NRF_HW_ASYNC \
364-
|| UART_1_NRF_HW_ASYNC \
365-
|| UART_2_NRF_HW_ASYNC \
366-
|| UART_3_NRF_HW_ASYNC
367-
select NRFX_PPI if HAS_HW_NRF_PPI
368-
select NRFX_DPPI if HAS_HW_NRF_DPPIC
369-
370-
config UART_ENHANCED_POLL_OUT
371-
def_bool y
372-
depends on UART_0_ENHANCED_POLL_OUT \
373-
|| UART_1_ENHANCED_POLL_OUT \
374-
|| UART_2_ENHANCED_POLL_OUT \
375-
|| UART_3_ENHANCED_POLL_OUT
376-
select NRFX_PPI if HAS_HW_NRF_PPI
377-
select NRFX_DPPI if HAS_HW_NRF_DPPIC
378-
37994
endif # UART_NRFX

0 commit comments

Comments
 (0)