mirror of https://github.com/ARMmbed/mbed-os.git
RTOS: SysTimer: Split methods for testing
parent
1054277c65
commit
d098cd6757
|
@ -45,6 +45,10 @@ SysTimer::SysTimer() :
|
|||
TimerEvent(get_lp_ticker_data()), _start_time(0), _tick(0)
|
||||
{
|
||||
_start_time = ticker_read_us(_ticker_data);
|
||||
}
|
||||
|
||||
void SysTimer::setup_irq()
|
||||
{
|
||||
#if (defined(NO_SYSTICK))
|
||||
NVIC_SetVector(mbed_get_m0_tick_irqn(), (uint32_t)SysTick_Handler);
|
||||
NVIC_SetPriority(mbed_get_m0_tick_irqn(), 0xFF); /* RTOS requires lowest priority */
|
||||
|
@ -96,16 +100,26 @@ SysTimer::~SysTimer()
|
|||
{
|
||||
}
|
||||
|
||||
void SysTimer::handler()
|
||||
void SysTimer::set_irq_pending()
|
||||
{
|
||||
#if (defined(NO_SYSTICK))
|
||||
NVIC_SetPendingIRQ(mbed_get_m0_tick_irqn());
|
||||
#else
|
||||
SCB->ICSR = SCB_ICSR_PENDSTSET_Msk;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SysTimer::increment_tick()
|
||||
{
|
||||
_tick++;
|
||||
}
|
||||
|
||||
void SysTimer::handler()
|
||||
{
|
||||
set_irq_pending();
|
||||
increment_tick();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,11 @@ public:
|
|||
SysTimer();
|
||||
virtual ~SysTimer();
|
||||
|
||||
/**
|
||||
* Enable an IRQ/SysTick with the correct priority.
|
||||
*/
|
||||
static void setup_irq();
|
||||
|
||||
/**
|
||||
* Schedule an os tick to fire
|
||||
*
|
||||
|
@ -92,6 +97,8 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void handler();
|
||||
void increment_tick();
|
||||
static void set_irq_pending();
|
||||
us_timestamp_t _start_time;
|
||||
uint64_t _tick;
|
||||
};
|
||||
|
|
|
@ -47,6 +47,7 @@ int32_t OS_Tick_Enable (void)
|
|||
// Do not use SingletonPtr since this relies on the RTOS
|
||||
if (NULL == os_timer) {
|
||||
os_timer = new (os_timer_data) rtos::internal::SysTimer();
|
||||
os_timer->setup_irq();
|
||||
}
|
||||
|
||||
// set to fire interrupt on next tick
|
||||
|
|
Loading…
Reference in New Issue