Subversion Repositories pentevo

Rev

Rev 100 | Rev 129 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef __RTC_H__
  2. #define __RTC_H__
  3. /**
  4.  * @file
  5.  * @brief RTC support.
  6.  * @author http://www.nedopc.com
  7.  *
  8.  * RTC PCF8583 support for ZX Evolution.
  9.  *
  10.  * ZX Evolution emulate Gluk clock standard:
  11.  * - full read/write time emulate;
  12.  * - full read/write nvram emulate;
  13.  * - registers A,B,C,D read only;
  14.  * - alarm functions not emulated.
  15.  */
  16.  
  17. /** Address of PCF8583 RTC chip.*/
  18. #define RTC_ADDRESS  0xA0
  19.  
  20. /** Register for year additional data. */
  21. #define RTC_YEAR_ADD_REG  0xFF
  22.  
  23. /** Init RTC.*/
  24. void rtc_init(void);
  25.  
  26. /**
  27.  * Write byte to RTC.
  28.  * @param addr [in] - address of internal register on RTC
  29.  * @param data [in] - data to write
  30.  */
  31. void rtc_write(UBYTE addr, UBYTE data);
  32.  
  33. /**
  34.  * Read byte from RTC.
  35.  * @return data
  36.  * @param addr [in] - address of internal register on RTC
  37.  */
  38. UBYTE rtc_read(UBYTE addr);
  39.  
  40.  
  41. /** Seconds register index. */
  42. #define GLUK_REG_SEC        0x00
  43. /** Seconds alarm register index. */
  44. #define GLUK_REG_SEC_ALARM  0x01
  45. /** Minutes register index. */
  46. #define GLUK_REG_MIN        0x02
  47. /** Minutes alarm register index. */
  48. #define GLUK_REG_MIN_ALARM  0x03
  49. /** Hours register index. */
  50. #define GLUK_REG_HOUR       0x04
  51. /** Hours alarm register index. */
  52. #define GLUK_REG_HOUR_ALARM 0x05
  53. /** Day of week register index. */
  54. #define GLUK_REG_DAY_WEEK   0x06
  55. /** Day of month register index. */
  56. #define GLUK_REG_DAY_MONTH  0x07
  57. /** Month register index. */
  58. #define GLUK_REG_MONTH      0x08
  59. /** Year register index. */
  60. #define GLUK_REG_YEAR       0x09
  61. /** A register index. */
  62. #define GLUK_REG_A          0x0A
  63. /** B register index. */
  64. #define GLUK_REG_B          0x0B
  65. /** C register index. */
  66. #define GLUK_REG_C          0x0C
  67. /** D register index. */
  68. #define GLUK_REG_D          0x0D
  69.  
  70. /** B register 2 bit - data mode (A 1 in DM signifies binary data while a 0 in DM specifies BCD data). */
  71. #define GLUK_B_DATA_MODE    0x04
  72. /** B register 1 bit - 24/12 mode (A 1 indicates the 24-hour mode and a 0 indicates the 12-hour mode.). */
  73. #define GLUK_B_24_12_MODE   0x02
  74.  
  75. /** Read values from RTC and setup Gluk clock registers. */
  76. void gluk_init(void);
  77.  
  78. /** Increment Gluk clock registers on one second. */
  79. void gluk_inc(void);
  80.  
  81. /**
  82.  * Get Gluk clock registers data.
  83.  * @return registers data
  84.  * @param index [in] - index of Gluck clock register
  85.  */
  86. UBYTE gluk_get_reg(UBYTE index);
  87.  
  88. /**
  89.  * Set Gluk clock registers data.
  90.  * @param index [in] - index of Gluck clock register
  91.  * @param data [in] - data
  92.  */
  93. void gluk_set_reg(UBYTE index, UBYTE data);
  94.  
  95.  
  96. #endif //__RTC_H__
  97.