Exemplo n.º 1
0
void sleep_manager_sleep_auto(void)
{
#ifdef MBED_SLEEP_TRACING_ENABLED
    sleep_tracker_print_stats();
#endif
    core_util_critical_section_enter();
    us_timestamp_t start = read_us();
    bool deep = false;

// debug profile should keep debuggers attached, no deep sleep allowed
#ifdef MBED_DEBUG
    hal_sleep();
#else
    if (sleep_manager_can_deep_sleep()) {
        deep = true;
        hal_deepsleep();
    } else {
        hal_sleep();
    }
#endif

    us_timestamp_t end = read_us();
    if (true == deep) {
        deep_sleep_time += end - start;
    } else {
        sleep_time += end - start;
    }
    core_util_critical_section_exit();
}
Exemplo n.º 2
0
void Timer::interruptHandler()
{
// 	DEBUG("timer irq 0x%x\r\n", this);
	if(TIM_GetIntStatus(TIMER_PERIPHERAL, TIM_MR0_INT) == SET)
	{
// 		DEBUG("overflow 0x%x\r\n", this);
// 		if(isLast)
// 		{
// 			TIM_ClearIntPending(TIMER_PERIPHERAL, TIM_MR0_INT);
// 		}
		overflows++;
	}
	if(TIM_GetIntStatus(TIMER_PERIPHERAL, TIM_MR1_INT) == SET)
	{
// 		if(isLast)
// 		{
// // 			DEBUG("clearing 0x%x\r\n", this);
// 			TIM_ClearIntPending(TIMER_PERIPHERAL, TIM_MR1_INT);
// 		}
		if(callbackActive && read_us() >= callbackDelay)
		{
			frozenTimerValue = TIMER_PERIPHERAL->TC;
// 			DEBUG("calling 0x%x\r\n", this);
			callbackActive = false;
			_removeMatch(matchValue);
			callbackFunction->call();
		}
		else
		{
// 			DEBUG("not calling 0x%x\r\n", this);
		}
	}
}
Exemplo n.º 3
0
int Timer::read_ms() {
    return read_us() / 1000;
}
Exemplo n.º 4
0
float Timer::read() {
    return (float)read_us() / 1000000.0f;
}
Exemplo n.º 5
0
us_timestamp_t mbed_uptime(void)
{
    return read_us();
}