Skip to content

Commit c7ff74e

Browse files
Added timer_isActive()
1 parent 9f8a782 commit c7ff74e

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

threadX/inc/u_tx_timers.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,12 @@ int timer_restart(timer_t* timer);
6969
*/
7070
int timer_getRemainingTicks(timer_t* timer, uint32_t *remaining);
7171

72+
/**
73+
* @brief Checks whether or not the timer is active.
74+
*
75+
* @param timer Pointer to the timer.
76+
* @param active Buffer to store the information.
77+
*/
78+
int timer_isActive(timer_t* timer, bool* active);
79+
7280
// clang-format on

threadX/src/u_tx_timers.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,20 @@ int timer_getRemainingTicks(timer_t* timer, uint32_t* remaining) {
153153
return U_SUCCESS;
154154
}
155155

156+
/* Gets whether or not the timer is active. */
157+
int timer_isActive(timer_t* timer, bool* active) {
158+
/* Get the remaining ticks status. */
159+
UINT active;
160+
int status = tx_timer_info_get(&timer->TX_TIMER_, (CHAR**)TX_NULL, &active, (ULONG*)TX_NULL, (ULONG*)TX_NULL, (TX_TIMER**)TX_NULL);
161+
if(status != TX_SUCCESS) {
162+
PRINTLN_ERROR("Failed to call tx_timer_info_get (Status: %d/%s, Timer: %s).", status, tx_status_toString(status), timer->name);
163+
return U_ERROR;
164+
}
165+
166+
/* Set the remaining ticks. */
167+
*active = (active == TX_TRUE);
168+
169+
return U_SUCCESS;
170+
}
171+
156172
// clang-format on

0 commit comments

Comments
 (0)