rtc.h 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __RT_HW_SERIAL_H__
  2. #define __RT_HW_SERIAL_H__
  3. #include <rthw.h>
  4. #include <rtthread.h>
  5. #include "s3c24x0.h"
  6. #define RTC_DEBUG
  7. #define RTC_ENABLE() (RTCCON |= 0x01) //RTC read and write enable
  8. #define RTC_DISABLE() (RTCCON &= ~0x01) //RTC read and write disable
  9. #define BCD2BIN(n) (((((n) >> 4) & 0x0F) * 10) + ((n) & 0x0F))
  10. #define BIN2BCD(n) ((((n) / 10) << 4) | ((n) % 10))
  11. #define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400)
  12. #define LEAP_YEAR(year) ((!(year % 4) && (year % 100)) || !(year % 400))
  13. static const unsigned char days_in_month[] =
  14. {
  15. 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
  16. };
  17. struct rtc_time
  18. {
  19. int tm_sec;
  20. int tm_min;
  21. int tm_hour;
  22. int tm_mday;
  23. int tm_mon;
  24. int tm_year;
  25. int tm_wday;
  26. int tm_yday;
  27. int tm_isdst;
  28. };
  29. void rt_hw_rtc_get (struct rtc_time *tmp);
  30. void rt_hw_rtc_set (struct rtc_time *tmp);
  31. void rt_hw_rtc_reset (void);
  32. void rt_rtc_time_to_tm(rt_uint32_t time, struct tm *tm);
  33. #endif