- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
DS1307-Linux测试成功.doc
DS1307-Linux测试成功
1、编译内核支持:
2、添加设备以及注册设备:
添加设备:
static struct i2c_board_info ek_i2c_devices[] __initdata = {
{
.driver_name = rtc-ds1307,
.addr = 0x68,
.type = ds1338,
},
};
注册:
方法一:(首选)
at91_add_device_i2c(ek_i2c_devices,ARRAY_SIZE(ek_i2c_devices));
方法二:
i2c_register_board_info(0,ek_i2c_devices,ARRAY_SIZE(ek_i2c_devices));
3、测试:
测试代码:
/*
* Real Time Clock Driver Test/Example Program
* Compile with:
* gcc -s -Wall -Wstrict-prototypes rtctest.c -o rtctest
* Copyright (C) 1996, Paul Gortmaker.
* Released under the GNU General Public License, version 2,
* included herein by reference.
*/
#include stdio.h
#include linux/rtc.h
#include sys/ioctl.h
#include sys/time.h
#include sys/types.h
#include fcntl.h
#include unistd.h
#include stdlib.h
#include errno.h
/*
* This expects the new RTC class driver framework, working with
* clocks that will often not be clones of what the PC-AT had.
* Use the command line to specify another RTC if you need one.
*/
static const char default_rtc[] = /dev/rtc1;
int main(int argc, char **argv)
{
int i, fd, retval;
struct rtc_time rtc_tm;
struct rtc_time rtc_wr = {
.tm_mday=22,
.tm_mon =2,
.tm_year =112,
.tm_hour=3,
.tm_min=55,
.tm_sec=50,
};
const char *rtc = default_rtc;
switch (argc) {
case 2:
rtc = argv[1];
/* FALLTHROUGH */
case 1:
break;
default:
fprintf(stderr, usage: rtctest [rtcdev]\n);
return 1;
}
fd = open(rtc, O_RDWR);
if (fd == -1) {
perror(rtc);
exit(errno);
}
fprintf(stderr, \n\t\t\tRTC Driver Test Example.\n\n);
// Write the RTC time/date
retval = ioctl(fd, RTC_SET_TIME, rtc_wr);
if (retval == -1) {
perror(RTC_SET_TIME ioctl);
您可能关注的文档
最近下载
- 油田开发与分析研究知识问答汇编.doc VIP
- 2025陕西公需课党的二十届三中全会精神解读与高质量发展答案.docx VIP
- NFPA 110-2019 国外国际标准.pdf VIP
- 宿舍规章制度十条.docx VIP
- (2025)第九届全国中小学“学宪法、讲宪法”活动知识竞赛题库及答案.pdf VIP
- 严明党的纪律和规矩论述摘编.docx VIP
- 福建省福州第一中学2024-2025学年高一下学期第四学段模块考试(7月期末)数学试题(含部分答案).pdf
- DB36∕T 1601-2022 猪场粪污异位发酵处理技术规程.pdf VIP
- 甘肃白银有色集团股份有限公司招聘真题.docx VIP
- 《科研基金申请撰写策略》课件.ppt VIP
文档评论(0)