Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  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.  * Save modes of ZX Evolution to RTC NVRAM.
  17.  */
  18.  
  19. /** Address of PCF8583 RTC chip.*/
  20. #define RTC_ADDRESS  0xA0
  21.  
  22. /** Register for year additional data. */
  23. #define RTC_YEAR_ADD_REG     0xFF
  24. /** Register for common modes. */
  25. #define RTC_COMMON_MODE_REG  0xFE
  26.  
  27. /** Init RTC.*/
  28. void rtc_init(void);
  29.  
  30. /**
  31.  * Write byte to RTC.
  32.  * @param addr [in] - address of internal register on RTC
  33.  * @param data [in] - data to write
  34.  */
  35. void rtc_write(UBYTE addr, UBYTE data);
  36.  
  37. /**
  38.  * Read byte from RTC.
  39.  * @return data
  40.  * @param addr [in] - address of internal register on RTC
  41.  */
  42. UBYTE rtc_read(UBYTE addr);
  43.  
  44.  
  45. /** Seconds register index. */
  46. #define GLUK_REG_SEC        0x00
  47. /** Seconds alarm register index. */
  48. #define GLUK_REG_SEC_ALARM  0x01
  49. /** Minutes register index. */
  50. #define GLUK_REG_MIN        0x02
  51. /** Minutes alarm register index. */
  52. #define GLUK_REG_MIN_ALARM  0x03
  53. /** Hours register index. */
  54. #define GLUK_REG_HOUR       0x04
  55. /** Hours alarm register index. */
  56. #define GLUK_REG_HOUR_ALARM 0x05
  57. /** Day of week register index. */
  58. #define GLUK_REG_DAY_WEEK   0x06
  59. /** Day of month register index. */
  60. #define GLUK_REG_DAY_MONTH  0x07
  61. /** Month register index. */
  62. #define GLUK_REG_MONTH      0x08
  63. /** Year register index. */
  64. #define GLUK_REG_YEAR       0x09
  65. /** A register index. */
  66. #define GLUK_REG_A          0x0A
  67. /** B register index. */
  68. #define GLUK_REG_B          0x0B
  69. /** C register index. */
  70. #define GLUK_REG_C          0x0C
  71. /** D register index. */
  72. #define GLUK_REG_D          0x0D
  73.  
  74. /** B register 2 bit - data mode (A 1 in DM signifies binary data while a 0 in DM specifies BCD data). */
  75. #define GLUK_B_DATA_MODE    0x04
  76. /** B register 1 bit - 24/12 mode (A 1 indicates the 24-hour mode and a 0 indicates the 12-hour mode). */
  77. #define GLUK_B_24_12_MODE   0x02
  78. /** C register 4 bit - Update-ended interrupt flag [UF] (Bit is set after each update cycle, UF is cleared by reading Register C or a RESET). */
  79. #define GLUK_C_UPDATE_FLAG  0x10
  80.  
  81. /** Read values from RTC and setup Gluk clock registers. */
  82. void gluk_init(void);
  83.  
  84. /** Increment Gluk clock registers on one second. */
  85. void gluk_inc(void);
  86.  
  87. /**
  88.  * Get Gluk clock registers data.
  89.  * @return registers data
  90.  * @param index [in] - index of Gluck clock register
  91.  */
  92. UBYTE gluk_get_reg(UBYTE index);
  93.  
  94. /**
  95.  * Set Gluk clock registers data.
  96.  * @param index [in] - index of Gluck clock register
  97.  * @param data [in] - data
  98.  */
  99. void gluk_set_reg(UBYTE index, UBYTE data);
  100.  
  101.  
  102. #endif //__RTC_H__
  103.