Commit Graph

16556 Commits (5d8570be39bcb6ce8807f45c3a6d558201a0de84)

Author SHA1 Message Date
Przemyslaw Stekiel 3850c80b43 Make common_rtc.c compatible with SDK 14.2 and move it common dir 2018-05-25 12:33:43 -05:00
Przemyslaw Stekiel f32f866f00 NRF52840_DK: Enable lp us ticker support 2018-05-25 12:33:42 -05:00
Ashok Rao 96ca7c22ed Adding usticker to MTB_ODIN 2018-05-25 12:33:42 -05:00
Jesse Marroquin 0ddec48efc mbed-os v5.9 LPTICKER implementation 2018-05-25 12:33:42 -05:00
Jesse Marroquin b88329acb8 mbed-os v5.9 USTICKER implementation 2018-05-25 12:33:42 -05:00
Przemyslaw Stekiel 11748bf95c Enable us lp ticker support for entire MCU_NRF52832 family 2018-05-25 12:33:42 -05:00
Przemyslaw Stekiel 1d1b6cd571 NRF52_DK: disable us ticker in deep-sleep mode
This functionality is required by new sleep standards.
2018-05-25 12:33:42 -05:00
Przemyslaw Stekiel e7fa5fc599 tests-mbed_hal-flash: optimieze time_cpu_cycles() function
This function should perform instruction cycles count in critical section.
Additionally remove redundant code.
2018-05-25 12:33:42 -05:00
Przemyslaw Stekiel be098399a8 tests-mbed_hal-flash: Remove 5% extra tolerance for NRF52_DK
NRF52_DK is now based on fast and accurate 1MHz counter.
2018-05-25 12:33:42 -05:00
Przemyslaw Stekiel 06c6db5119 tests-mbed_drivers-lp_timer: modify tolerance to percentage form
Represent tolerance value as it is done in `tests-mbed_drivers_timer`.
Use 5% tolerance for lp ticker.
2018-05-25 12:33:42 -05:00
Przemyslaw Stekiel a0a07d9725 tests-mbed_drivers-timerevent: increase tolerance for NRF52_DK
Test inserts event into the TimerEvent object which is scheduled 50 ms in the future. Then test thread hangs on the semaphore for 51 ms and after that time we expect that event handler has been executed. This test fails sometimes on NRF51_DK, NRF52_DK since different clocks are used for event handling and delay. TimerEvent class uses fast us ticker and semaphores are based on lp ticker (NRF51_DK) or System Tick Timer (NRF52_DK).
We assume that ticker measurement error is 10% and our 1 [ms] extra corresponds to 2% error. I suggest to increase delay to 2 [ms] (4%). This should be enough for all boards at this moment.
2018-05-25 12:33:42 -05:00
Przemyslaw Stekiel 50a5e2c1f4 tests-mbed_hal-common_tickers: fix bug in ticker increment test case
It is possible that the difference between base and next tick count on some platforms is greater than 1, in this case we need to repeat counting with the reduced number of cycles (for slower boards).
If number of cycles has been reduced than base tick count needs to be redefined. This operation is missing and is added by this patch.
2018-05-25 12:33:42 -05:00
Przemyslaw Stekiel b0153574d4 NRF52_DK: Enable lp ticker and us ticker support 2018-05-25 12:33:42 -05:00
Przemyslaw Stekiel 9ef0083f92 NRF52_DK: use new ticker driver designed for NRF51_DK 2018-05-25 12:33:41 -05:00
Mahesh Mahadevan fb622a2081 MIMXRT1050_EVK: Update lpticker implementation
Use only the GPT module and avoid using RTC.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:33:41 -05:00
Mahesh Mahadevan 3b7b0f1307 KW41Z, KL43Z, KL27Z: Enable LPTICKER
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:33:41 -05:00
Mahesh Mahadevan d46af14bb6 KL27Z: Update usticker to use TPM instead of LPTMR for ticker
This will free up the LPTMR to be used as lpticker

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:33:41 -05:00
Mahesh Mahadevan a21d21e700 KL43Z: Update usticker to use TPM instead of LPTMR for ticker
This will free up the LPTMR to be used as lpticker

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:33:41 -05:00
Mahesh Mahadevan 62254c2bae KW41Z: Update usticker to use TPM instead of LPTMR for ticker
This will free up the LPTMR to be used as lpticker

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:33:41 -05:00
Bartek Szatkowski 95559ad3e1 Change LPTICKER spec to allow clock freq starting at 4kHz 2018-05-25 12:32:39 -05:00
Edmund Hsu e514c2c70d Fix us_ticker.c to support "USTICKER"
- Disable microsecond ticker interrupt on reinitialization
- Skip us_ticker_set_interrupt() if timestamp is already past
- Eliminate tmr2Config since tmrConfig is adequate for all timer config
2018-05-25 12:32:38 -05:00
Mahesh Mahadevan 774de11d1f MCUXpresso: Enable usticker on MIMXRT1050_EVK
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:32:38 -05:00
Mahesh Mahadevan 659be61e4b MCUXpresso: Enable usticker for LPC546XX and LPC54114
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:32:38 -05:00
Mahesh Mahadevan 4eb8841dc1 MCUXpresso: Update the usticker implementation
Enabled usticker for K22F, K24F, K66F, K82F, KL82Z, KW24D

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:32:38 -05:00
Mahesh Mahadevan 0d0321a7f0 MCUXpresso: Update Low Power Ticker
1. Enable LPTICKER for K22, K24, K64, K66, K82, KL82F, KW24D
2. Change the implementation to only use the LPTMR which reduces
   the amount of interrupts generated which is required for tickless
   operation

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:32:38 -05:00
Mahesh Mahadevan 132dc87f3e KL05, KL25, KL26, KL46: Enable usticker
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:30:53 -05:00
Mahesh Mahadevan 870600400d LPC1768: Enable usticker
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2018-05-25 12:30:53 -05:00
Przemyslaw Stekiel c18763bb41 tests-mbed_hal-common_tickers: disable os tick while running test cases
It has been noticed on NRF51_DK board that occurrence of system tick have impact on test execution.
NRF51_DK is a slow board with fast us ticker and handling of system tick interrupt takes about 250 us ticker ticks which have huge influence on interrupt tests where interrupt is set to <current count> + 100, 200, 500 ticks.
2018-05-25 12:30:52 -05:00
Przemyslaw Stekiel 7d969326d6 Enable support for NRF51 boards.
Make it consistent with master.
2018-05-25 12:30:52 -05:00
Przemyslaw Stekiel 75df9ecd19 tests-mbed_drivers-lp_ticker: increase tolerance for NRF51_DK
This test fails sometimes while testing 1 ms timeout on NRF51_DK board.
This board is very slow and lp ticker is inaccurate.
I noticed that measured results are very close to the tolerance value. For 1ms delay we measure in failure case 1560 us and tolerance is set to 550.
Since measurement method is also significantly flawed (extra time for setting up ticker and execution of a ticker irq handler) I recommend to increase tolerance by least +100 us for now.
2018-05-25 12:30:52 -05:00
Przemyslaw Stekiel a3d5921515 tests-mbed_drivers-timerevent: Disable deep-sleep mode in TestTimerEvent class.
Since now us ticker is disabled in deep-sleep mode and tests-mbed_drivers-timerevent verifies TimerEvent class which uses us ticker then deep-sleep mode needs to be disabled during the test execution.
2018-05-25 12:30:52 -05:00
Przemyslaw Stekiel fac7d744d5 Disable us ticker in deep-sleep mode. 2018-05-25 12:30:52 -05:00
Przemyslaw Stekiel 4fe068834c tests-events-queue: modify tolerance to percentage form
On some boards without SYSTICK support lp ticker is used to trace system ticks.
Event queue uses system ticker to count delay when callback is to be fired.
New ticker implementation for NRF51_DK provides fast and accurate counter for us ticker which shows inaccuracy of the system ticker(which is based on slow and inaccurate lp ticker). This is why measured error grows linearly and percentage form needs to be used.

Currently we use constant tolerance value equal to: 5 [ms].
This patch modifies tolerance to the following form: 5% of measured time [ms].

In this test the lowest delay is equal to 100 [ms], so 5% corresponds to 5 [ms] tolerance - original value. This means that min tolerance is 5 [ms] so this change should not have negative impact on other targets.
2018-05-25 12:30:52 -05:00
Przemyslaw Stekiel ffd09f8a70 Enable support for NRF51 boards. 2018-05-25 12:30:52 -05:00
Przemyslaw Stekiel 77f738baac Move common_rtc.c and us_ticker.h files to the valid directory.
I decided to move these files to the targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF51 since us_ticker.h is for sure specific for NRF51_DK and common_rtc.c might be valid also for NRF52, but this needs to be checked while porting NRF52_DK board.
2018-05-25 12:29:55 -05:00
Bartek Szatkowski 1e71515471 Disable MAX targets failig to build 2018-05-25 12:29:55 -05:00
Bartek Szatkowski e6bb77085c Disable failig Nordic targets 2018-05-25 12:29:55 -05:00
Marc Emmers ce79492154 Updated types according to header changes 2018-05-25 12:29:55 -05:00
Marc Emmers d35b29830b Changed struct position to try to maintain binary compatibility
Changed comment because a lot of numbers are divisible by 2
2018-05-25 12:29:55 -05:00
Marc Emmers 1aaef7bc12 mbed_ticker_api remove specific case for 32768 in favor of all frequencies divisible by 2 2018-05-25 12:29:55 -05:00
Przemyslaw Stekiel ff39a9874a tests-mbed_hal-common_tickers: increase overflow protection limit
For NR51_DK US_TICKER_OV_LIMIT needs to be increased since if test is run few times in row sometimes fails. This is because NR51_DK is a slow board (16 MHz) with fast and short us ticker counter 1 MHz/16 bits.
2018-05-25 12:29:55 -05:00
Przemyslaw Stekiel bdfbad8422 Rename DEVICE_LOWPOWERTIMER to DEVICE_LPTICKER. 2018-05-25 12:29:55 -05:00
Przemyslaw Stekiel 79f219bb3d tests-mbed_drivers-timer: Adapt tolerance for new Ticker driver
Since this change concerns new ticker driver for NRF51_DK it goas on ticker feature branch.

On this branch us ticker is based on 1 MHz higher precision counter (on master is based on 32kHz RTC). As a result of using higher precision counter measurement error increased:
:485::FAIL: Expected 1.060000 Was 1.070478

For delay 1060 ms we measured ~1070 ms so we have about ~1% measurement error which is not bed for this board.

To make it work with 1MHz us ticker increase test tolerance. Define tolerance as follows:
tolerance  = 500us + 0.02 * delay.
2018-05-25 12:29:55 -05:00
Przemyslaw Stekiel b524a7f8d9 tests-mbed_drivers-lp_ticker: Adapt tolerance for new Ticker driver
Since this change concerns new ticker driver for NRF51_DK it goas on ticker feature branch.

On master NRF51_DK Ticker driver uses 32kHz RTC for lp and us ticker. Test uses us ticker to measure lp ticker interrupt scheduling (LowPowerTicker.attach), but since the same hardware is used for both tickers the measurement error is constant. On this branch us ticker uses 1 MHz higher precision clock and the results are different - measurement error grows linearly and shows inaccuracy of the RTC.
Test implements constant delta for measured time equal to 2000 us.

Change delta so it depends on lp ticker tested timeout value:
500us for measurement inaccuracy + 5% tolerance for LowPowerTicker
2018-05-25 12:29:54 -05:00
Przemyslaw Stekiel 8979212b78 tests-mbed_hal-lp_ticker: run sleep test only if SLEEP support is enabled. 2018-05-25 12:29:54 -05:00
Przemyslaw Stekiel 2323486bf3 tests-mbed_drivers-timerevent: perform test only if USTICKER support is enabled. 2018-05-25 12:29:54 -05:00
Przemyslaw Stekiel af2863a9e5 Update lp ticker to be consistent with the new standards.
Provide the following modifications for lp ticker driver:
- According to NRF51_DK reference manual rtc interrupt cannot be controlled by rtc event. In the previous implementation interrupts were enabled permanently and specific interrupt was enabled/disabled by enabling/disabling the specific event. If event is enabled, then event signal is provided to Programmable Peripheral Interconnect (PPI). If interrupt is enabled, then interrupt signal is provided to Nested Vector Interrupt Controller (NVIC). Disable all events permanently. Enable lp ticker overflow interrupt permanently(needed for RTC), disable lp ticker capture/compare interrupt on init (lp_ticker_init) , enable lp ticker interrupt when lp ticker interrupt is set (lp_ticker_set_interrupt), disable lp ticker interrupt on disable request(lp_ticker_disable_interrupt).
- Provide lp ticker data for higher level (freq: 32kHz / len: 24 bits),
- Add the following features to init routine: disable lp ticker interrupt.
- Make ticker driver to operate on ticks instead of us.
- Simplify lp ticker read and set interrupt routines (upper layers handle conversion to us and interrupt scheduling).
2018-05-25 12:29:54 -05:00
Przemyslaw Stekiel 007a707527 Enable us/lp ticker support for NRF51_DK board 2018-05-25 12:29:54 -05:00
Przemyslaw Stekiel 533ad59669 NRF5 - make us ticker to be driven by high speed 1MHz timer
According to new ticker standards the following requirements for us ticker are not met on RRF5 boards:
- has a frequency between 250KHz and 8MHz (currently is driven by 32kHz clock)
- ticker increments by 1 each tick (currently is scaled to 1 MHz by incrementing counter by ~31)

Since BLE softdevice uses TIMER0 the proposition is to use high speed TIMER1 for us ticker configured as follows:
- TIMER counter width: 16 bits (max)
- TIMER frequency: 1MHz
This solution also uses Timer's capture/compare register 0 to specify interrupt time and Timer's capture/compare register 1 to read current timer value.
2018-05-25 12:29:54 -05:00
jeromecoutant e3deaecc27 STM32 LPTICKER update for targets supporting RTC 2018-05-25 12:29:54 -05:00