Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
module: timer: add API to update timer status without alarm
Browse files Browse the repository at this point in the history
Some device need interrupt to update internal status. Add new
driver API to do this if there is no acitve alarm.

Change-Id: I6a3106beb8dce8de7de29dfa5ff5742a9fd9692b
Signed-off-by: Joe Zhu <[email protected]>
  • Loading branch information
Joe-Zhucg committed May 19, 2023
1 parent 388bf87 commit 6f5140d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions module/timer/include/mod_timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ struct mod_timer_driver_api {

/*! Get counter frequency */
int (*get_frequency)(fwk_id_t dev_id, uint32_t *value);

/*!
* Timer device may need to update internal status periodically.
* So interrupt is triggered even there is no active alarm.
* Only will be called if interrupt is not an alarm timeout. Optional
*/
void (*update)(fwk_id_t dev_id);
};

/*!
Expand Down
8 changes: 6 additions & 2 deletions module/timer/src/mod_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,12 @@ static void timer_isr(uintptr_t ctx_ptr)
(struct alarm_sub_element_ctx *)fwk_list_pop_head(&ctx->alarms_active);

if (alarm == NULL) {
/* Timer interrupt triggered without any alarm in the active queue */
fwk_unexpected();
if (ctx->driver->update) {
ctx->driver->update(ctx->driver_dev_id);
} else {
/* Timer interrupt triggered without any alarm in the active queue */
fwk_unexpected();
}
return;
}

Expand Down

0 comments on commit 6f5140d

Please sign in to comment.