rx8025t.h 5.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright 2021 IOsetting <iosetting(at)outlook.com>
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef __FW_RX8025T_H__
  15. #define __FW_RX8025T_H__
  16. #include "fw_hal.h"
  17. #define RX8025T_I2C_ADDR 0x64
  18. /**
  19. * REGISTER TABLE
  20. *
  21. * * RX-8025T is different from RX-8025 SA/NB
  22. */
  23. #define RX8025T_REG_SECOND 0x00 // BCD value 00 -> 59
  24. #define RX8025T_REG_MINUTE 0x01 // BCD value 00 -> 59
  25. #define RX8025T_REG_HOUR 0x02 // BCD value 00 -> 23
  26. #define RX8025T_REG_WEEKDAY 0x03 // bit 0->6: sunday->saturday
  27. #define RX8025T_REG_DAY 0x04 // BCD value 01 -> 31
  28. #define RX8025T_REG_MONTH 0x05 // BCD value 01 -> 12
  29. #define RX8025T_REG_YEAR 0x06 // BCD value 00 -> 99
  30. #define RX8025T_REG_RAM 0x07 // R/W accessible for any data in the range from 00 h to FF h
  31. #define RX8025T_REG_ALARM_MIN 0x08 // BCD value 00 -> 59
  32. #define RX8025T_REG_ALARM_HOUR 0x09 // BCD value 00 -> 23
  33. #define RX8025T_REG_ALARM_W_OR_D 0x0A // WEEK: bit 0->6: sunday->saturday
  34. // DAY: BCD value
  35. #define RX8025T_REG_TIMER_COUNTER0 0x0B // Fixed-cycle timer control registers to set the preset countdown value
  36. // for the fixed-cycle timer interrupt. (COUNTER1, COUNTER0) = 12bit number
  37. #define RX8025T_REG_TIMER_COUNTER1 0x0C // When control register changes from 001h to 000h, the /INT pin goes to
  38. // low level and "1" is set to the TF.
  39. #define RX8025T_REG_EXTEN 0x0D
  40. #define RX8025T_EXTEN_TEST 0x80 // TEST bit. value should always be "0"
  41. #define RX8025T_EXTEN_WADA 0x40 // Week Alarm/Day Alarm bit. R/W to specify either WEEK or DAY
  42. // as the target of the alarm interrupt function. 0:WEEK, 1:DAY
  43. #define RX8025T_EXTEN_USEL 0x20 // Update Interrupt Select bit. R/W specify either "second"
  44. // or "minute" as update interrupt, 0:second update, 1:minute update
  45. #define RX8025T_EXTEN_TE 0x10 // Timer Enable bit. controls the start/stop setting for the fixed-cycle
  46. // timer interrupt function. 1:start, 0:stop
  47. #define RX8025T_EXTEN_FSEL1 0x08 // FOUT frequency Select bits to set the FOUT frequency. (FSEL1, FSEL0)
  48. #define RX8025T_EXTEN_FSEL0 0x04 // 0,0:32.768KHz, 0,1:1024Hz, 1,0:1Hz, 1,1:32.768KHz
  49. #define RX8025T_EXTEN_TSEL1 0x02 // Timer Select bits to set the countdown period (source clock) for the
  50. // fixed-cycle timer interrupt (TSEL1, TSEL0)
  51. #define RX8025T_EXTEN_TSEL0 0x01 // 0,0:4096Hz, 0,1:64Hz, 1,0:1Hz(per second), 1,1:1/60Hz(per minute)
  52. #define RX8025T_REG_FLAG 0x0E
  53. #define RX8025T_FLAG_UF 0x20 // Update Flag. 0 -> 1 when a time update interrupt event has
  54. // occurred. 1 is retained until a 0 is written
  55. #define RX8025T_FLAG_TF 0x10 // Timer Flag. 0 -> 1 when a fixed-cycle timer interrupt
  56. // event has occurred, 1 is retained until a 0 is written
  57. #define RX8025T_FLAG_AF 0x08 // Alarm Flag. 0 -> 1 when an alarm interrupt event has occurred
  58. // 1 is retained until a 0 is written
  59. #define RX8025T_FLAG_VLF 0x02 // Voltage Low Flag. 0 -> 1 when data loss occurs, e.g. a supply
  60. // voltage drop,
  61. #define RX8025T_FLAG_VDET 0x01 // Voltage Detection Flag. 0 -> 1 when stop the temperature compensation
  62. // such as due to a supply voltage drop, 1 is retained until a 0 is written
  63. #define RX8025T_REG_CONTROL 0x0F
  64. #define RX8025T_CONTR_CSEL1 0x80 // Compensation interval (CSEL1, CSEL0)
  65. #define RX8025T_CONTR_CSEL0 0x40 // 0,0:0.5s, 0,1:2s(default), 1,0:10s, 1,1:30s
  66. #define RX8025T_CONTR_UIE 0x20 // Update Interrupt Enable, 0:off, 1:on
  67. #define RX8025T_CONTR_TIE 0x10 // Timer Interrupt Enable
  68. #define RX8025T_CONTR_AIE 0x08 // Alarm Interrupt Enable
  69. #define RX8025T_CONTR_RESET 0x01 // Writing a "1" to this bit stops the counter operation and
  70. // resets the RTC module's internal counter value when the
  71. // value is less than one second.
  72. uint8_t RX8025T_Init(void);
  73. uint8_t RX8025T_GetTime(uint8_t* t);
  74. uint8_t RX8025T_SetTime(uint8_t* t);
  75. #endif