| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <string.h>
- #include <limits.h>
- #include <rtdevice.h>
- #include "log.h"
- #include "sys.h"
- #include "lock.h"
- #include "paras.h"
- #include "cfg.h"
- #include "fs.h"
- #include "thread.h"
- ////////////////////////////////////////////////////////////////////
- int sys_reboot(void)
- {
- int r=0;
- r = system("reboot");
- if(r) {
- LOGE("sys_reboot failed!\n");
- return -1;
- }
- return r;
- }
- int sys_get_chip_id(int *id)
- {
- if(!id) {
- return -1;
- }
-
- return 0;
- }
- static void* poll_thread(void *arg)
- {
- thread_handle_t *h=(thread_handle_t*)arg;
- //wdog_init();
- //tmp_create();
- while(h->quit==0) {
- sleep(1);
- }
- pthread_exit(NULL);
- }
- static int sd_mount(void)
- {
- int r=1,n=0;
- while(n<10) {
- r = mmcsd_wait_cd_changed(500);
- if(r==MMCSD_HOST_PLUGED) {
- r = fs_mount("sd", 1);
- }
- else if(r==MMCSD_HOST_UNPLUGED) {
- r = fs_mount("sd", 0);
- }
-
- if(r<=0) break;
- n++;
- }
- return r;
- }
- static void mk_dir(void)
- {
- fs_mkdir("/cfg");
- }
- int sys_init(void)
- {
- sd_mount();
- mk_dir();
- paras_init();
-
- //thread_start(THREAD_ID_POLL, poll_thread, NULL);
- return 0;
- }
|