summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjonas <[email protected]>2021-09-02 10:36:07 +0800
committerjonas <[email protected]>2021-09-02 10:36:07 +0800
commitd72ee7b6cc19e3b0d5721b2b5fa047ed1a5fc7c4 (patch)
treeab7034a4df4cb5171a68c2236f9f831c8cd27ed0 /src
parentab43390fe2c0e672771b73cf610e739a419aa06f (diff)
parent8d175ab3d237dccc25450a8e12808fc87318eb2f (diff)
Merge branch 'master' of [email protected]:RT-Thread/rt-thread.git into bsp_hk32
# Conflicts: # .ignore_format.yml
Diffstat (limited to 'src')
-rw-r--r--src/irq.c14
-rw-r--r--src/memheap.c6
-rw-r--r--src/timer.c94
3 files changed, 70 insertions, 44 deletions
diff --git a/src/irq.c b/src/irq.c
index 40c2aa5305..3889a2a2c8 100644
--- a/src/irq.c
+++ b/src/irq.c
@@ -25,9 +25,9 @@ static void (*rt_interrupt_leave_hook)(void);
*
* @brief This function set a hook function when the system enter a interrupt
*
- * @note the hook function must be simple and never be blocked or suspend.
+ * @note The hook function must be simple and never be blocked or suspend.
*
- * @param hook The function point to be called
+ * @param hook the function point to be called
*/
void rt_interrupt_enter_sethook(void (*hook)(void))
{
@@ -39,9 +39,9 @@ void rt_interrupt_enter_sethook(void (*hook)(void))
*
* @brief This function set a hook function when the system exit a interrupt.
*
- * @note the hook function must be simple and never be blocked or suspend.
+ * @note The hook function must be simple and never be blocked or suspend.
*
- * @param hook The function point to be called
+ * @param hook the function point to be called
*/
void rt_interrupt_leave_sethook(void (*hook)(void))
{
@@ -65,7 +65,7 @@ volatile rt_uint8_t rt_interrupt_nest = 0;
/**
* @brief This function will be invoked by BSP, when enter interrupt service routine
*
- * @note please don't invoke this routine in application
+ * @note Please don't invoke this routine in application
*
* @see rt_interrupt_leave
*/
@@ -87,7 +87,7 @@ RTM_EXPORT(rt_interrupt_enter);
/**
* @brief This function will be invoked by BSP, when leave interrupt service routine
*
- * @note please don't invoke this routine in application
+ * @note Please don't invoke this routine in application
*
* @see rt_interrupt_enter
*/
@@ -112,7 +112,7 @@ RTM_EXPORT(rt_interrupt_leave);
* User application can invoke this function to get whether current
* context is interrupt context.
*
- * @return rt_uint8_t the number of nested interrupts.
+ * @return the number of nested interrupts.
*/
RT_WEAK rt_uint8_t rt_interrupt_get_nest(void)
{
diff --git a/src/memheap.c b/src/memheap.c
index d0801d721b..e09f5c4bce 100644
--- a/src/memheap.c
+++ b/src/memheap.c
@@ -730,13 +730,15 @@ int memheaptrace(void)
if (count > 0)
{
int index;
+#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
extern int list_memheap(void);
+#endif
heaps = (struct rt_memheap **)rt_malloc(sizeof(struct rt_memheap *) * count);
if (heaps == RT_NULL) return 0;
-
+#if defined(RT_USING_FINSH) && defined(MSH_USING_BUILT_IN_COMMANDS)
list_memheap();
-
+#endif
rt_kprintf("memheap header size: %d\n", RT_MEMHEAP_SIZE);
count = rt_object_get_pointers(RT_Object_Class_MemHeap, (rt_object_t *)heaps, count);
for (index = 0; index < count; index++)
diff --git a/src/timer.c b/src/timer.c
index 07647a55f9..25ba175306 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -61,9 +61,9 @@ static void (*rt_timer_exit_hook)(struct rt_timer *timer);
/**
* @brief This function will set a hook function on timer,
- * which will be invoked when enter timer timeout callback function.
+ * which will be invoked when enter timer timeout callback function.
*
- * @param hook the function point of timer
+ * @param hook is the function point of timer
*/
void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer))
{
@@ -72,9 +72,9 @@ void rt_timer_enter_sethook(void (*hook)(struct rt_timer *timer))
/**
* @brief This function will set a hook function, which will be
- * invoked when exit * timer timeout callback function.
+ * invoked when exit timer timeout callback function.
*
- * @param hook the function point of timer
+ * @param hook is the function point of timer
*/
void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer))
{
@@ -86,16 +86,20 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer))
/**
- * @brief [internal] the init funtion of timer
+ * @brief [internal] The init funtion of timer
*
- * the internal called function of rt_timer_init
+ * The internal called function of rt_timer_init
*
* @see rt_timer_init
*
- * @param timer the static timer object
- * @param timeout the timeout function
- * @param parameter the parameter of timeout function
- * @param time the tick of timer
+ * @param timer is timer object
+ *
+ * @param timeout is the timeout function
+ *
+ * @param parameter is the parameter of timeout function
+ *
+ * @param time is the tick of timer
+ *
* @param flag the flag of timer
*/
static void _timer_init(rt_timer_t timer,
@@ -126,11 +130,11 @@ static void _timer_init(rt_timer_t timer,
}
/**
- * @brief find the next emtpy timer
+ * @brief Find the next emtpy timer ticks
*
- * @param timer_list the timer of the next timeout
+ * @param timer_list is the array of time list
*
- * @return rt_tick_t the point of timer
+ * @return the next timer's ticks
*/
static rt_tick_t _timer_list_next_timeout(rt_list_t timer_list[])
{
@@ -155,9 +159,9 @@ static rt_tick_t _timer_list_next_timeout(rt_list_t timer_list[])
}
/**
- * @brief remove the timer
+ * @brief Remove the timer
*
- * @param timer the point of timer
+ * @param timer the point of the timer
*/
rt_inline void _timer_remove(rt_timer_t timer)
{
@@ -171,10 +175,11 @@ rt_inline void _timer_remove(rt_timer_t timer)
#if RT_DEBUG_TIMER
/**
- * @brief the number of timer
+ * @brief The number of timer
*
- * @param timer
- * @return int the count
+ * @param timer the head of timer
+ *
+ * @return count of timer
*/
static int _timer_count_height(struct rt_timer *timer)
{
@@ -218,12 +223,18 @@ void rt_timer_dump(rt_list_t timer_heads[])
/**
* @brief This function will initialize a timer
* normally this function is used to initialize a static timer object.
- * @param timer the static timer object
- * @param name the name of timer
- * @param timeout the timeout function
- * @param parameter the parameter of timeout function
- * @param time the tick of timer
- * @param flag the flag of timer
+ *
+ * @param timer is the point of timer
+ *
+ * @param name is a pointer to the name of the timer
+ *
+ * @param timeout is the callback of timer
+ *
+ * @param parameter is the param of the callback
+ *
+ * @param time is the ticks of timer
+ *
+ * @param flag is the flag of timer
*/
void rt_timer_init(rt_timer_t timer,
const char *name,
@@ -245,8 +256,9 @@ RTM_EXPORT(rt_timer_init);
/**
* @brief This function will detach a timer from timer management.
*
- * @param timer the timer to be detached
- * @return rt_err_t RT_EOK
+ * @param timer is the timer to be detached
+ *
+ * @return the status of detach
*/
rt_err_t rt_timer_detach(rt_timer_t timer)
{
@@ -278,9 +290,13 @@ RTM_EXPORT(rt_timer_detach);
* @brief This function will create a timer
*
* @param name the name of timer
+ *
* @param timeout the timeout function
+ *
* @param parameter the parameter of timeout function
+ *
* @param time the tick of timer
+ *
* @param flag the flag of timer
*
* @return the created timer object
@@ -351,6 +367,7 @@ rt_err_t rt_timer_start(rt_timer_t timer)
unsigned int row_lvl;
rt_list_t *timer_list;
register rt_base_t level;
+ register rt_bool_t need_schedule;
rt_list_t *row_head[RT_TIMER_SKIP_LIST_LEVEL];
unsigned int tst_nr;
static unsigned int random_nr;
@@ -359,6 +376,8 @@ rt_err_t rt_timer_start(rt_timer_t timer)
RT_ASSERT(timer != RT_NULL);
RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer);
+ need_schedule = RT_FALSE;
+
/* stop timer firstly */
level = rt_hw_interrupt_disable();
/* remove timer from list */
@@ -441,9 +460,6 @@ rt_err_t rt_timer_start(rt_timer_t timer)
timer->parent.flag |= RT_TIMER_FLAG_ACTIVATED;
- /* enable interrupt */
- rt_hw_interrupt_enable(level);
-
#ifdef RT_USING_TIMER_SOFT
if (timer->parent.flag & RT_TIMER_FLAG_SOFT_TIMER)
{
@@ -453,11 +469,19 @@ rt_err_t rt_timer_start(rt_timer_t timer)
{
/* resume timer thread to check soft timer */
rt_thread_resume(&_timer_thread);
- rt_schedule();
+ need_schedule = RT_TRUE;
}
}
#endif /* RT_USING_TIMER_SOFT */
+ /* enable interrupt */
+ rt_hw_interrupt_enable(level);
+
+ if (need_schedule)
+ {
+ rt_schedule();
+ }
+
return RT_EOK;
}
RTM_EXPORT(rt_timer_start);
@@ -503,7 +527,7 @@ RTM_EXPORT(rt_timer_stop);
* @param cmd the control command
* @param arg the argument
*
- * @return RT_EOK
+ * @return the statu of control
*/
rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg)
{
@@ -558,7 +582,7 @@ RTM_EXPORT(rt_timer_control);
* @brief This function will check timer list, if a timeout event happens,
* the corresponding timeout function will be invoked.
*
- * @note this function shall be invoked in operating system timer interrupt.
+ * @note This function shall be invoked in operating system timer interrupt.
*/
void rt_timer_check(void)
{
@@ -642,7 +666,7 @@ rt_tick_t rt_timer_next_timeout_tick(void)
#ifdef RT_USING_TIMER_SOFT
/**
* @brief This function will check software-timer list, if a timeout event happens, the
- * corresponding timeout function will be invoked.
+ * corresponding timeout function will be invoked.
*/
void rt_soft_timer_check(void)
{
@@ -719,9 +743,9 @@ void rt_soft_timer_check(void)
}
/**
- * @brief system timer thread entry
+ * @brief System timer thread entry
*
- * @param parameter
+ * @param parameter is the arg of the thread
*/
static void _timer_thread_entry(void *parameter)
{