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
**************************************** ************************