ds1742rtc.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* $Id: ds1742rtc.h,v 1.1 2002/02/27 18:57:58 marcelo Exp $
  2.  *
  3.  * ds1742rtc.h - register definitions for the Real-Time-Clock / CMOS RAM
  4.  *
  5.  *   Based on include/asm-mips/ds1643rtc.h.
  6.  *
  7.  * Copyright (C) 1999-2001 Toshiba Corporation
  8.  * It was written to be part of the Linux operating system.
  9.  */
  10. /* permission is hereby granted to copy, modify and redistribute this code
  11.  * in terms of the GNU Library General Public License, Version 2 or later,
  12.  * at your option.
  13.  */
  14. #ifndef _DS1742RTC_H
  15. #define _DS1742RTC_H
  16. #include <linux/rtc.h>
  17. #include <asm/mc146818rtc.h> /* bad name... */
  18. #define RTC_BRAM_SIZE 0x800
  19. #define RTC_OFFSET 0x7f8
  20. /**********************************************************************
  21.  * register summary
  22.  **********************************************************************/
  23. #define RTC_CONTROL (RTC_OFFSET + 0)
  24. #define RTC_CENTURY (RTC_OFFSET + 0)
  25. #define RTC_SECONDS (RTC_OFFSET + 1)
  26. #define RTC_MINUTES (RTC_OFFSET + 2)
  27. #define RTC_HOURS (RTC_OFFSET + 3)
  28. #define RTC_DAY (RTC_OFFSET + 4)
  29. #define RTC_DATE (RTC_OFFSET + 5)
  30. #define RTC_MONTH (RTC_OFFSET + 6)
  31. #define RTC_YEAR (RTC_OFFSET + 7)
  32. #define RTC_CENTURY_MASK 0x3f
  33. #define RTC_SECONDS_MASK 0x7f
  34. #define RTC_DAY_MASK 0x07
  35. /*
  36.  * Bits in the Control/Century register
  37.  */
  38. #define RTC_WRITE 0x80
  39. #define RTC_READ 0x40
  40. /*
  41.  * Bits in the Seconds register
  42.  */
  43. #define RTC_STOP 0x80
  44. /*
  45.  * Bits in the Day register
  46.  */
  47. #define RTC_BATT_FLAG 0x80
  48. #define RTC_FREQ_TEST 0x40
  49. /*
  50.  * Conversion between binary and BCD.
  51.  */
  52. #ifndef BCD_TO_BIN
  53. #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10)
  54. #endif
  55. #ifndef BIN_TO_BCD
  56. #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10)
  57. #endif
  58. #endif /* _DS1742RTC_H */