Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions arch/arm/src/armv7-m/arm_systick.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,22 @@ static int systick_interrupt(int irq, void *context, void *arg)
if (lower->callback && systick_is_running())
{
uint32_t reload = getreg32(NVIC_SYSTICK_RELOAD);
uint32_t interval = usec_from_count(
RELOAD2TIMEOUT(reload), lower->freq);

/* Convert count to us then to tick for callback parameter */

uint32_t interval = USEC2TICK(usec_from_count(
RELOAD2TIMEOUT(reload), lower->freq));
uint32_t next_interval = interval;

lower->next_interval = &next_interval;
if (lower->callback(&next_interval, lower->arg))
{
if (next_interval && next_interval != interval)
{
/* Recover tick to us then to count for register writing */

reload = TIMEOUT2RELOAD(
usec_to_count(next_interval, lower->freq));
usec_to_count(TICK2USEC(next_interval), lower->freq));
putreg32(CLAMP_RELOAD(reload), NVIC_SYSTICK_RELOAD);
putreg32(0, NVIC_SYSTICK_CURRENT);
}
Expand Down
11 changes: 8 additions & 3 deletions arch/arm/src/armv8-m/arm_systick.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,22 @@ static int systick_interrupt(int irq, void *context, void *arg)
if (lower->callback && systick_is_running())
{
uint32_t reload = getreg32(NVIC_SYSTICK_RELOAD);
uint32_t interval = usec_from_count(
RELOAD2TIMEOUT(reload), lower->freq);

/* Convert count to us then to tick for callback parameter */

uint32_t interval = USEC2TICK(usec_from_count(
RELOAD2TIMEOUT(reload), lower->freq));
uint32_t next_interval = interval;

lower->next_interval = &next_interval;
if (lower->callback(&next_interval, lower->arg))
{
if (next_interval && next_interval != interval)
{
/* Recover tick to us then to count for register writing */

reload = TIMEOUT2RELOAD(
usec_to_count(next_interval, lower->freq));
usec_to_count(TICK2USEC(next_interval), lower->freq));
putreg32(CLAMP_RELOAD(reload), NVIC_SYSTICK_RELOAD);
putreg32(0, NVIC_SYSTICK_CURRENT);
}
Expand Down