Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-dev by
Diff: targets/TARGET_Realtek/TARGET_AMEBA/us_ticker.c
- Revision:
- 173:e131a1973e81
- Parent:
- 167:e84263d55307
- Child:
- 174:b96e65c34a4d
--- a/targets/TARGET_Realtek/TARGET_AMEBA/us_ticker.c Thu Aug 31 17:27:04 2017 +0100 +++ b/targets/TARGET_Realtek/TARGET_AMEBA/us_ticker.c Fri Sep 15 14:59:18 2017 +0100 @@ -77,21 +77,22 @@ void us_ticker_set_interrupt(timestamp_t timestamp) { uint32_t cur_time_us; - uint32_t time_def; + uint32_t time_dif; - + HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId); cur_time_us = us_ticker_read(); - if ((uint32_t)timestamp >= cur_time_us) { - time_def = (uint32_t)timestamp - cur_time_us; + if ((uint32_t)timestamp > cur_time_us) { + time_dif = (uint32_t)timestamp - cur_time_us; } else { - time_def = 0xffffffff - cur_time_us + (uint32_t)timestamp; + HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, 0xffffffff); + HalTimerOpExt.HalTimerIrqEn((u32)TimerAdapter.TimerId); + HalTimerOp.HalTimerEn((u32)TimerAdapter.TimerId); + NVIC_SetPendingIRQ(TIMER2_7_IRQ); + return; } - if (time_def < TIMER_TICK_US) { - time_def = TIMER_TICK_US; // at least 1 tick - } - HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId); - HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, time_def); + TimerAdapter.TimerLoadValueUs = time_dif; + HalTimerOpExt.HalTimerReLoad((u32)TimerAdapter.TimerId, time_dif / TIMER_TICK_US); HalTimerOpExt.HalTimerIrqEn((u32)TimerAdapter.TimerId); HalTimerOp.HalTimerEn((u32)TimerAdapter.TimerId);