📄 rtc_set.c
字号:
#include <time.h>#include <stdio.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <stdlib.h>#include <sys/ioctl.h>#include <errno.h>#include <asm/types.h>#include <linux/rtc.h>#include "../include/api.h"void help(void){ printf("Usage : rtc_set year-month-day@hour:minute:second\n"); printf("example: rtc_set 2005-03-03@10:10:10\n");} int main(int argc,const char * argv[]){ struct tm read_tm; struct tm t; int nr; //ds1302_set_time(&t); if(argc < 2){ help(); return 1; } ds1302_get_time(&read_tm); printf("DS1302 rtc time now is : "); show_time(&read_tm); nr = sscanf(argv[1],"%4d-%2d-%2d@%2d:%2d:%2d", &(t.tm_year), &(t.tm_mon), &(t.tm_mday), &(t.tm_hour), &(t.tm_min), &(t.tm_sec)); if(nr != 6){ help(); return 2; } t.tm_year -= 1900; t.tm_mon -= 1; printf("set new date time: \n"); rtc_set_time(&t); rtc_get_time(&t); printf("AT91RM9200 rtc time: "); show_time(&t); ds1302_set_time(&t); ds1302_get_time(&read_tm); printf("DS1302 rtc time: "); show_time(&read_tm);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -