forked from Imagelibrary/rtems
2009-05-27 Sebastian Huber <sebastian.huber@embedded-brains.de>
* tod.h, tod.c: Update for new RTC driver interface.
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2009-05-27 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
|
* tod.h, tod.c: Update for new RTC driver interface.
|
||||||
|
|
||||||
2009-05-18 Joel Sherrill <joel.sherrill@OARcorp.com>
|
2009-05-18 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||||
|
|
||||||
* bsppost.c: Fix typo.
|
* bsppost.c: Fix typo.
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
|
#include <rtems/rtc.h>
|
||||||
|
#include <rtems/libio.h>
|
||||||
|
|
||||||
#include <libchip/rtc.h>
|
#include <libchip/rtc.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -65,7 +68,7 @@ rtems_device_driver rtc_initialize(
|
|||||||
* Register and initialize the primary RTC's
|
* Register and initialize the primary RTC's
|
||||||
*/
|
*/
|
||||||
|
|
||||||
status = rtems_io_register_name( "/dev/rtc", major, RTC_Minor );
|
status = rtems_io_register_name( RTC_DEVICE_NAME, major, RTC_Minor );
|
||||||
if (status != RTEMS_SUCCESSFUL) {
|
if (status != RTEMS_SUCCESSFUL) {
|
||||||
rtems_fatal_error_occurred(status);
|
rtems_fatal_error_occurred(status);
|
||||||
}
|
}
|
||||||
@@ -104,6 +107,101 @@ rtems_device_driver rtc_initialize(
|
|||||||
return RTEMS_SUCCESSFUL;
|
return RTEMS_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtems_device_driver rtc_read(
|
||||||
|
rtems_device_major_number major,
|
||||||
|
rtems_device_minor_number minor,
|
||||||
|
void *arg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int rv = 0;
|
||||||
|
rtems_libio_rw_args_t *rw = arg;
|
||||||
|
rtems_time_of_day *tod = (rtems_time_of_day *) rw->buffer;
|
||||||
|
|
||||||
|
rw->offset = 0;
|
||||||
|
rw->bytes_moved = 0;
|
||||||
|
|
||||||
|
if (!RTC_Present) {
|
||||||
|
return RTEMS_NOT_CONFIGURED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rw->count != sizeof( rtems_time_of_day)) {
|
||||||
|
return RTEMS_INVALID_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = RTC_Table [RTC_Minor].pDeviceFns->deviceGetTime(
|
||||||
|
RTC_Minor,
|
||||||
|
tod
|
||||||
|
);
|
||||||
|
if (rv != 0) {
|
||||||
|
return RTEMS_IO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
rw->bytes_moved = rw->count;
|
||||||
|
|
||||||
|
return RTEMS_SUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
rtems_device_driver rtc_write(
|
||||||
|
rtems_device_major_number major,
|
||||||
|
rtems_device_minor_number minor,
|
||||||
|
void *arg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int rv = 0;
|
||||||
|
rtems_libio_rw_args_t *rw = arg;
|
||||||
|
const rtems_time_of_day *tod = (const rtems_time_of_day *) rw->buffer;
|
||||||
|
|
||||||
|
rw->offset = 0;
|
||||||
|
rw->bytes_moved = 0;
|
||||||
|
|
||||||
|
if (!RTC_Present) {
|
||||||
|
return RTEMS_NOT_CONFIGURED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rw->count != sizeof( rtems_time_of_day)) {
|
||||||
|
return RTEMS_INVALID_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = RTC_Table [RTC_Minor].pDeviceFns->deviceSetTime(
|
||||||
|
RTC_Minor,
|
||||||
|
tod
|
||||||
|
);
|
||||||
|
if (rv != 0) {
|
||||||
|
return RTEMS_IO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
rw->bytes_moved = rw->count;
|
||||||
|
|
||||||
|
return RTEMS_SUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
rtems_device_driver rtc_open(
|
||||||
|
rtems_device_major_number major,
|
||||||
|
rtems_device_minor_number minor,
|
||||||
|
void *arg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return RTEMS_SUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
rtems_device_driver rtc_close(
|
||||||
|
rtems_device_major_number major,
|
||||||
|
rtems_device_minor_number minor,
|
||||||
|
void *arg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return RTEMS_SUCCESSFUL;
|
||||||
|
}
|
||||||
|
|
||||||
|
rtems_device_driver rtc_control(
|
||||||
|
rtems_device_major_number major,
|
||||||
|
rtems_device_minor_number minor,
|
||||||
|
void *arg
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return RTEMS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
*
|
*
|
||||||
* This routine copies the time from the real time clock to RTEMS
|
* This routine copies the time from the real time clock to RTEMS
|
||||||
@@ -186,7 +284,7 @@ void getRealTime(
|
|||||||
* Return values: NONE
|
* Return values: NONE
|
||||||
*/
|
*/
|
||||||
int setRealTime(
|
int setRealTime(
|
||||||
rtems_time_of_day *tod
|
const rtems_time_of_day *tod
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!RTC_Present)
|
if (!RTC_Present)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int setRealTime(
|
int setRealTime(
|
||||||
rtems_time_of_day *tod
|
const rtems_time_of_day *tod
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -40,20 +40,20 @@ void getRealTime(
|
|||||||
* Read real time from RTC and set it to RTEMS' clock manager
|
* Read real time from RTC and set it to RTEMS' clock manager
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void setRealTimeToRTEMS();
|
void setRealTimeToRTEMS(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read time from RTEMS' clock manager and set it to RTC
|
* Read time from RTEMS' clock manager and set it to RTC
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void setRealTimeFromRTEMS();
|
void setRealTimeFromRTEMS(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the difference between RTC and RTEMS' clock manager time in minutes.
|
* Return the difference between RTC and RTEMS' clock manager time in minutes.
|
||||||
* If the difference is greater than 1 day, this returns 9999.
|
* If the difference is greater than 1 day, this returns 9999.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int checkRealTime();
|
int checkRealTime(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user