Skip to content

Commit 4b9913f

Browse files
authored
Merge pull request #4802 from rtthread-bot/rtt_bot
[update] RT-Thread Robot automatic submission
2 parents fab435a + 1e7dfa6 commit 4b9913f

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

bsp/stm32/libraries/HAL_Drivers/drv_common.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,32 @@ void _Error_Handler(char *s, int num)
113113
*/
114114
void rt_hw_us_delay(rt_uint32_t us)
115115
{
116-
rt_uint32_t start, now, delta, reload, us_tick;
117-
start = SysTick->VAL;
118-
reload = SysTick->LOAD;
119-
us_tick = SystemCoreClock / 1000000UL;
120-
do
116+
rt_uint32_t ticks;
117+
rt_uint32_t told, tnow, tcnt = 0;
118+
rt_uint32_t reload = SysTick->LOAD;
119+
120+
ticks = us * reload / (1000000 / RT_TICK_PER_SECOND);
121+
told = SysTick->VAL;
122+
while (1)
121123
{
122-
now = SysTick->VAL;
123-
delta = start >= now ? start - now : reload + start - now;
124+
tnow = SysTick->VAL;
125+
if (tnow != told)
126+
{
127+
if (tnow < told)
128+
{
129+
tcnt += told - tnow;
130+
}
131+
else
132+
{
133+
tcnt += reload - tnow + told;
134+
}
135+
told = tnow;
136+
if (tcnt >= ticks)
137+
{
138+
break;
139+
}
140+
}
124141
}
125-
while (delta < us_tick * us);
126142
}
127143

128144
/**

components/drivers/include/ipc/workqueue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ rt_err_t rt_workqueue_submit_work(struct rt_workqueue *queue, struct rt_work *wo
6464
rt_err_t rt_workqueue_cancel_work(struct rt_workqueue *queue, struct rt_work *work);
6565
rt_err_t rt_workqueue_cancel_work_sync(struct rt_workqueue *queue, struct rt_work *work);
6666
rt_err_t rt_workqueue_cancel_all_work(struct rt_workqueue *queue);
67+
rt_err_t rt_workqueue_critical_work(struct rt_workqueue *queue, struct rt_work *work);
6768

6869
#ifdef RT_USING_SYSTEM_WORKQUEUE
6970
rt_err_t rt_work_submit(struct rt_work *work, rt_tick_t time);

0 commit comments

Comments
 (0)