Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: uart: Add low power uart module #2591

Merged
merged 5 commits into from Sep 10, 2020
Merged

Conversation

nordic-krch
Copy link
Contributor

Low Power UART is a driver which implements standard asynchronous UART API and uses two control lines (instead
of standard hardware flow control lines) protocol to allow disabling UART receiver during idle period. This allows achieving low power consumption since high frequency clock (required when UART receiver is enabled) can be shut down when UART is in idle.

PR provides driver and sample.

See documentation for operation details.

I'm planning to add test in additional PR.

Primary use case is to use it for HCI communication between nrf52 and nrf91.

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Jul 15, 2020

All checks are passing now.

checkpatch (informational only, not a failure)

No additional types will be considered - file 'scripts/checkpatch/typedefsfile': No such file or directory
-:842: WARNING:LONG_LINE: line over 80 characters
#842: FILE: drivers/uart/uart_nrf_lpuart.c:633:
+			(DT_INST_PROP(0, req_pin) - 32) : DT_INST_PROP(0, req_pin),

-:844: WARNING:LONG_LINE: line over 80 characters
#844: FILE: drivers/uart/uart_nrf_lpuart.c:635:
+			(DT_INST_PROP(0, rdy_pin) - 32) : DT_INST_PROP(0, rdy_pin)

- total: 0 errors, 2 warnings, 1115 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPDX_LICENSE_TAG SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

Comment on lines 17 to 23
config NRF_LPUART_REQ_PIN
int "Transfer request pin"
default 0

config NRF_LPUART_RDY_PIN
int "Receiver ready pin"
default 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not define those pins in dts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's where border between kconfig is unclear. I could create something build on top or uart as a bus. As for now, ncs has only dts/bindings/sensor and dts/bindings/net and lpuart does not fit there. I could add something like dts/bindings/serial/nordic,nrf-lpuart.yaml but then it suggests as if that is a hw peripheral. What if some next gen SoC gets low power uart?

@anangl @Mierunski what do you think?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

software pwm is defined in nordic,nrf-sw-pwm.yaml, how about adding nordic,nrf-sw-lpuart.yaml which would extend standard uart?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to DT

Overview
********

Sample implements simple loopback using single UART instance.Sample by default

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* |nRF52840DK|
* |nRF9160DK|

* Pins shortend

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shorted or connected, same below in line 34

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

data->rx_state = RX_ACTIVE;
}

/* Called when end of transfer is detected. It sets resposnse pin to idle and

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@carlescufi
Copy link
Contributor

@nordic-krch this seems to use the standard UART API, so is there a reason why this is downstream?

@carlescufi
Copy link
Contributor

@anangl can you take a look please?

@nordic-krch
Copy link
Contributor Author

@carlescufi It is not standard uart (custom pin protocol) and multiple customers is asking for this and zephyr means longer review and more time till it is supported by ncs (upmerge). Because of that I put it here but there is no long term obstacles. I can as well move downstram (now or later).

@nordic-krch nordic-krch force-pushed the lpuart branch 2 times, most recently from f507070 to c5721ae Compare July 20, 2020 14:02
@nordic-krch
Copy link
Contributor Author

@greg-fer can you take o look or add other doc reviewer?

@b-gent b-gent added the doc-required PR must not be merged without tech writer approval. label Aug 6, 2020
samples/peripheral/lpuart/CMakeLists.txt Outdated Show resolved Hide resolved
samples/peripheral/lpuart/sample.yaml Outdated Show resolved Hide resolved
doc/nrf/drivers/uart_nrf_lpuart.rst Outdated Show resolved Hide resolved
doc/nrf/drivers/uart_nrf_lpuart.rst Outdated Show resolved Hide resolved
doc/nrf/drivers/uart_nrf_lpuart.rst Outdated Show resolved Hide resolved
doc/nrf/drivers/uart_nrf_lpuart.rst Outdated Show resolved Hide resolved
doc/nrf/drivers/uart_nrf_lpuart.rst Outdated Show resolved Hide resolved
samples/peripheral/lpuart/README.rst Outdated Show resolved Hide resolved
samples/peripheral/lpuart/README.rst Outdated Show resolved Hide resolved
samples/peripheral/lpuart/README.rst Outdated Show resolved Hide resolved
samples/peripheral/lpuart/README.rst Outdated Show resolved Hide resolved
samples/peripheral/lpuart/README.rst Outdated Show resolved Hide resolved
b-gent
b-gent previously requested changes Aug 19, 2020
doc/nrf/drivers/uart_nrf_lpuart.rst Outdated Show resolved Hide resolved
@b-gent

This comment has been minimized.

@nordic-krch
Copy link
Contributor Author

@anangl thanks for comments, please recheck.

Comment on lines 20 to 21
:start-after: set18_start
:end-before: set18_end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these two be set22_start and set22_end, respectively?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well spotted. fixed

@anangl
Copy link
Contributor

anangl commented Sep 4, 2020

One more detail: the commit title "drivers: uart: Add low power uart module" should actually start with "drivers: serial:".

#define GPIO(id) DT_NODELABEL(gpio##id)

#define GET_PORT(pin_prop) \
COND_CODE_1(DT_NODE_EXISTS(DT_INST(1, nordic_nrf_gpio)), \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
COND_CODE_1(DT_NODE_EXISTS(DT_INST(1, nordic_nrf_gpio)), \
COND_CODE_1(DT_NODE_EXISTS(GPIO(1)), \

Comment on lines 638 to 639
.pin = (DT_INST_PROP(0, pin_prop) >= 32) ? \
(DT_INST_PROP(0, pin_prop) - 32) : DT_INST_PROP(0, pin_prop), \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.pin = (DT_INST_PROP(0, pin_prop) >= 32) ? \
(DT_INST_PROP(0, pin_prop) - 32) : DT_INST_PROP(0, pin_prop), \
.pin = (DT_INST_PROP(0, pin_prop) & 0x1F), \

@nordic-krch
Copy link
Contributor Author

@utzig can you review changes in doc/nrf/conf.py?

Copy link
Contributor

@utzig utzig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nordic-krch nordic-krch dismissed b-gent’s stale review September 9, 2020 05:02

On vacation. Comments addressed

@nordic-krch
Copy link
Contributor Author

@rlubos @tejlmand maybe you are more familiar with CI failure analysis but i can't find failures related to that PR. If there are no failures related could you merge as further work is pending on that for days already.

@rlubos
Copy link
Contributor

rlubos commented Sep 9, 2020

Apart from all of the recent wackiness of the CI, this particular error in the previous doc build looks like a valid one:

AssertionError: There were warnings in: nrf/doc.log

https://jenkins-ncs.nordicsemi.no/job/latest/job/sub/job/test-fw-nrfconnect-nrf_doc/job/master/4664/artifact/_build/nrf/doc.log

But we need some doc expert to interpret this.

@nordic-krch
Copy link
Contributor Author

it states:

../../test_doc/_build/nrf/rst/doc/nrf/includes/boardname_tables/sample_boardnames.txt:13: WARNING: Inline literal start-string without end-string.

But this PR does not modify line 13 of this file and line 13 looks perfectly normal
@greg-fer @FrancescoSer @ru-fu any ideas?

Now it is again:

process apparently never started in /jenkins_workspace/workspace/t-fw-nrfconnect-nrf_doc_master_2/test_doc/DOC@tmp/durable-909d16d7

@b-gent
Copy link
Contributor

b-gent commented Sep 9, 2020

it states:

../../test_doc/_build/nrf/rst/doc/nrf/includes/boardname_tables/sample_boardnames.txt:13: WARNING: Inline literal start-string without end-string.

But this PR does not modify line 13 of this file and line 13 looks perfectly normal
@greg-fer @FrancescoSer @ru-fu any ideas?

Now it is again:

process apparently never started in /jenkins_workspace/workspace/t-fw-nrfconnect-nrf_doc_master_2/test_doc/DOC@tmp/durable-909d16d7

There is a backquote missing here in line 322 of this file:
``nrf5340pdk_nrf5340_cpuapp`

Low power UART implements UART asynchronous API and is using
2 additional pins to control the transfer. Based on pin status
receiver can be disabled during idle phase.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added documentation for low power UART module.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Sample application used to sanity check low power uart and
measure power consumption.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added nordic-krch as sample codeowner.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Adding DTS lexer.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
@nordic-krch
Copy link
Contributor Author

@b-gent thanks for pointing it out.

@rlubos
Copy link
Contributor

rlubos commented Sep 10, 2020

The CI failures are unrelated to this PR, merging.

@rlubos rlubos merged commit b31ecab into nrfconnect:master Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-required PR must not be merged without tech writer approval.
Projects
None yet
10 participants