Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
11-13-2009, 11:36 PM
|
#1
|
LQ Newbie
Registered: Nov 2009
Posts: 4
Rep:
|
Help On RTC !
Is it possible to turn on periodic interrupt for RTC from a kernel module ? We can do it from user space using 'RTC_IRQP_SET' and 'RTC_PIE_ON' options. But what about turning it on from kernel module?
|
|
|
11-14-2009, 10:37 AM
|
#2
|
Moderator
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,961
|
Hi,
You should read the rest of the 'man rtc'.
'RTC' management is very important so the use of handler/API are preferred;
Quote:
excerpt 'man rtc';
FILES
/dev/rtc, /dev/rtc0, /dev/rtc1, etc: RTC special character device files.
/proc/driver/rtc: status of the (first) RTC.
NOTES
When the kernel's system time is synchronized with an external reference using adjtimex(2) it
will update a designated RTC periodically every 11 minutes. To do so, the kernel has to briefly
turn off periodic interrupts; this might affect programs using that RTC.
An RTC's Epoch has nothing to do with the POSIX Epoch which is only used for the system clock.
If the year according to the RTC's Epoch and the year register is less than 1970 it is assumed to
be 100 years later, that is, between 2000 and 2069.
Some RTCs support "wildcard" values in alarm fields, to support scenarios like periodic alarms at
fifteen minutes after every hour, or on the first day of each month. Such usage is non-portable;
portable user space code only expects a single alarm interrupt, and will either disable or reini-
tialize the alarm after receiving it.
Some RTCs support periodic interrupts with periods that are multiples of a second rather than
fractions of a second; multiple alarms; programmable output clock signals; non-volatile memory;
and other hardware capabilities that are not currently exposed by this API.
SEE ALSO
date(1), adjtimex(2), gettimeofday(2), settimeofday(2), stime(2), time(2), gmtime(3), time(7),
hwclock(8), /usr/src/linux/Documentation/rtc.txt
|
You should look at '/usr/src/linux/Documentation/rtc.txt' to gain some insight. If you want to work at the kernel level then I suggest that you look at ' Linux Kernel Parameters' & ' Linux Device Drivers, Third Edition'.
The above links and others can be found at ' Slackware-Links'. More than just SlackwareŽ links!
|
|
|
11-21-2009, 12:26 AM
|
#3
|
LQ Newbie
Registered: Nov 2009
Posts: 4
Original Poster
Rep:
|
Hi there..........,
Thanks Gary !
I turned on periodic interrupt from user space and loaded a kernel module with my ISR for RTC interrupt. What i need exactly is to execute my ISR on each RTC interrupt. But i couldnt find it working. I am attaching the code herewith. Any suggestions on what went wrong ?
---------------
irqreturn_t my_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
{
printk("Inside ISR for IRQ 8,\n");
}
int init_module(void)
{
printk("<1>Hello World\n");
request_irq(8, my_irq_handler, IRQF_SHARED,"test", NULL);
return 0;
}
void cleanup_module(void)
{
printk("<1>GoodBye World\n");
free_irq(8, NULL);
}
MODULE_LICENSE("GPL");
--------------
*******************
int main()
{
int fd,retval,freq,i=1;
unsigned long temp,data;
fd=open("/dev/rtc0",O_RDONLY);
freq= 2;
ioctl(fd, RTC_IRQP_SET, freq);
fflush(stderr);
/* Enable periodic interrupts */
ioctl(fd, RTC_PIE_ON, 0);
while(1)
{
/* This blocks */
retval = read(fd, &data, sizeof(unsigned long));
if (retval == -1)
{
perror("read");
exit(errno);
}
fprintf(stderr, " %d",i);
i++;
}
}
*******************
|
|
|
All times are GMT -5. The time now is 08:38 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|