From 7deaa4a49b1d0fb2112a69719141709b9c261c7c Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Wed, 21 Aug 2024 16:05:07 +0800 Subject: [PATCH] Update leds source code --- booster/util_time.h | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-) diff --git a/booster/util_time.h b/booster/util_time.h index adf7391..0f8dbcc 100644 --- a/booster/util_time.h +++ b/booster/util_time.h @@ -8,7 +8,7 @@ * Version: 1.0.0(07/23/2020) * Author: Guo Wenxue <guowenxue@gmail.com> * ChangeLog: 1, Release initial version on "07/23/2020 07:46:37 AM" - * + * ********************************************************************************/ #ifndef __UTIL_TIME_H_ #define __UTIL_TIME_H_ @@ -31,7 +31,7 @@ int year; int month; int day; - int hour; + int hour; int minute; int second; int dayofweek; @@ -40,7 +40,7 @@ /* sleep for micro second */ static inline void msleep(unsigned long ms) { - struct timespec timeout; + struct timespec timeout; unsigned long tmp; timeout.tv_sec = ms / 1000; @@ -52,15 +52,15 @@ else { timeout.tv_nsec = 0; - } - + } + nanosleep(&timeout, 0); } /* call gettimeofday() to get current micro second */ static inline unsigned long time_now() { - struct timeval now; + struct timeval now; gettimeofday(&now, 0); @@ -70,18 +70,18 @@ /* timep has elapsed since $start, unit as micro second*/ static inline uint32_t time_elapsed(uint32_t start) { - uint32_t current = time_now(); + uint32_t current = time_now(); if(current >= start) return current-start; - else + else return current+0xFFFFFFFF-start; } /* call gettimeofday() to get current micro second */ static inline unsigned long time_second() { - struct timeval now; + struct timeval now; gettimeofday(&now, 0); return now.tv_sec; @@ -90,11 +90,11 @@ /* timep has elapsed since $start, unit as micro second*/ static inline uint32_t seconds_elapsed(uint32_t start) { - uint32_t current = time_second(); + uint32_t current = time_second(); if(current >= start) return current-start; - else + else return current+0xFFFFFFFF-start; } @@ -122,7 +122,7 @@ #define time_after(a,b) \ (typecheck(unsigned long, a) && typecheck(unsigned long, b) && ((long)(b) - (long)(a) < 0)) #define time_before(a,b) time_after(b,a) - + #define time_after_eq(a,b) \ (typecheck(unsigned long, a) && typecheck(unsigned long, b) && ((long)(a) - (long)(b) >= 0)) #define time_before_eq(a,b) time_after_eq(b,a) @@ -133,33 +133,33 @@ #define time_after64(a,b) \ (typecheck(__u64, a) && typecheck(__u64, b) && ((__s64)(b) - (__s64)(a) < 0)) #define time_before64(a,b) time_after64(b,a) - + #define time_after_eq64(a,b) \ (typecheck(__u64, a) && typecheck(__u64, b) && ((__s64)(a) - (__s64)(b) >= 0)) #define time_before_eq64(a,b) time_after_eq64(b,a) - + static inline void get_sys_time(date_time_t *date) { time_t now = time(NULL); - struct tm *tnow = localtime(&now); - - memset(date, 0, sizeof(*date)); + struct tm *tnow = localtime(&now); + + memset(date, 0, sizeof(*date)); date->year = 1900 + tnow->tm_year; date->month = 1 + tnow->tm_mon; date->day = tnow->tm_mday; date->hour = tnow->tm_hour; date->minute = tnow->tm_min; - date->second = tnow->tm_sec; - date->dayofweek = tnow->tm_wday; + date->second = tnow->tm_sec; + date->dayofweek = tnow->tm_wday; return; } static inline int get_rtc_time(date_time_t *date) { int rv, fd = -1; - struct rtc_time rtc_tm; + struct rtc_time rtc_tm; memset(date, 0, sizeof(*date)); -- Gitblit v1.9.1