diff options
| author | Meco Man <[email protected]> | 2020-12-30 03:44:37 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-30 03:44:37 -0600 |
| commit | 4a4f00de6bf553a7b047acb2f43b38693c0afaa2 (patch) | |
| tree | a7db2443e8409bf1304291c583498340364ba6e8 /components | |
| parent | 3bca2cfb418f03c529fc8563b62c19d391caf90b (diff) | |
| parent | 4c399f88bb15416e833e9b86ad9de46807ca12e0 (diff) | |
Merge pull request #8 from RT-Thread/master
pr
Diffstat (limited to 'components')
| -rw-r--r-- | components/dfs/filesystems/jffs2/src/gcthread.c | 28 | ||||
| -rw-r--r-- | components/drivers/hwtimer/hwtimer.c | 9 | ||||
| -rw-r--r-- | components/net/lwip-1.4.1/src/arch/sys_arch.c | 3 | ||||
| -rw-r--r-- | components/net/lwip-2.0.2/src/arch/sys_arch.c | 3 | ||||
| -rw-r--r-- | components/net/lwip-2.1.2/src/arch/sys_arch.c | 3 |
5 files changed, 39 insertions, 7 deletions
diff --git a/components/dfs/filesystems/jffs2/src/gcthread.c b/components/dfs/filesystems/jffs2/src/gcthread.c index 4005ec4788..ab66e1878e 100644 --- a/components/dfs/filesystems/jffs2/src/gcthread.c +++ b/components/dfs/filesystems/jffs2/src/gcthread.c @@ -187,7 +187,8 @@ jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c) { struct super_block *sb=OFNI_BS_2SFFJ(c); cyg_mtab_entry *mte; - rt_uint32_t e; + rt_uint32_t e; + rt_err_t result; //RT_ASSERT(sb->s_gc_thread_handle); @@ -198,10 +199,20 @@ jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c) D1(printk("jffs2_stop_garbage_collect_thread wait\n")); - rt_event_recv(&sb->s_gc_thread_flags, + result = rt_event_recv(&sb->s_gc_thread_flags, GC_THREAD_FLAG_HAS_EXIT, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER, &e); + if (result == -RT_ETIMEOUT) + { + LOG_E("wait completed timeout"); + return; + } + else if (result == -RT_ERROR) + { + LOG_E("event received error"); + return; + } // Kill and free the resources ... this is safe due to the flag // from the thread. @@ -218,15 +229,26 @@ jffs2_garbage_collect_thread(unsigned long data) struct super_block *sb=OFNI_BS_2SFFJ(c); cyg_mtab_entry *mte; rt_uint32_t flag = 0; + rt_err_t result; D1(printk("jffs2_garbage_collect_thread START\n")); while(1) { - rt_event_recv(&sb->s_gc_thread_flags, + result = rt_event_recv(&sb->s_gc_thread_flags, GC_THREAD_FLAG_TRIG | GC_THREAD_FLAG_STOP, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, cyg_current_time() + CYGNUM_JFFS2_GS_THREAD_TICKS, &flag); + if (result == -RT_ETIMEOUT) + { + LOG_E("wait completed timeout"); + continue; + } + else if (result == -RT_ERROR) + { + LOG_E("event received error"); + continue; + } if (flag & GC_THREAD_FLAG_STOP) break; diff --git a/components/drivers/hwtimer/hwtimer.c b/components/drivers/hwtimer/hwtimer.c index 3953919fae..976d8bbf32 100644 --- a/components/drivers/hwtimer/hwtimer.c +++ b/components/drivers/hwtimer/hwtimer.c @@ -10,6 +10,7 @@ #include <rtthread.h> #include <rtdevice.h> +#include <rthw.h> rt_inline rt_uint32_t timeout_calc(rt_hwtimer_t *timer, rt_hwtimerval_t *tv) { @@ -144,19 +145,25 @@ static rt_size_t rt_hwtimer_read(struct rt_device *dev, rt_off_t pos, void *buff rt_hwtimer_t *timer; rt_hwtimerval_t tv; rt_uint32_t cnt; + rt_base_t level; + rt_int32_t overflow; float t; timer = (rt_hwtimer_t *)dev; if (timer->ops->count_get == RT_NULL) return 0; + level = rt_hw_interrupt_disable(); cnt = timer->ops->count_get(timer); + overflow = timer->overflow; + rt_hw_interrupt_enable(level); + if (timer->info->cntmode == HWTIMER_CNTMODE_DW) { cnt = (timer->freq * timer->period_sec) - cnt; } - t = timer->overflow * timer->period_sec + cnt/(float)timer->freq; + t = overflow * timer->period_sec + cnt/(float)timer->freq; tv.sec = t; tv.usec = (t - tv.sec) * 1000000; size = size > sizeof(tv)? sizeof(tv) : size; diff --git a/components/net/lwip-1.4.1/src/arch/sys_arch.c b/components/net/lwip-1.4.1/src/arch/sys_arch.c index 2392dde2fa..2f6dbb4143 100644 --- a/components/net/lwip-1.4.1/src/arch/sys_arch.c +++ b/components/net/lwip-1.4.1/src/arch/sys_arch.c @@ -32,6 +32,7 @@ */ #include <rtthread.h> +#include <rthw.h> #include "lwip/sys.h" #include "lwip/opt.h" @@ -617,7 +618,7 @@ u32_t sys_jiffies(void) u32_t sys_now(void) { - return rt_tick_get() * (1000 / RT_TICK_PER_SECOND); + return rt_tick_get_millisecond(); } #ifdef RT_LWIP_PPP diff --git a/components/net/lwip-2.0.2/src/arch/sys_arch.c b/components/net/lwip-2.0.2/src/arch/sys_arch.c index 40c79011ec..fbf02cad0a 100644 --- a/components/net/lwip-2.0.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.0.2/src/arch/sys_arch.c @@ -32,6 +32,7 @@ */ #include <rtthread.h> +#include <rthw.h> #include "lwip/sys.h" #include "lwip/opt.h" @@ -627,7 +628,7 @@ u32_t sys_jiffies(void) u32_t sys_now(void) { - return rt_tick_get() * (1000 / RT_TICK_PER_SECOND); + return rt_tick_get_millisecond(); } diff --git a/components/net/lwip-2.1.2/src/arch/sys_arch.c b/components/net/lwip-2.1.2/src/arch/sys_arch.c index 0633501bb6..a0eeed1073 100644 --- a/components/net/lwip-2.1.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.1.2/src/arch/sys_arch.c @@ -33,6 +33,7 @@ */ #include <rtthread.h> +#include <rthw.h> #include "lwip/sys.h" #include "lwip/opt.h" @@ -641,7 +642,7 @@ u32_t sys_jiffies(void) u32_t sys_now(void) { - return rt_tick_get() * (1000 / RT_TICK_PER_SECOND); + return rt_tick_get_millisecond(); } #if MEM_OVERFLOW_CHECK || MEMP_OVERFLOW_CHECK |
