mirror of https://github.com/ARMmbed/mbed-os.git
rtx idle: fix coding style
parent
9a0651c7fb
commit
830f7464cc
|
|
@ -33,18 +33,18 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "rtx_lib.h"
|
#include "rtx_lib.h"
|
||||||
|
|
||||||
using namespace mbed;
|
using namespace mbed;
|
||||||
|
|
||||||
#if (defined(MBED_TICKLESS) && defined(DEVICE_LPTICKER))
|
#if (defined(MBED_TICKLESS) && defined(DEVICE_LPTICKER))
|
||||||
|
|
||||||
#include "rtos/TARGET_CORTEX/SysTimer.h"
|
#include "rtos/TARGET_CORTEX/SysTimer.h"
|
||||||
|
|
||||||
static rtos::internal::SysTimer *os_timer;
|
static rtos::internal::SysTimer *os_timer;
|
||||||
static uint64_t os_timer_data[sizeof(rtos::internal::SysTimer) / 8];
|
static uint64_t os_timer_data[sizeof(rtos::internal::SysTimer) / 8];
|
||||||
|
|
||||||
/// Enable System Timer.
|
// Enable System Timer.
|
||||||
void OS_Tick_Enable(void)
|
void OS_Tick_Enable(void)
|
||||||
{
|
{
|
||||||
// Do not use SingletonPtr since this relies on the RTOS
|
// Do not use SingletonPtr since this relies on the RTOS
|
||||||
if (NULL == os_timer) {
|
if (NULL == os_timer) {
|
||||||
os_timer = new (os_timer_data) rtos::internal::SysTimer();
|
os_timer = new (os_timer_data) rtos::internal::SysTimer();
|
||||||
|
|
@ -53,46 +53,46 @@ void OS_Tick_Enable(void)
|
||||||
|
|
||||||
// set to fire interrupt on next tick
|
// set to fire interrupt on next tick
|
||||||
os_timer->schedule_tick();
|
os_timer->schedule_tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disable System Timer.
|
// Disable System Timer.
|
||||||
void OS_Tick_Disable(void)
|
void OS_Tick_Disable(void)
|
||||||
{
|
{
|
||||||
os_timer->cancel_tick();
|
os_timer->cancel_tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Acknowledge System Timer IRQ.
|
// Acknowledge System Timer IRQ.
|
||||||
void OS_Tick_AcknowledgeIRQ(void)
|
void OS_Tick_AcknowledgeIRQ(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get System Timer count.
|
// Get System Timer count.
|
||||||
uint32_t OS_Tick_GetCount(void)
|
uint32_t OS_Tick_GetCount(void)
|
||||||
{
|
{
|
||||||
return os_timer->get_time() & 0xFFFFFFFF;
|
return os_timer->get_time() & 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get OS Tick IRQ number.
|
// Get OS Tick IRQ number.
|
||||||
int32_t OS_Tick_GetIRQn(void)
|
int32_t OS_Tick_GetIRQn(void)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get OS Tick overflow status.
|
// Get OS Tick overflow status.
|
||||||
uint32_t OS_Tick_GetOverflow(void)
|
uint32_t OS_Tick_GetOverflow(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get OS Tick interval.
|
// Get OS Tick interval.
|
||||||
uint32_t OS_Tick_GetInterval(void)
|
uint32_t OS_Tick_GetInterval(void)
|
||||||
{
|
{
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void default_idle_hook(void)
|
static void default_idle_hook(void)
|
||||||
{
|
{
|
||||||
uint32_t ticks_to_sleep = osKernelSuspend();
|
uint32_t ticks_to_sleep = osKernelSuspend();
|
||||||
const bool block_deep_sleep = ticks_to_sleep <= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
|
const bool block_deep_sleep = ticks_to_sleep <= MBED_CONF_TARGET_DEEP_SLEEP_LATENCY;
|
||||||
|
|
||||||
|
|
@ -123,41 +123,41 @@ static void default_idle_hook(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
osKernelResume(os_timer->resume());
|
osKernelResume(os_timer->resume());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static void default_idle_hook(void)
|
static void default_idle_hook(void)
|
||||||
{
|
{
|
||||||
// critical section to complete sleep with locked deepsleep
|
// critical section to complete sleep with locked deepsleep
|
||||||
core_util_critical_section_enter();
|
core_util_critical_section_enter();
|
||||||
sleep_manager_lock_deep_sleep();
|
sleep_manager_lock_deep_sleep();
|
||||||
sleep();
|
sleep();
|
||||||
sleep_manager_unlock_deep_sleep();
|
sleep_manager_unlock_deep_sleep();
|
||||||
core_util_critical_section_exit();
|
core_util_critical_section_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // (defined(MBED_TICKLESS) && defined(DEVICE_LPTICKER))
|
#endif // (defined(MBED_TICKLESS) && defined(DEVICE_LPTICKER))
|
||||||
|
|
||||||
static void (*idle_hook_fptr)(void) = &default_idle_hook;
|
static void (*idle_hook_fptr)(void) = &default_idle_hook;
|
||||||
|
|
||||||
void rtos_attach_idle_hook(void (*fptr)(void))
|
void rtos_attach_idle_hook(void (*fptr)(void))
|
||||||
{
|
{
|
||||||
//Attach the specified idle hook, or the default idle hook in case of a NULL pointer
|
//Attach the specified idle hook, or the default idle hook in case of a NULL pointer
|
||||||
if (fptr != NULL) {
|
if (fptr != NULL) {
|
||||||
idle_hook_fptr = fptr;
|
idle_hook_fptr = fptr;
|
||||||
} else {
|
} else {
|
||||||
idle_hook_fptr = default_idle_hook;
|
idle_hook_fptr = default_idle_hook;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MBED_NORETURN void rtos_idle_loop(void)
|
MBED_NORETURN void rtos_idle_loop(void)
|
||||||
{
|
{
|
||||||
//Continuously call the idle hook function pointer
|
//Continuously call the idle hook function pointer
|
||||||
while (1) {
|
while (1) {
|
||||||
idle_hook_fptr();
|
idle_hook_fptr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue