Skip to content

Commit 1dbb478

Browse files
authored
Merge pull request #10597 from LDong-Arm/systimer_lptimer
SysTimer should be buildable without lp ticker
2 parents 75100d6 + 427c7db commit 1dbb478

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
#error [NOT_SUPPORTED] Tickless mode not supported for this target.
1818
#endif
1919

20-
#if !DEVICE_LPTICKER
21-
#error [NOT_SUPPORTED] Current SysTimer implementation requires lp ticker support.
22-
#endif
23-
2420
#include "mbed.h"
2521
#include "greentea-client/test_env.h"
2622
#include "unity.h"

rtos/TARGET_CORTEX/SysTimer.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
*/
2222
#include "rtos/TARGET_CORTEX/SysTimer.h"
2323

24-
#if DEVICE_LPTICKER
24+
#if MBED_TICKLESS
2525

26+
#include "hal/us_ticker_api.h"
2627
#include "hal/lp_ticker_api.h"
2728
#include "mbed_critical.h"
2829
#include "mbed_assert.h"
@@ -58,7 +59,12 @@ namespace rtos {
5859
namespace internal {
5960

6061
SysTimer::SysTimer() :
61-
TimerEvent(get_lp_ticker_data()), _time_us(0), _tick(0)
62+
#if DEVICE_LPTICKER
63+
TimerEvent(get_lp_ticker_data()),
64+
#else
65+
TimerEvent(get_us_ticker_data()),
66+
#endif
67+
_time_us(0), _tick(0)
6268
{
6369
_time_us = ticker_read_us(_ticker_data);
6470
_suspend_time_passed = true;
@@ -69,6 +75,8 @@ SysTimer::SysTimer(const ticker_data_t *data) :
6975
TimerEvent(data), _time_us(0), _tick(0)
7076
{
7177
_time_us = ticker_read_us(_ticker_data);
78+
_suspend_time_passed = true;
79+
_suspended = false;
7280
}
7381

7482
void SysTimer::setup_irq()
@@ -194,4 +202,4 @@ void SysTimer::handler()
194202
}
195203
}
196204

197-
#endif
205+
#endif // MBED_TICKLESS

rtos/TARGET_CORTEX/SysTimer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifndef MBED_SYS_TIMER_H
2323
#define MBED_SYS_TIMER_H
2424

25-
#if DEVICE_LPTICKER || defined(DOXYGEN_ONLY)
25+
#if MBED_TICKLESS || defined(DOXYGEN_ONLY)
2626

2727
#include "platform/NonCopyable.h"
2828
#include "drivers/TimerEvent.h"

rtos/TARGET_CORTEX/mbed_rtx_idle.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@ extern "C" {
3838

3939
#ifdef MBED_TICKLESS
4040

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");
41+
#if MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER && !DEVICE_USTICKER
42+
#error Microsecond ticker required when MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER is true
43+
#endif
44+
45+
#if !MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER && !DEVICE_LPTICKER
46+
#error Low power ticker required when MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER is false
47+
#endif
4548

4649
#include "rtos/TARGET_CORTEX/SysTimer.h"
4750

@@ -137,7 +140,7 @@ extern "C" {
137140
}
138141

139142

140-
#else
143+
#else // MBED_TICKLESS
141144

142145
static void default_idle_hook(void)
143146
{
@@ -149,7 +152,7 @@ extern "C" {
149152
core_util_critical_section_exit();
150153
}
151154

152-
#endif // (defined(MBED_TICKLESS) && DEVICE_LPTICKER)
155+
#endif // MBED_TICKLESS
153156

154157
static void (*idle_hook_fptr)(void) = &default_idle_hook;
155158

0 commit comments

Comments
 (0)