Bläddra i källkod

[libc][time] add LOG_W to give a warning when RTC device is not used

Meco Man 4 år sedan
förälder
incheckning
0ec2a5f782
1 ändrade filer med 4 tillägg och 1 borttagningar
  1. 4 1
      components/libc/compilers/common/time.c

+ 4 - 1
components/libc/compilers/common/time.c

@@ -21,6 +21,7 @@
 
 
 #include <sys/time.h>
 #include <sys/time.h>
 #include <rtthread.h>
 #include <rtthread.h>
+#include <rtdbg.h>
 #ifdef RT_USING_DEVICE
 #ifdef RT_USING_DEVICE
 #include <rtdevice.h>
 #include <rtdevice.h>
 #endif
 #endif
@@ -219,6 +220,7 @@ RT_WEAK time_t time(time_t *t)
 
 
     if(time_now == (time_t)-1)
     if(time_now == (time_t)-1)
     {
     {
+        LOG_W("Cannot find a RTC device to provide time!");
         errno = ENOSYS;
         errno = ENOSYS;
     }
     }
 
 
@@ -246,12 +248,13 @@ int stime(const time_t *t)
     }
     }
     else
     else
     {
     {
+        LOG_W("Cannot find a RTC device to provide time!");
         errno = ENOSYS;
         errno = ENOSYS;
         return -1;
         return -1;
     }
     }
     return 0;
     return 0;
-
 #else
 #else
+    LOG_W("Cannot find a RTC device to provide time!");
     errno = ENOSYS;
     errno = ENOSYS;
     return -1;
     return -1;
 #endif /* RT_USING_RTC */
 #endif /* RT_USING_RTC */