summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/bfin
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-04-17 17:00:38 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-04-17 17:00:38 +0000
commitd7fa4a981b1023c347a0a6309351e7567b7e20c6 (patch)
treeb976884e19d9ff84cfac3d221b9da57a63be3ee1 /c/src/lib/libbsp/bfin
parent2007-04-17 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-d7fa4a981b1023c347a0a6309351e7567b7e20c6.tar.bz2
2007-04-17 Joel Sherrill <joel@OARcorp.com>
* shared/clock/rtc.c, shared/timer/timer.c: Fix compile errors and address most warnings about constants being too large.
Diffstat (limited to 'c/src/lib/libbsp/bfin')
-rw-r--r--c/src/lib/libbsp/bfin/ChangeLog5
-rw-r--r--c/src/lib/libbsp/bfin/shared/clock/rtc.c53
-rw-r--r--c/src/lib/libbsp/bfin/shared/timer/timer.c6
3 files changed, 42 insertions, 22 deletions
diff --git a/c/src/lib/libbsp/bfin/ChangeLog b/c/src/lib/libbsp/bfin/ChangeLog
index f5b64e54e6..5cef731aa8 100644
--- a/c/src/lib/libbsp/bfin/ChangeLog
+++ b/c/src/lib/libbsp/bfin/ChangeLog
@@ -1,3 +1,8 @@
+2007-04-17 Joel Sherrill <joel@OARcorp.com>
+
+ * shared/clock/rtc.c, shared/timer/timer.c: Fix compile errors and
+ address most warnings about constants being too large.
+
2006-12-02 Ralf Corsépius <ralf.corsepius@rtems.org>
* configure.ac: New BUG-REPORT address.
diff --git a/c/src/lib/libbsp/bfin/shared/clock/rtc.c b/c/src/lib/libbsp/bfin/shared/clock/rtc.c
index 4c19ceccfe..aa24c36c28 100644
--- a/c/src/lib/libbsp/bfin/shared/clock/rtc.c
+++ b/c/src/lib/libbsp/bfin/shared/clock/rtc.c
@@ -28,6 +28,20 @@
#define SHF_MINUTE 6
#define SHF_SECOND 0
+/* The following are inside RTEMS -- we are violating visibility!!!
+ * Perhaps an API could be defined to get days since 1 Jan.
+ */
+extern const uint16_t _TOD_Days_to_date[2][13];
+
+/*
+ * Prototypes and routines used below
+ */
+int Leap_years_until_now (int year);
+
+void Init_RTC(void)
+{
+ *((uint16_t*)RTC_PREN) = 0x0001; /* Enable Prescaler */
+}
rtems_device_driver rtc_initialize(
rtems_device_major_number major,
@@ -52,13 +66,6 @@ rtems_device_driver rtc_initialize(
return RTEMS_SUCCESSFUL;
}
-void Init_RTC(void)
-{
- *((uint16_t*)RTC_PREN) = 0x0001; /* Enable Prescaler */
-}
-
-int Leap_years_until_now (int year);
-
/*
* Read time from RTEMS' clock manager and set it to RTC
*/
@@ -98,12 +105,19 @@ int setRealTime(
tod_temp = *tod;
- days = (tod_temp.year - TOD_BASE_YEAR)*365 + _TOD_Days_to_date[0][tod_temp.month] + tod_temp.day - 1;
- if (tod_temp.month < 3) days += Leap_years_until_now (tod_temp.year - 1);
- else days += Leap_years_until_now (tod_temp.year);
+ days = (tod_temp.year - TOD_BASE_YEAR) * 365 + \
+ _TOD_Days_to_date[0][tod_temp.month] + tod_temp.day - 1;
+ if (tod_temp.month < 3)
+ days += Leap_years_until_now (tod_temp.year - 1);
+ else
+ days += Leap_years_until_now (tod_temp.year);
- *((uint32_t*)RTC_STAT) = (days << SHF_DAY)|(tod_temp.hour << SHF_HOUR)|(tod_temp.minute << SHF_MINUTE)|tod_temp.second;
+ *((uint32_t*)RTC_STAT) = (days << SHF_DAY)|
+ (tod_temp.hour << SHF_HOUR)|
+ (tod_temp.minute << SHF_MINUTE)|
+ tod_temp.second;
+ return 0;
}
/*
@@ -124,19 +138,18 @@ void getRealTime(
/* finding year */
tod_temp.year = days/365 + TOD_BASE_YEAR;
- if (days%365 > Leap_years_until_now (tod_temp.year - 1)){
+ if (days%365 > Leap_years_until_now (tod_temp.year - 1)) {
days = (days%365) - Leap_years_until_now (tod_temp.year - 1);
- }else{
+ } else {
tod_temp.year--;
days = (days%365) + 365 - Leap_years_until_now (tod_temp.year - 1);
}
/* finding month and day */
- Leap_year = (((!(tod_temp.year%4)) && (tod_temp.year%100)) || (!(tod_temp.year%400)))?1:0;
- for (n=1; n<=12; n++)
- {
- if (days <= _TOD_Days_to_date[Leap_year][n+1])
- {
+ Leap_year = (((!(tod_temp.year%4)) && (tod_temp.year%100)) ||
+ (!(tod_temp.year%400)))?1:0;
+ for (n=1; n<=12; n++) {
+ if (days <= _TOD_Days_to_date[Leap_year][n+1]) {
tod_temp.month = n;
tod_temp.day = days - _TOD_Days_to_date[Leap_year][n];
break;
@@ -173,5 +186,7 @@ int checkRealTime (void)
int Leap_years_until_now (int year)
{
- return ((year/4 - year/100 + year/400) - ((TOD_BASE_YEAR - 1)/4 - (TOD_BASE_YEAR - 1)/100 + (TOD_BASE_YEAR - 1)/400));
+ return ((year/4 - year/100 + year/400) -
+ ((TOD_BASE_YEAR - 1)/4 - (TOD_BASE_YEAR - 1)/100 +
+ (TOD_BASE_YEAR - 1)/400));
}
diff --git a/c/src/lib/libbsp/bfin/shared/timer/timer.c b/c/src/lib/libbsp/bfin/shared/timer/timer.c
index 9bbf6f7a83..6c51384fc2 100644
--- a/c/src/lib/libbsp/bfin/shared/timer/timer.c
+++ b/c/src/lib/libbsp/bfin/shared/timer/timer.c
@@ -60,9 +60,9 @@ void Timer_initialize( void )
int Read_timer( void )
{
- uint32_t clicks;
- uint32_t total;
- register int *cycles asm ("R2");
+ uint32_t clicks;
+ uint32_t total;
+ register uint32_t cycles asm ("R2");
/* stop counter */
asm("R2 = SYSCFG;");