Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
7009557 RTC Device Driver

7009557 RTC Device Driver

Ratings: (0)|Views: 5 |Likes:
Published by NguyenVan Thanh

More info:

Published by: NguyenVan Thanh on Jul 13, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

10/25/2012

pdf

text

original

 
 1
How to use RTC driver
****************************************************************1. Introducation****************************************************************ADSP21535 has one Real Time Clock RTC device, and the RTC driveris designed as a standard Linux RTC driver.The RTC device major/minor numbers:major minor10 135The RTC device name is /dev/rtc.When the read function is called, the application is blockeduntil the RTC interrupt is generated.****************************************************************2. system call****************************************************************The RTC device driver is designed as a standard Linux RTCdriver, and the following system calls are supported.2.1 open: The standard open function call.int open("/dev/rtc", int oflag, /* mode_t mode */...);The open function is used to establish the connection between the RTCdevice with a file descriptor.- oflag:O_RDONLY Open for reading onlyO_WRONLY Open for writing onlyO_RDWR Open for reading and writingUSAGE:------int fd;fd = open("/dev/rtc", O_RDONLY, 0);...close(fd);2.2 close: The standard open function call.int close(int file_handler);The close function is used to disconnect the RTC device with the relevantfile descriptor.USAGE:------int fd;fd = open("/dev/rtc", O_RDONLY, 0);...close(fd);2.3 ioctl: the standard ioctl function call(refer to section 3).int ioctl(int file_handler, int request, /* arg */...);
 
 2
The ioctl command is used to configure the RTC device.USAGE:------int fd;struct rtc_time rtc_tm;int ret;fd = open("/dev/rtc", O_RDONLY, 0);...// the ioctl command RTC_RD_TIME is used to read the current timer.// about the detail ioctl command, refer to section 3ret = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);...close(fd);2.4 read: the standard read function call.ssize_t read(int file_handler, viod *buf, size_t nbytes);In the RTC driver, the read function is used to wait for the RTC deviceinterrupt.When call the read function, the application is locked until a interrupt isgenerated.USAGE:------int fd;int ret;struct rtc_time rtc_tm;unsigned long data;fd = open("/dev/rtc", O_RDONLY, 0);ret = ioctl(fd, RTC_ALM_SET, &rtc_tm);// call the read function to wait the Alarm interruptret = read(fd, &data, sizeof(unsigned long));...close(fd);****************************************************************3. RTC deivce ioctl****************************************************************RTC_SWCNT_OFF: This ioctl does not need an argument, and it canbe used to disable the RTC stop-watch interrupt.RTC_SWCNT_ON: This ioctl does not need an argument, and it canbe used to enable the RTC stop-watch interrupt.RTC_AIE_OFF: This ioctl does not need an argument, and it canbe used to disable the RTC alarm interrupt.RTC_AIE_ON: This ioctl does not need an argument, and it canbe used to enable the RTC alarm interrupt.RTC_UIE_OFF: This ioctl does not need an argument, and it canbe used to disable the RTC update interrupt.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->