How to Use the RTC driver

Source: Internet
Author: User

How to Use the RTC driver

**************************************** ************************
1. introducation
**************************************** ************************
Adsp21535 has one real time clock RTC device, and the RTC driver
Is designed as a standard Linux RTC driver.

The RTC device major/minor numbers:
Major minor
10 135

The RTC device name is/dev/RTC.

When the READ function is called, the application is blocked
Until the RTC interrupt is generated.

**************************************** ************************
2. System Call
**************************************** ************************
The RTC device driver is designed as a standard Linux rtc
Driver, and the following system cballs 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 RTC
Device with a file descriptor.
-Oflag:
O_rdonly open for reading only
O_wronly open for writing only
O_rdwr open for reading and writing

Usage:
------
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 relevant
File 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 */...);

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 3
Ret = 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 device interrupt.
When call the READ function, the application is locked until a interrupt is generated.

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 interrupt
Ret = read (FD, & Data, sizeof (unsigned long ));
...
Close (FD );

**************************************** ************************
3. RTC deivce IOCTL
**************************************** ************************
Rtc_swcnt_off: This IOCTL does not need an argument, and it can
Be used to disable the RTC stop-watch interrupt.

Rtc_swcnt_on: This IOCTL does not need an argument, and it can
Be used to enable the RTC stop-watch interrupt.

Rtc_aie_off: This IOCTL does not need an argument, and it can
Be used to disable the RTC alarm interrupt.

Rtc_aie_on: This IOCTL does not need an argument, and it can
Be used to enable the RTC alarm interrupt.

Rtc_uie_off: This IOCTL does not need an argument, and it can
Be used to disable the RTC update interrupt.

Rtc_uie_on: This IOCTL does not need an argument, and it can
Be used to enable the RTC update interrupt.

Rtc_alm_read: This IOCTL needs one argument (struct rtc_time *),
And it can be used to get the current RTC alarm
Parameter.

Rtc_alm_set: This IOCTL needs one argument (struct rtc_time *),
And it can be used to set the RTC alarm.

Rtc_rd_time: This IOCTL needs one argument (struct rtc_time *),
And it can be used to get the current RTC time.

Rtc_set_time: This IOCTL needs one argument (struct rtc_time *),
And it can be used to set the current RTC time.

Rtc_epoch_read: This IOCTL needs one argument (long *), and it
Can be used to get the current RTC epoch.

Rtc_epoch_set: This IOCTL needs one argument (long), and it can
Be used to set the current RTC epoch.

Rtc_swcnt_set: This IOCTL needs one argument (long), and it can
Be used to set the current RTC stop-Watch (
Unit is minute ).

Rtc_swcnt_rd: This IOCTL needs one argument (long *), and it
Can be used to get the current RTC stop-watch
(The unit is minute ).

**************************************** ************************
4. Caution
**************************************** ************************

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.