rtc.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /**
  2. ******************************************************************************
  3. * File Name : RTC.h
  4. * Description : This file provides code for the configuration
  5. * of the RTC instances.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under Ultimate Liberty license
  13. * SLA0044, the "License"; You may not use this file except in compliance with
  14. * the License. You may obtain a copy of the License at:
  15. * www.st.com/SLA0044
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __rtc_H
  21. #define __rtc_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "main.h"
  27. /* USER CODE BEGIN Includes */
  28. #include "time.h"
  29. /* USER CODE END Includes */
  30. extern RTC_HandleTypeDef hrtc;
  31. /* USER CODE BEGIN Private defines */
  32. //---------------------------------------------------------------
  33. #define TIMER_IDX_CP 0
  34. #define TIMER_IDX_POWER 1
  35. #define TIMER_IDX_BLE 2
  36. #define TIMER_IDX_SPEAKER 3
  37. #define TIMER_IDX_RTOS_STAT 4
  38. #define TIMER_IDX_RETRY_OC 5
  39. #define TIMER_IDX_RETRY_LEAK 6
  40. #define TIMER_IDX_RETRY_OT 7
  41. #define TIMER_IDX_DEBUG 8
  42. #define TIMER_IDX_STATE_E 9
  43. #define TIMER_IDX_LED_TEMP 10
  44. #define TIMER_IDX_RFID_RELAY_OFF 11
  45. #define TIMER_IDX_RELAY_1 12
  46. #define TIMER_IDX_RELAY_2 13
  47. #define TIMER_IDX_PE_DETECT 14
  48. #define TIMER_IDX_WIFI 15
  49. #define TIMER_IDX_UPDATE 16
  50. #define TIMER_IDX_SIMU_DISCONNECT 17
  51. #ifdef FUNC_ADD_AC_DC_LEAK_TIMER
  52. #define TIMER_IDX_RETRY_LEAK_AC 18
  53. #define TIMER_IDX_RETRY_LEAK_DC 19
  54. #endif
  55. #define TIMER_COUNT 20
  56. //---------------------------------------------------------------
  57. #define BLINKER_COUNT 2
  58. #define BLINKER_IDX_LED 0
  59. #define BLINKER_IDX_SPEAKER 1
  60. #define FLICKER_COUNT 2
  61. #define FLICKER_IDX_BREATHE 0
  62. #define FLICKER_IDX_1 1
  63. #define BREATHE_LED_LOW_BOUNDARY 100 //Noode 200 , BYton and standard 100
  64. //---------------------------------------------------------------
  65. /* USER CODE END Private defines */
  66. void MX_RTC_Init(void);
  67. /* USER CODE BEGIN Prototypes */
  68. extern void timerEnable(uint8_t tmrIdx, uint32_t timeoutSpec);
  69. extern void timerDisable(uint8_t tmrIdx);
  70. extern void timerRefresh(uint8_t tmrIdx);
  71. extern void blinkerTimeSet(uint8_t idx, uint16_t on, uint16_t off, uint16_t rest, uint8_t count);
  72. extern void flickerTimeSet(uint8_t idx, uint16_t on, uint16_t off);
  73. extern void breatheTimeSet(uint16_t up, uint16_t down, uint16_t R_color, uint16_t G_color, uint16_t B_color, uint16_t W_color);
  74. extern void disblinkerTime (uint8_t idx) ;
  75. extern void LedOnRGBSet(uint16_t R_color, uint16_t G_color, uint16_t B_color, uint16_t W_color);
  76. extern uint32_t timerGetTimePass(uint8_t tmrIdx) ;
  77. extern RTC_DateTypeDef currentDate;
  78. extern RTC_TimeTypeDef currentTime;
  79. extern RTC_DateTypeDef setDate;
  80. extern RTC_TimeTypeDef setTime;
  81. extern struct TIMER
  82. {
  83. uint64_t timeoutSpec; // Timer timeout specification
  84. uint64_t startTime; // Timetick in 1ms
  85. uint8_t isEnable:1; // Timer is enable flag
  86. uint8_t isAlarm:1; // Timer is alarm flag
  87. }timer[TIMER_COUNT];
  88. extern struct BLINK_TIMER
  89. {
  90. uint16_t blinkOnSpec;
  91. uint16_t blinkOffSpec;
  92. uint16_t blinkRestSpec;
  93. uint8_t blinkCountSpec;
  94. uint32_t blinkStartTime;
  95. uint32_t resetStartTime;
  96. uint8_t blinkCount;
  97. uint8_t isOn:1;
  98. uint8_t blinkisFinish:1;
  99. }blinker[BLINKER_COUNT];
  100. extern struct BREATHE_TIMER
  101. {
  102. uint16_t duty[4];
  103. uint16_t RGB[4];
  104. uint8_t isUp;
  105. uint16_t timeUp;
  106. uint16_t countUp;
  107. uint16_t timeDown;
  108. uint16_t countDown;
  109. uint16_t countPause;
  110. }breathe;
  111. extern struct FLICKER_TIMER
  112. {
  113. uint16_t OnSpec;
  114. uint16_t OffSpec;
  115. uint32_t StartTime;
  116. uint8_t isOn;
  117. }flicker[FLICKER_COUNT];
  118. /* USER CODE END Prototypes */
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif /*__ rtc_H */
  123. /**
  124. * @}
  125. */
  126. /**
  127. * @}
  128. */
  129. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/