rtc_test.c

来自「ATMEL公司的AT91RM9200的实时时钟的测试程序」· C语言 代码 · 共 43 行

C
43
字号
#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"int main(int argc,const char * argv[]){     struct tm read_tm;     struct tm t; 	t.tm_sec  = 50;	//0-59	t.tm_min  = 59;	//0-59	t.tm_hour = 23;	//0-23	t.tm_mday = 25; //1-31	t.tm_mon  = 1; //0-11	t.tm_wday = 1; 	//0-6 week day 	t.tm_year = 105; //0-199   2005-1900	//ds1302_set_time(&t); 	if(argc>1){		 if(strcmp(argv[1],"w")==0){			printf("set new date time: \n");	     	ds1302_set_time(&t);			rtc_set_time(&t);					 }	}	rtc_get_time(&read_tm);	printf("AT91RM9200 rtc time: ");   	show_time(&read_tm);	ds1302_get_time(&read_tm);	printf("DS1302     rtc time: ");   	show_time(&read_tm);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?