mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 13:13:08 +08:00
arch/xtensa/src/esp32/esp32_rt_timer: Fix typos and re-word some
comments. Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
committed by
David Sidrane
parent
0f3d94e8e8
commit
08aa9ce540
@@ -39,7 +39,7 @@
|
||||
#define RT_TIMER_REPEAT (1 << 0) /* Timer is repeat */
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
|
||||
@@ -80,13 +80,13 @@ static struct esp32_tim_dev_s *s_esp32_tim_dev;
|
||||
* Name: start_rt_timer
|
||||
*
|
||||
* Description:
|
||||
* Start timer by inserting it into running list and reset hardware timer
|
||||
* alarm value if this timer in head of list.
|
||||
* Start the timer by inserting it into the running list and reset the
|
||||
* hardware timer alarm value if this timer is at the head of the list.
|
||||
*
|
||||
* Input Parameters:
|
||||
* timer - RT timer pointer
|
||||
* timeout - Timeout value
|
||||
* repeat - If the timer run repeat
|
||||
* repeat - repeat mode (true: enabled, false: disabled)
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
@@ -124,8 +124,8 @@ static void start_rt_timer(FAR struct rt_timer_s *timer,
|
||||
timer->flags &= ~RT_TIMER_REPEAT;
|
||||
}
|
||||
|
||||
/** Scan timer list and insert the new timer into previous
|
||||
* node of timer whose alarm value is larger than new one
|
||||
/* Scan the timer list and insert the new timer into previous
|
||||
* node of timer whose alarm value is larger than new one
|
||||
*/
|
||||
|
||||
list_for_every_entry(&s_runlist, p, struct rt_timer_s, list)
|
||||
@@ -138,7 +138,9 @@ static void start_rt_timer(FAR struct rt_timer_s *timer,
|
||||
}
|
||||
}
|
||||
|
||||
/* If not find a larger one, insert new timer into tail of list */
|
||||
/* If we didn't find a larger one, insert the new timer at the tail
|
||||
* of the list.
|
||||
*/
|
||||
|
||||
if (!inserted)
|
||||
{
|
||||
@@ -147,11 +149,11 @@ static void start_rt_timer(FAR struct rt_timer_s *timer,
|
||||
|
||||
timer->state = RT_TIMER_READY;
|
||||
|
||||
/* If this timer is in head of list */
|
||||
/* If this timer is at the head of the list */
|
||||
|
||||
if (timer == container_of(s_runlist.next, struct rt_timer_s, list))
|
||||
{
|
||||
/* Reset hardware timer alarm */
|
||||
/* Reset the hardware timer alarm */
|
||||
|
||||
ESP32_TIM_SETALRVL(tim, timer->alarm);
|
||||
ESP32_TIM_SETALRM(tim, true);
|
||||
@@ -165,8 +167,8 @@ static void start_rt_timer(FAR struct rt_timer_s *timer,
|
||||
* Name: stop_rt_timer
|
||||
*
|
||||
* Description:
|
||||
* Stop timer by removing it from running list and reset hardware timer
|
||||
* alarm value if this timer is in head of list.
|
||||
* Stop the timer by removing it from the running list and reset the
|
||||
* hardware timer alarm value if this timer is at the head of list.
|
||||
*
|
||||
* Input Parameters:
|
||||
* timer - RT timer pointer
|
||||
@@ -186,18 +188,17 @@ static void stop_rt_timer(FAR struct rt_timer_s *timer)
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/**
|
||||
* Function "start" can set timer to be repeat, and function "stop"
|
||||
* should remove this feature although it is not in ready state.
|
||||
/* "start" function can set the timer's repeat flag, and function "stop"
|
||||
* should remove this flag.
|
||||
*/
|
||||
|
||||
timer->flags &= ~RT_TIMER_REPEAT;
|
||||
|
||||
/* Only ready timer can be stopped */
|
||||
/* Only timers in "ready" state can be stopped */
|
||||
|
||||
if (timer->state == RT_TIMER_READY)
|
||||
{
|
||||
/* Check if timer is in head of list */
|
||||
/* Check if the timer is at the head of the list */
|
||||
|
||||
if (timer == container_of(s_runlist.next, struct rt_timer_s, list))
|
||||
{
|
||||
@@ -211,15 +212,15 @@ static void stop_rt_timer(FAR struct rt_timer_s *timer)
|
||||
list_delete(&timer->list);
|
||||
timer->state = RT_TIMER_IDLE;
|
||||
|
||||
/* If timer is in in head of list */
|
||||
/* If the timer is at the head of the list */
|
||||
|
||||
if (ishead)
|
||||
{
|
||||
/* If list is not empty */
|
||||
|
||||
if (!list_is_empty(&s_runlist))
|
||||
{
|
||||
/* Reset hardware timer alarm value to be next timer's */
|
||||
/* Set the value from the next timer as the new hardware timer
|
||||
* alarm value
|
||||
*/
|
||||
|
||||
next_timer = container_of(s_runlist.next,
|
||||
struct rt_timer_s,
|
||||
@@ -239,9 +240,9 @@ static void stop_rt_timer(FAR struct rt_timer_s *timer)
|
||||
* Name: delete_rt_timer
|
||||
*
|
||||
* Description:
|
||||
* Delete timer by removing it from list, then set the timer's state
|
||||
* to be "RT_TIMER_DELETE", inserting into work list to let rt-timer
|
||||
* thread to delete it and free resource.
|
||||
* Delete the timer by removing it from the list, then set the timer's
|
||||
* state to "RT_TIMER_DELETE" and finally insert it into the work list
|
||||
* to let the rt-timer's thread to delete it and free the resources.
|
||||
*
|
||||
* Input Parameters:
|
||||
* timer - RT timer pointer
|
||||
@@ -281,8 +282,8 @@ exit:
|
||||
* Name: rt_timer_thread
|
||||
*
|
||||
* Description:
|
||||
* RT timer working thread, it wait for a timeout semaphore, scan
|
||||
* the timeout list and process all timers in this list.
|
||||
* RT timer working thread: Waits for a timeout semaphore, scans
|
||||
* the timeout list and processes all the timers in the list.
|
||||
*
|
||||
* Input Parameters:
|
||||
* argc - Not used
|
||||
@@ -302,7 +303,7 @@ static int rt_timer_thread(int argc, FAR char *argv[])
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Waiting for timers timeout */
|
||||
/* Waiting for all the timers to time out */
|
||||
|
||||
ret = nxsem_wait(&s_toutsem);
|
||||
if (ret)
|
||||
@@ -311,15 +312,13 @@ static int rt_timer_thread(int argc, FAR char *argv[])
|
||||
assert(0);
|
||||
}
|
||||
|
||||
/* Enter critical to check global timer timeout list */
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Process all timers in list */
|
||||
/* Process all the timers in the list */
|
||||
|
||||
while (!list_is_empty(&s_toutlist))
|
||||
{
|
||||
/* Get first timer in list */
|
||||
/* Get the first timer in the list */
|
||||
|
||||
timer = container_of(s_toutlist.next, struct rt_timer_s, list);
|
||||
|
||||
@@ -327,16 +326,14 @@ static int rt_timer_thread(int argc, FAR char *argv[])
|
||||
|
||||
raw_state = timer->state;
|
||||
|
||||
/* Delete timer from list */
|
||||
/* Delete the timer from list */
|
||||
|
||||
list_delete(&timer->list);
|
||||
|
||||
/* Set timer's state to be let it to able to restart by user */
|
||||
/* Set timer's state to idle so it can be restarted by the user. */
|
||||
|
||||
timer->state = RT_TIMER_IDLE;
|
||||
|
||||
/* Leave from critical to start to call "callback" function */
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
if (raw_state == RT_TIMER_TIMEOUT)
|
||||
@@ -348,13 +345,13 @@ static int rt_timer_thread(int argc, FAR char *argv[])
|
||||
kmm_free(timer);
|
||||
}
|
||||
|
||||
/* Enter critical for next scanning list */
|
||||
/* Enter critical section for next scanning list */
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
if (raw_state == RT_TIMER_TIMEOUT)
|
||||
{
|
||||
/* Check if timer is repeat */
|
||||
/* Check if the timer is in "repeat" mode */
|
||||
|
||||
if (timer->flags & RT_TIMER_REPEAT)
|
||||
{
|
||||
@@ -373,7 +370,7 @@ static int rt_timer_thread(int argc, FAR char *argv[])
|
||||
* Name: rt_timer_isr
|
||||
*
|
||||
* Description:
|
||||
* Hardware timer interrupt service function.
|
||||
* Hardware timer interrupt service routine.
|
||||
*
|
||||
* Input Parameters:
|
||||
* irq - Not used
|
||||
@@ -397,13 +394,13 @@ static int rt_timer_isr(int irq, void *context, void *arg)
|
||||
|
||||
ESP32_TIM_ACKINT(tim);
|
||||
|
||||
/* Wake up thread to process timeout timers */
|
||||
/* Wake up the thread to process timed-out timers */
|
||||
|
||||
nxsem_post(&s_toutsem);
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Check if there is timer running */
|
||||
/* Check if there is a timer running */
|
||||
|
||||
if (!list_is_empty(&s_runlist))
|
||||
{
|
||||
@@ -417,19 +414,18 @@ static int rt_timer_isr(int irq, void *context, void *arg)
|
||||
ESP32_TIM_GETCTR(tim, &counter);
|
||||
if (timer->alarm <= counter)
|
||||
{
|
||||
/**
|
||||
* Remove first timer in running list and add it into
|
||||
* timeout list.
|
||||
/* Remove the first timer in the running list and add it to
|
||||
* the timeout list.
|
||||
*
|
||||
* Set the timer's state to be RT_TIMER_TIMEOUT to avoid
|
||||
* other operation.
|
||||
* other operations.
|
||||
*/
|
||||
|
||||
list_delete(&timer->list);
|
||||
timer->state = RT_TIMER_TIMEOUT;
|
||||
list_add_after(&s_toutlist, &timer->list);
|
||||
|
||||
/* Check if thers is timer running */
|
||||
/* Check if there is a timer running */
|
||||
|
||||
if (!list_is_empty(&s_runlist))
|
||||
{
|
||||
@@ -457,7 +453,7 @@ static int rt_timer_isr(int irq, void *context, void *arg)
|
||||
* Name: rt_timer_create
|
||||
*
|
||||
* Description:
|
||||
* Create RT timer by into timer creation arguments
|
||||
* Create a RT timer from the provided arguments.
|
||||
*
|
||||
* Input Parameters:
|
||||
* args - Input RT timer creation arguments
|
||||
@@ -495,12 +491,12 @@ int rt_timer_create(FAR const struct rt_timer_args_s *args,
|
||||
* Name: rt_timer_start
|
||||
*
|
||||
* Description:
|
||||
* Start RT timer.
|
||||
* Start the RT timer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* timer - RT timer pointer
|
||||
* timeout - Timeout value
|
||||
* repeat - If the timer run repeat
|
||||
* repeat - repeat mode (true: enabled, false: disabled)
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
@@ -520,7 +516,7 @@ void rt_timer_start(FAR struct rt_timer_s *timer,
|
||||
* Name: rt_timer_stop
|
||||
*
|
||||
* Description:
|
||||
* Stop RT timer.
|
||||
* Stop the RT timer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* timer - RT timer pointer
|
||||
@@ -539,7 +535,7 @@ void rt_timer_stop(FAR struct rt_timer_s *timer)
|
||||
* Name: rt_timer_delete
|
||||
*
|
||||
* Description:
|
||||
* Stop and deleta RT timer.
|
||||
* Stop and delete RT timer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* timer - RT timer pointer
|
||||
@@ -558,13 +554,13 @@ void rt_timer_delete(FAR struct rt_timer_s *timer)
|
||||
* Name: rt_timer_time_us
|
||||
*
|
||||
* Description:
|
||||
* Get time of RT timer by micro second.
|
||||
* Get time of the RT timer in microseconds.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Time of RT timer by micro second.
|
||||
* Time of the RT timer in microseconds.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -588,7 +584,7 @@ uint64_t IRAM_ATTR rt_timer_time_us(void)
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Timestamp of the nearest timer event, in microseconds.
|
||||
* Timestamp of the nearest timer event in microseconds.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -625,7 +621,7 @@ uint64_t IRAM_ATTR rt_timer_get_alarm(void)
|
||||
* Adjust current RT timer by a certain value.
|
||||
*
|
||||
* Input Parameters:
|
||||
* time_us - adjustment to apply to RT timer, in microseconds
|
||||
* time_us - adjustment to apply to the RT timer in microseconds.
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
@@ -695,8 +691,7 @@ int esp32_rt_timer_init(void)
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/**
|
||||
* ESP32 hardware timer configuration:
|
||||
/* ESP32 hardware timer configuration:
|
||||
* - 1 counter = 1us
|
||||
* - Counter increase mode
|
||||
* - Non-reload mode
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define RT_TIMER_NOFLAGS (0) /* Timer support no feature */
|
||||
#define RT_TIMER_REPEAT (1 << 0) /* Timer is repeat */
|
||||
#define RT_TIMER_NOFLAGS (0) /* Timer supports no feature */
|
||||
#define RT_TIMER_REPEAT (1 << 0) /* Timer supports repeat mode */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
@@ -50,7 +50,7 @@ enum rt_timer_state_e
|
||||
{
|
||||
RT_TIMER_IDLE, /* Timer is not counting */
|
||||
RT_TIMER_READY, /* Timer is counting */
|
||||
RT_TIMER_TIMEOUT, /* Timer is timeout */
|
||||
RT_TIMER_TIMEOUT, /* Timer timed out */
|
||||
RT_TIMER_DELETE /* Timer is to be delete */
|
||||
};
|
||||
|
||||
@@ -64,8 +64,8 @@ struct rt_timer_s
|
||||
uint64_t alarm; /* Timeout period */
|
||||
void (*callback)(void *arg); /* Callback function */
|
||||
void *arg; /* Private data */
|
||||
uint16_t flags; /* Support feature */
|
||||
enum rt_timer_state_e state; /* Mark if timer is started */
|
||||
uint16_t flags; /* Supported features */
|
||||
enum rt_timer_state_e state; /* Timer state */
|
||||
struct list_node list; /* Working list */
|
||||
};
|
||||
|
||||
@@ -96,7 +96,7 @@ extern "C"
|
||||
* Name: rt_timer_create
|
||||
*
|
||||
* Description:
|
||||
* Create RT timer by into timer creation arguments
|
||||
* Create a RT timer from the provided arguments.
|
||||
*
|
||||
* Input Parameters:
|
||||
* args - Input RT timer creation arguments
|
||||
@@ -114,12 +114,12 @@ int rt_timer_create(FAR const struct rt_timer_args_s *args,
|
||||
* Name: rt_timer_start
|
||||
*
|
||||
* Description:
|
||||
* Start RT timer.
|
||||
* Start the RT timer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* timer - RT timer pointer
|
||||
* timeout - Timeout value
|
||||
* repeat - If the timer run repeat
|
||||
* repeat - repeat mode (true: enabled, false: disabled)
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
@@ -134,7 +134,7 @@ void rt_timer_start(FAR struct rt_timer_s *timer,
|
||||
* Name: rt_timer_stop
|
||||
*
|
||||
* Description:
|
||||
* Stop RT timer.
|
||||
* Stop the RT timer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* timer - RT timer pointer
|
||||
@@ -150,7 +150,7 @@ void rt_timer_stop(FAR struct rt_timer_s *timer);
|
||||
* Name: rt_timer_delete
|
||||
*
|
||||
* Description:
|
||||
* Stop and deleta RT timer.
|
||||
* Stop and delete the RT timer.
|
||||
*
|
||||
* Input Parameters:
|
||||
* timer - RT timer pointer
|
||||
@@ -166,13 +166,13 @@ void rt_timer_delete(FAR struct rt_timer_s *timer);
|
||||
* Name: rt_timer_time_us
|
||||
*
|
||||
* Description:
|
||||
* Get time of RT timer by micro second.
|
||||
* Get time of the RT timer in microseconds.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Time of RT timer by micro second.
|
||||
* Time of the RT timer in microseconds.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -188,7 +188,7 @@ uint64_t rt_timer_time_us(void);
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Timestamp of the nearest timer event, in microseconds.
|
||||
* Timestamp of the nearest timer event in microseconds.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -201,7 +201,7 @@ uint64_t rt_timer_get_alarm(void);
|
||||
* Adjust current RT timer by a certain value.
|
||||
*
|
||||
* Input Parameters:
|
||||
* time_us - adjustment to apply to RT timer, in microseconds
|
||||
* time_us - adjustment to apply to the RT timer in microseconds.
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
|
||||
Reference in New Issue
Block a user