DS1307-Linux测试成功.doc

  1. 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 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);

文档评论(0)

gshshxx + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档