ds1244y.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:3k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* ds1244y.h - Dallas SRAM/Clock chip structures and addresses */
  2. /*
  3. modification history
  4. --------------------
  5. 01b,23jul93,caf  added support for c++.
  6. 01a,07aug92,sas  written.
  7. */
  8. /*
  9.  * Structures for control of the Dallas Semiconductor DS1244Y Static-Ram-and-
  10.  * Real-Time-Clock chip.
  11.  *
  12.  */
  13. #ifndef __INCds1244yh
  14. #define __INCds1244yh
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif /* __cplusplus */
  18. #define THEDAYS { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }
  19. #define THEMONTHS 
  20.  { "Jan", "Feb", "Mar", "Apr", "May", "Jun", 
  21.        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
  22. /*
  23.  * Here is the magic key to access the clock (rather than the RAM) on the
  24.  * chip. These bits must be shifted into the clock until all 64 bits have
  25.  * been read in. This unlocks the clock for one additional 64-bit access,
  26.  * which may be a read or a write.
  27.  */
  28. #define CLOCK_KEY 
  29.  {0xc5, 0x3a, 0xa3, 0x5c, 0xc5, 0x3a, 0xa3, 0x5c}
  30. /* tm structure for dealing with time of day ala UNIX */
  31. /* all fields are in binary */
  32. typedef struct {
  33.     unsigned char tm_hsec;  /* hundredths of seconds (0-99) */
  34.     unsigned char tm_sec;   /* seconds (0-59) */
  35.     unsigned char tm_min;   /* minutes (0-59) */
  36.     unsigned char tm_hour;  /* hours (0-23) */
  37.     unsigned char tm_mday;  /* day of month (1-31) */
  38.     unsigned char tm_mon;   /* month of year (0-11) */
  39.     unsigned char tm_year;  /* year - 1900 */
  40.     unsigned char tm_wday;  /* day of week (Sunday=0) */
  41.     unsigned char tm_jmsb;  /* MSB of julian date (100's day of year)*/
  42.     unsigned char tm_jlsb;  /* LSB of julian date */
  43. /*  unsigned char tm_isdst; nonzero if Daylight Savings Time in effect */
  44. } TIME_DATA ;
  45. /*
  46.  * These defines are for various conversions to and from the binary
  47.  * structure above and the values that actually get loaded into the
  48.  * clock.
  49.  */
  50. #define MIN_YEAR    1990
  51. #define MAX_YEAR    2089
  52. #define BIAS_YEAR  -1990
  53.  
  54. #define MIN_MONTH    1
  55. #define MAX_MONTH   12
  56. #define BIAS_MONTH  -1
  57.  
  58. #define MIN_DAY      1
  59. #define MAX_DAY      7
  60. #define BIAS_DAY    -1
  61.  
  62. #define MIN_MDAY     1
  63. #define MAX_MDAY    31
  64. #define BIAS_MDAY    0
  65.  
  66. #define MIN_HOUR     0
  67. #define MAX_HOUR    23
  68. #define BIAS_HOUR    0
  69.  
  70. #define MIN_MINUTE   0
  71. #define MAX_MINUTE  59
  72. #define BIAS_MINUTE  0
  73.  
  74. #define MIN_SECOND   0
  75. #define MAX_SECOND  59
  76. #define BIAS_SECOND  0
  77.  
  78. #define MIN_HSEC     0
  79. #define MAX_HSEC    99
  80. #define BIAS_HSEC    0
  81. typedef struct {
  82.     unsigned char data[8];
  83. } CLOCK_DATA;
  84. /*
  85.  * the following macros convert from BCD to binary and back.
  86.  * Be careful that the arguments are chars, and watch for overflows.
  87.  */
  88. #define BCD_TO_BIN(bcd) ( ((((bcd)&0xf0)>>4)*10) + ((bcd)&0xf) )
  89. #define BIN_TO_BCD(bin) ( (((bin)/10)<<4) + ((bin)%10) )
  90. #define FRAC_SECS 0
  91. #define SECS 1
  92. #define MINS 2
  93. #define HOURS 3
  94. #define DAYS 4
  95. #define DATE 5
  96. #define MONTH 6
  97. #define YEAR 7
  98. #ifdef __cplusplus
  99. }
  100. #endif /* __cplusplus */
  101. #endif /* __INCds1244yh */