Skip to content

Commit 830f746

Browse files
committed
rtx idle: fix coding style
1 parent 9a0651c commit 830f746

File tree

1 file changed

+99
-99
lines changed

1 file changed

+99
-99
lines changed

rtos/TARGET_CORTEX/mbed_rtx_idle.cpp

Lines changed: 99 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -33,131 +33,131 @@
3333
extern "C" {
3434
#include "rtx_lib.h"
3535

36-
using namespace mbed;
36+
using namespace mbed;
3737

3838
#if (defined(MBED_TICKLESS) && defined(DEVICE_LPTICKER))
3939

4040
#include "rtos/TARGET_CORTEX/SysTimer.h"
4141

42-
static rtos::internal::SysTimer *os_timer;
43-
static uint64_t os_timer_data[sizeof(rtos::internal::SysTimer) / 8];
42+
static rtos::internal::SysTimer *os_timer;
43+
static uint64_t os_timer_data[sizeof(rtos::internal::SysTimer) / 8];
4444

45-
/// Enable System Timer.
46-
void OS_Tick_Enable(void)
47-
{
48-
// Do not use SingletonPtr since this relies on the RTOS
49-
if (NULL == os_timer) {
50-
os_timer = new (os_timer_data) rtos::internal::SysTimer();
51-
os_timer->setup_irq();
45+
// Enable System Timer.
46+
void OS_Tick_Enable(void)
47+
{
48+
// Do not use SingletonPtr since this relies on the RTOS
49+
if (NULL == os_timer) {
50+
os_timer = new (os_timer_data) rtos::internal::SysTimer();
51+
os_timer->setup_irq();
52+
}
53+
54+
// set to fire interrupt on next tick
55+
os_timer->schedule_tick();
5256
}
5357

54-
// set to fire interrupt on next tick
55-
os_timer->schedule_tick();
56-
}
57-
58-
/// Disable System Timer.
59-
void OS_Tick_Disable(void)
60-
{
61-
os_timer->cancel_tick();
62-
}
63-
64-
/// Acknowledge System Timer IRQ.
65-
void OS_Tick_AcknowledgeIRQ(void)
66-
{
67-
68-
}
69-
70-
/// Get System Timer count.
71-
uint32_t OS_Tick_GetCount(void)
72-
{
73-
return os_timer->get_time() & 0xFFFFFFFF;
74-
}
75-
76-
// Get OS Tick IRQ number.
77-
int32_t OS_Tick_GetIRQn(void)
78-
{
79-
return -1;
80-
}
81-
82-
// Get OS Tick overflow status.
83-
uint32_t OS_Tick_GetOverflow(void)
84-
{
85-
return 0;
86-
}
87-
88-
// Get OS Tick interval.
89-
uint32_t OS_Tick_GetInterval(void)
90-
{
91-
return 1000;
92-
}
93-
94-
static void default_idle_hook(void)
95-
{
96-
uint32_t ticks_to_sleep = osKernelSuspend();
97-
const bool block_deep_sleep = ticks_to_sleep <= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
98-
99-
if (block_deep_sleep) {
100-
sleep_manager_lock_deep_sleep();
101-
} else {
102-
ticks_to_sleep -= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
58+
// Disable System Timer.
59+
void OS_Tick_Disable(void)
60+
{
61+
os_timer->cancel_tick();
10362
}
104-
os_timer->suspend(ticks_to_sleep);
10563

106-
bool event_pending = false;
107-
while (!os_timer->suspend_time_passed() && !event_pending) {
64+
// Acknowledge System Timer IRQ.
65+
void OS_Tick_AcknowledgeIRQ(void)
66+
{
10867

109-
core_util_critical_section_enter();
110-
if (osRtxInfo.kernel.pendSV) {
111-
event_pending = true;
112-
} else {
113-
sleep();
114-
}
115-
core_util_critical_section_exit();
68+
}
11669

117-
// Ensure interrupts get a chance to fire
118-
__ISB();
70+
// Get System Timer count.
71+
uint32_t OS_Tick_GetCount(void)
72+
{
73+
return os_timer->get_time() & 0xFFFFFFFF;
11974
}
12075

121-
if (block_deep_sleep) {
122-
sleep_manager_unlock_deep_sleep();
76+
// Get OS Tick IRQ number.
77+
int32_t OS_Tick_GetIRQn(void)
78+
{
79+
return -1;
80+
}
81+
82+
// Get OS Tick overflow status.
83+
uint32_t OS_Tick_GetOverflow(void)
84+
{
85+
return 0;
86+
}
87+
88+
// Get OS Tick interval.
89+
uint32_t OS_Tick_GetInterval(void)
90+
{
91+
return 1000;
12392
}
12493

125-
osKernelResume(os_timer->resume());
126-
}
94+
static void default_idle_hook(void)
95+
{
96+
uint32_t ticks_to_sleep = osKernelSuspend();
97+
const bool block_deep_sleep = ticks_to_sleep <= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
98+
99+
if (block_deep_sleep) {
100+
sleep_manager_lock_deep_sleep();
101+
} else {
102+
ticks_to_sleep -= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
103+
}
104+
os_timer->suspend(ticks_to_sleep);
105+
106+
bool event_pending = false;
107+
while (!os_timer->suspend_time_passed() && !event_pending) {
108+
109+
core_util_critical_section_enter();
110+
if (osRtxInfo.kernel.pendSV) {
111+
event_pending = true;
112+
} else {
113+
sleep();
114+
}
115+
core_util_critical_section_exit();
116+
117+
// Ensure interrupts get a chance to fire
118+
__ISB();
119+
}
120+
121+
if (block_deep_sleep) {
122+
sleep_manager_unlock_deep_sleep();
123+
}
124+
125+
osKernelResume(os_timer->resume());
126+
}
127127

128128

129129
#else
130130

131-
static void default_idle_hook(void)
132-
{
133-
// critical section to complete sleep with locked deepsleep
134-
core_util_critical_section_enter();
135-
sleep_manager_lock_deep_sleep();
136-
sleep();
137-
sleep_manager_unlock_deep_sleep();
138-
core_util_critical_section_exit();
139-
}
131+
static void default_idle_hook(void)
132+
{
133+
// critical section to complete sleep with locked deepsleep
134+
core_util_critical_section_enter();
135+
sleep_manager_lock_deep_sleep();
136+
sleep();
137+
sleep_manager_unlock_deep_sleep();
138+
core_util_critical_section_exit();
139+
}
140140

141141
#endif // (defined(MBED_TICKLESS) && defined(DEVICE_LPTICKER))
142142

143-
static void (*idle_hook_fptr)(void) = &default_idle_hook;
143+
static void (*idle_hook_fptr)(void) = &default_idle_hook;
144144

145-
void rtos_attach_idle_hook(void (*fptr)(void))
146-
{
147-
//Attach the specified idle hook, or the default idle hook in case of a NULL pointer
148-
if (fptr != NULL) {
149-
idle_hook_fptr = fptr;
150-
} else {
151-
idle_hook_fptr = default_idle_hook;
145+
void rtos_attach_idle_hook(void (*fptr)(void))
146+
{
147+
//Attach the specified idle hook, or the default idle hook in case of a NULL pointer
148+
if (fptr != NULL) {
149+
idle_hook_fptr = fptr;
150+
} else {
151+
idle_hook_fptr = default_idle_hook;
152+
}
152153
}
153-
}
154154

155-
MBED_NORETURN void rtos_idle_loop(void)
156-
{
157-
//Continuously call the idle hook function pointer
158-
while (1) {
159-
idle_hook_fptr();
155+
MBED_NORETURN void rtos_idle_loop(void)
156+
{
157+
//Continuously call the idle hook function pointer
158+
while (1) {
159+
idle_hook_fptr();
160+
}
160161
}
161-
}
162162

163163
} // extern "C"

0 commit comments

Comments
 (0)