sys.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <fcntl.h>
  4. #include <unistd.h>
  5. #include <string.h>
  6. #include <limits.h>
  7. #include "rtdbg.h"
  8. #include "sys.h"
  9. #include "paras.h"
  10. #include "cfg.h"
  11. #include "fs.h"
  12. #include "thread.h"
  13. #if 1
  14. #define LOGE LOG_E
  15. #define LOGW LOG_W
  16. #define LOGD LOG_D
  17. #else
  18. #define LOGD rt_printf
  19. #define LOGW rt_printf
  20. #define LOGE rt_printf
  21. #endif
  22. ////////////////////////////////////////////////////////////////////
  23. int sys_reboot(void)
  24. {
  25. int r=0;
  26. r = system("reboot");
  27. if(r) {
  28. LOGE("sys_reboot failed!\n");
  29. return -1;
  30. }
  31. return r;
  32. }
  33. int sys_get_chip_id(int *id)
  34. {
  35. if(!id) {
  36. return -1;
  37. }
  38. return 0;
  39. }
  40. static void* poll_thread(void *arg)
  41. {
  42. thread_handle_t *h=(thread_handle_t*)arg;
  43. //wdog_init();
  44. //tmp_create();
  45. while(h->quit==0) {
  46. sleep(1);
  47. }
  48. pthread_exit(NULL);
  49. }
  50. int sys_init(void)
  51. {
  52. paras_init();
  53. //thread_start(THREAD_ID_POLL, poll_thread, NULL);
  54. return 0;
  55. }