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 numberOriginal file lineDiff line numberDiff line change
@@ -288,7 +288,7 @@ void test_sleep(void)
288
TEST_ASSERT_UINT64_WITHIN(DELAY_DELTA_US, DELAY_US, timer.read_high_resolution_us());
288
TEST_ASSERT_UINT64_WITHIN(DELAY_DELTA_US, DELAY_US, timer.read_high_resolution_us());
289
}
289
}
290

290

291-
#if DEVICE_LPTICKER
291+
#if DEVICE_LPTICKER && !MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER
292
/** Test wake up from deepsleep
292
/** Test wake up from deepsleep
293
*
293
*
294
* Given a SysTimer with a tick scheduled in the future
294
* Given a SysTimer with a tick scheduled in the future
@@ -342,7 +342,7 @@ Case cases[] = {
342
Case("Handler called once", test_handler_called_once),
342
Case("Handler called once", test_handler_called_once),
343
#if DEVICE_SLEEP
343
#if DEVICE_SLEEP
344
Case("Wake up from sleep", test_sleep),
344
Case("Wake up from sleep", test_sleep),
345-
#if DEVICE_LPTICKER
345+
#if DEVICE_LPTICKER && !MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER
346
Case("Wake up from deep sleep", test_deepsleep),
346
Case("Wake up from deep sleep", test_deepsleep),
347
#endif
347
#endif
348
#endif
348
#endif

rtos/TARGET_CORTEX/mbed_rtx_idle.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -24,6 +24,7 @@
24
#include "platform/mbed_power_mgmt.h"
24
#include "platform/mbed_power_mgmt.h"
25
#include "TimerEvent.h"
25
#include "TimerEvent.h"
26
#include "lp_ticker_api.h"
26
#include "lp_ticker_api.h"
27+
#include "us_ticker_api.h"
27
#include "mbed_critical.h"
28
#include "mbed_critical.h"
28
#include "mbed_assert.h"
29
#include "mbed_assert.h"
29
#include <new>
30
#include <new>
@@ -35,7 +36,12 @@ extern "C" {
35

36

36
using namespace mbed;
37
using namespace mbed;
37

38

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");
39

45

40
#include "rtos/TARGET_CORTEX/SysTimer.h"
46
#include "rtos/TARGET_CORTEX/SysTimer.h"
41

47

@@ -47,7 +53,11 @@ extern "C" {
47
{
53
{
48
// Do not use SingletonPtr since this relies on the RTOS
54
// Do not use SingletonPtr since this relies on the RTOS
49
if (NULL == os_timer) {
55
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
51
os_timer->setup_irq();
61
os_timer->setup_irq();
52
}
62
}
53

63

@@ -94,7 +104,8 @@ extern "C" {
94
static void default_idle_hook(void)
104
static void default_idle_hook(void)
95
{
105
{
96
uint32_t ticks_to_sleep = osKernelSuspend();
106
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);
98

109

99
if (block_deep_sleep) {
110
if (block_deep_sleep) {
100
sleep_manager_lock_deep_sleep();
111
sleep_manager_lock_deep_sleep();

targets/targets.json

Lines changed: 21 additions & 7 deletions
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -38,6 +38,10 @@
38
"default-form-factor": {
38
"default-form-factor": {
39
"help": "Default form factor of this board taken from supported_form_factors. This must be a lowercase string such as 'arduino'",
39
"help": "Default form factor of this board taken from supported_form_factors. This must be a lowercase string such as 'arduino'",
40
"value": null
40
"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
41
}
45
}
42
}
46
}
43
},
47
},
@@ -1861,7 +1865,8 @@
1861
}
1865
}
1862
},
1866
},
1863
"overrides": {
1867
"overrides": {
1864-
"deep-sleep-latency": 3
1868+
"deep-sleep-latency": 3,
1869+
"tickless-from-us-ticker": true
1865
},
1870
},
1866
"device_has": [
1871
"device_has": [
1867
"USTICKER",
1872
"USTICKER",
@@ -3122,7 +3127,7 @@
3122
},
3127
},
3123
"lpticker_lptim": {
3128
"lpticker_lptim": {
3124
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
3129
"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
3126
}
3131
}
3127
},
3132
},
3128
"macros_add": [
3133
"macros_add": [
@@ -7029,7 +7034,8 @@
7029
"device_name": "NUC472HI8AE",
7034
"device_name": "NUC472HI8AE",
7030
"bootloader_supported": true,
7035
"bootloader_supported": true,
7031
"overrides": {
7036
"overrides": {
7032-
"network-default-interface-type": "ETHERNET"
7037+
"network-default-interface-type": "ETHERNET",
7038+
"tickless-from-us-ticker": true
7033
}
7039
}
7034
},
7040
},
7035
"NCS36510": {
7041
"NCS36510": {
@@ -7152,7 +7158,10 @@
7152
],
7158
],
7153
"release_versions": ["2", "5"],
7159
"release_versions": ["2", "5"],
7154
"device_name": "M453VG6AE",
7160
"device_name": "M453VG6AE",
7155-
"bootloader_supported": true
7161+
"bootloader_supported": true,
7162+
"overrides": {
7163+
"tickless-from-us-ticker": true
7164+
}
7156
},
7165
},
7157
"NUMAKER_PFM_NANO130": {
7166
"NUMAKER_PFM_NANO130": {
7158
"core": "Cortex-M0",
7167
"core": "Cortex-M0",
@@ -7214,7 +7223,10 @@
7214
"SPI_ASYNCH"
7223
"SPI_ASYNCH"
7215
],
7224
],
7216
"release_versions": ["5"],
7225
"release_versions": ["5"],
7217-
"device_name": "NANO130KE3BN"
7226+
"device_name": "NANO130KE3BN",
7227+
"overrides": {
7228+
"tickless-from-us-ticker": true
7229+
}
7218
},
7230
},
7219
"HI2110": {
7231
"HI2110": {
7220
"inherits": ["Target"],
7232
"inherits": ["Target"],
@@ -7538,7 +7550,8 @@
7538
"release_versions": ["5"],
7550
"release_versions": ["5"],
7539
"bootloader_supported": true,
7551
"bootloader_supported": true,
7540
"overrides": {
7552
"overrides": {
7541-
"network-default-interface-type": "ETHERNET"
7553+
"network-default-interface-type": "ETHERNET",
7554+
"tickless-from-us-ticker": true
7542
}
7555
}
7543
},
7556
},
7544
"NUMAKER_PFM_M487": {
7557
"NUMAKER_PFM_M487": {
@@ -7777,7 +7790,8 @@
7777
"detect_code": ["1305"],
7790
"detect_code": ["1305"],
7778
"release_versions": ["5"],
7791
"release_versions": ["5"],
7779
"device_name": "M2351KIAAEES",
7792
"device_name": "M2351KIAAEES",
7780-
"bootloader_supported": true
7793+
"bootloader_supported": true,
7794+
"tickless-from-us-ticker": true
7781
},
7795
},
7782
"TMPM3H6": {
7796
"TMPM3H6": {
7783
"inherits": ["Target"],
7797
"inherits": ["Target"],

0 commit comments

Comments
 (0)