Skip to content

Commit e393c2d

Browse files
author
Cruz Monrreal
authored
Merge pull request #9785 from c1728p9/default_to_us_ticker
Use us ticker for tickless on devs with wrapper
2 parents 024cae5 + 8d880bb commit e393c2d

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

TESTS/mbedmicro-rtos-mbed/systimer/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ void test_sleep(void)
288288
TEST_ASSERT_UINT64_WITHIN(DELAY_DELTA_US, DELAY_US, timer.read_high_resolution_us());
289289
}
290290

291-
#if DEVICE_LPTICKER
291+
#if DEVICE_LPTICKER && !MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER
292292
/** Test wake up from deepsleep
293293
*
294294
* Given a SysTimer with a tick scheduled in the future
@@ -342,7 +342,7 @@ Case cases[] = {
342342
Case("Handler called once", test_handler_called_once),
343343
#if DEVICE_SLEEP
344344
Case("Wake up from sleep", test_sleep),
345-
#if DEVICE_LPTICKER
345+
#if DEVICE_LPTICKER && !MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER
346346
Case("Wake up from deep sleep", test_deepsleep),
347347
#endif
348348
#endif

rtos/TARGET_CORTEX/mbed_rtx_idle.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "platform/mbed_power_mgmt.h"
2525
#include "TimerEvent.h"
2626
#include "lp_ticker_api.h"
27+
#include "us_ticker_api.h"
2728
#include "mbed_critical.h"
2829
#include "mbed_assert.h"
2930
#include <new>
@@ -35,7 +36,12 @@ extern "C" {
3536

3637
using namespace mbed;
3738

38-
#if (defined(MBED_TICKLESS) && DEVICE_LPTICKER)
39+
#ifdef MBED_TICKLESS
40+
41+
MBED_STATIC_ASSERT(!MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER || DEVICE_USTICKER,
42+
"Microsecond ticker required when MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER is true");
43+
MBED_STATIC_ASSERT(MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER || DEVICE_LPTICKER,
44+
"Low power ticker required when MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER is false");
3945

4046
#include "rtos/TARGET_CORTEX/SysTimer.h"
4147

@@ -47,7 +53,11 @@ extern "C" {
4753
{
4854
// Do not use SingletonPtr since this relies on the RTOS
4955
if (NULL == os_timer) {
50-
os_timer = new (os_timer_data) rtos::internal::SysTimer();
56+
#if MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER
57+
os_timer = new (os_timer_data) rtos::internal::SysTimer(get_us_ticker_data());
58+
#else
59+
os_timer = new (os_timer_data) rtos::internal::SysTimer(get_lp_ticker_data());
60+
#endif
5161
os_timer->setup_irq();
5262
}
5363

@@ -94,7 +104,8 @@ extern "C" {
94104
static void default_idle_hook(void)
95105
{
96106
uint32_t ticks_to_sleep = osKernelSuspend();
97-
const bool block_deep_sleep = ticks_to_sleep <= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
107+
const bool block_deep_sleep = MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER ||
108+
(ticks_to_sleep <= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY);
98109

99110
if (block_deep_sleep) {
100111
sleep_manager_lock_deep_sleep();

targets/targets.json

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
"default-form-factor": {
3939
"help": "Default form factor of this board taken from supported_form_factors. This must be a lowercase string such as 'arduino'",
4040
"value": null
41+
},
42+
"tickless-from-us-ticker": {
43+
"help": "Run tickless from the microsecond ticker rather than the low power ticker. Running tickless off of the microsecond ticker improves interrupt latency on targets which use lpticker_delay_ticks",
44+
"value": false
4145
}
4246
}
4347
},
@@ -1861,7 +1865,8 @@
18611865
}
18621866
},
18631867
"overrides": {
1864-
"deep-sleep-latency": 3
1868+
"deep-sleep-latency": 3,
1869+
"tickless-from-us-ticker": true
18651870
},
18661871
"device_has": [
18671872
"USTICKER",
@@ -3122,7 +3127,7 @@
31223127
},
31233128
"lpticker_lptim": {
31243129
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
3125-
"value": 1
3130+
"value": 0
31263131
}
31273132
},
31283133
"macros_add": [
@@ -7029,7 +7034,8 @@
70297034
"device_name": "NUC472HI8AE",
70307035
"bootloader_supported": true,
70317036
"overrides": {
7032-
"network-default-interface-type": "ETHERNET"
7037+
"network-default-interface-type": "ETHERNET",
7038+
"tickless-from-us-ticker": true
70337039
}
70347040
},
70357041
"NCS36510": {
@@ -7152,7 +7158,10 @@
71527158
],
71537159
"release_versions": ["2", "5"],
71547160
"device_name": "M453VG6AE",
7155-
"bootloader_supported": true
7161+
"bootloader_supported": true,
7162+
"overrides": {
7163+
"tickless-from-us-ticker": true
7164+
}
71567165
},
71577166
"NUMAKER_PFM_NANO130": {
71587167
"core": "Cortex-M0",
@@ -7214,7 +7223,10 @@
72147223
"SPI_ASYNCH"
72157224
],
72167225
"release_versions": ["5"],
7217-
"device_name": "NANO130KE3BN"
7226+
"device_name": "NANO130KE3BN",
7227+
"overrides": {
7228+
"tickless-from-us-ticker": true
7229+
}
72187230
},
72197231
"HI2110": {
72207232
"inherits": ["Target"],
@@ -7538,7 +7550,8 @@
75387550
"release_versions": ["5"],
75397551
"bootloader_supported": true,
75407552
"overrides": {
7541-
"network-default-interface-type": "ETHERNET"
7553+
"network-default-interface-type": "ETHERNET",
7554+
"tickless-from-us-ticker": true
75427555
}
75437556
},
75447557
"NUMAKER_PFM_M487": {
@@ -7777,7 +7790,8 @@
77777790
"detect_code": ["1305"],
77787791
"release_versions": ["5"],
77797792
"device_name": "M2351KIAAEES",
7780-
"bootloader_supported": true
7793+
"bootloader_supported": true,
7794+
"tickless-from-us-ticker": true
77817795
},
77827796
"TMPM3H6": {
77837797
"inherits": ["Target"],

0 commit comments

Comments
 (0)