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

Unify RTC, lp ticker, and us ticker for NRF51 and NRF52 series #7172

Merged
merged 10 commits into from Jun 20, 2018

Conversation

Projects
None yet
7 participants
@mprse
Member

mprse commented Jun 8, 2018

Description

Add the following ticker modifications for NRF5x boards:

  • Increase NRF52 timer width to 32 bits,
  • Remove duplicate lp ticker initialization from I2C and flash,
  • common_rtc_set_interrupt(): Wrap <ticks_count> before comparisons,
  • NRF51, NRF52: Implement us_ticker_free() function,
  • NRF5x: Add bug fix for the first timer read,
  • NRF5x: Increase lp us ticker interrupt priority,
  • Use same ticker implementation for both NRF51 and NRF52.

Most of these changes have been proposed by @marcuschangarm. Can you review this PR?

Pull request type

[ ] Fix
[ ] Refactor
[ ] New target
[X] Feature
[ ] Breaking change

mprse added some commits May 23, 2018

common_rtc_set_interrupt: Wrap <ticks_count> before comparisons
RTC counter is 24-bit. Upper layer handles counter size and wraps ticks count when interrupt is to be fired before passing it to common_rtc_set_interrupt(), but for consistency and safety reasons we can wrap it again in the NRF driver.

@0xc0170 0xc0170 requested review from marcuschangarm and ARMmbed/mbed-os-hal Jun 8, 2018

@mprse mprse force-pushed the mprse:NRF5x_updates branch from 4e1cbfd to 5318c68 Jun 8, 2018

@@ -100,6 +100,9 @@ void us_ticker_init(void)
nrf_timer_task_trigger(NRF_TIMER1, NRF_TIMER_TASK_START);
/* Bug fix. First value can't be trusted. */
nrf_timer_task_trigger(NRF_TIMER1, NRF_TIMER_TASK_CAPTURE1);

This comment has been minimized.

@fkjagodzinski

fkjagodzinski Jun 18, 2018

Member

If this is somehow related to one of the known anomalies, it may be worth adding a reference.

This comment has been minimized.

@marcuschangarm

marcuschangarm Jun 18, 2018

Contributor

I don't think it is. I just noticed some very odd behavior on my boards.

#define LP_TICKER_COUNTER_BITS 32u
#define LP_TICKER_FREQ 31250
#endif // LP_TICKER_H

This comment has been minimized.

@marcuschangarm

marcuschangarm Jun 18, 2018

Contributor

I can't see where this file is being used?

This comment has been minimized.

@mprse

mprse Jun 19, 2018

Member

This file is added by mistake. I have removed it.

@@ -110,7 +110,9 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
{
core_util_critical_section_enter();
nrf_timer_cc_write(NRF_TIMER1, NRF_TIMER_CC_CHANNEL0, timestamp & 0xFFFF);
const uint32_t counter_mask = ((1 << US_TICKER_COUNTER_BITS) - 1);

This comment has been minimized.

@marcuschangarm

marcuschangarm Jun 18, 2018

Contributor

Will this bit-shift always work? I was expecting this:

((1ULL << US_TICKER_COUNTER_BITS) - 1)

This comment has been minimized.

@mprse

mprse Jun 19, 2018

Member

Fixed as suggested.

@@ -110,7 +110,9 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
{
core_util_critical_section_enter();
nrf_timer_cc_write(NRF_TIMER1, NRF_TIMER_CC_CHANNEL0, timestamp & 0xFFFF);
const uint32_t counter_mask = ((1 << US_TICKER_COUNTER_BITS) - 1);

This comment has been minimized.

@marcuschangarm

marcuschangarm Jun 18, 2018

Contributor

Same comment as above.

@marcuschangarm

This comment has been minimized.

Contributor

marcuschangarm commented Jun 18, 2018

@mprse I just got back in the office, thank you for pushing this! I've added a couple of minor comments.

mprse added some commits May 24, 2018

NRF5x: Add bug fix for the first timer read.
It has been noticed that first read value can not be trusted.
NRF5x: Increase lp us ticker interrupt priority
Set the second highest user level, leaving the highest for UART (we are having constant overflows) and two levels below for everything else.
This should increase the timer accuracy.

@mprse mprse dismissed stale reviews from fkjagodzinski and maciejbocianski via 02d7d25 Jun 19, 2018

@mprse mprse force-pushed the mprse:NRF5x_updates branch from 5318c68 to 02d7d25 Jun 19, 2018

@mprse

This comment has been minimized.

Member

mprse commented Jun 19, 2018

Provided some fixes after review.

@marcuschangarm

This comment has been minimized.

Contributor

marcuschangarm commented Jun 19, 2018

Looks good! Thank you!

@0xc0170 0xc0170 added needs: CI and removed needs: review labels Jun 20, 2018

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Jun 20, 2018

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented Jun 20, 2018

Build : SUCCESS

Build number : 2402
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7172/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@cmonr cmonr added ready for merge and removed needs: CI labels Jun 20, 2018

@cmonr cmonr merged commit 84d6b79 into ARMmbed:master Jun 20, 2018

14 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-mbed2-build build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
travis-ci/astyle Passed, 925 files
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/events Passed, runtime is 10187 cycles (+57 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/licence_check Local licence_check testing has passed
Details
travis-ci/littlefs Passed, code size is 9964B (+0.00%)
Details
travis-ci/tools-py2.7 Local tools-py2.7 testing has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment