rtc.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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) 2023 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_METER_POLLING 17
  51. #ifdef FUNC_OUTP_TYPE_E
  52. #define TIMER_IDX_SE_RELAY_1 18
  53. #else
  54. #define TIMER_IDX_18 18
  55. #endif //FUNC_OUTP_TYPE_E
  56. #ifdef FUNC_GUN_LOCK
  57. #define TIMER_IDX_GUN_LOCK 19
  58. #else
  59. #define TIMER_IDX_19 19
  60. #endif //FUNC_GUN_LOCK
  61. #ifdef FUNC_AX32_TRIG_LEAKAGE
  62. #define TIMER_IDX_TRIG_LEAKAGE 20
  63. #endif
  64. #ifdef RECODE_FUNC_METER_IC_TASK
  65. #define TIMER_IDX_METER_IC_POLLING 21
  66. #endif
  67. #ifdef FUNC_AX80_ADD_TILT_SENSOR
  68. #define TIMER_IDX_TILT_TRIG_LEAKAGE 22
  69. #endif
  70. #ifdef FUNC_ADD_AC_DC_LEAK_TIMER
  71. #define TIMER_IDX_RETRY_LEAK_AC 23
  72. #define TIMER_IDX_RETRY_LEAK_DC 24
  73. #endif
  74. #define TIMER_COUNT 25
  75. //---------------------------------------------------------------
  76. #ifdef FUNC_AW48_NET_LED
  77. #define BLINKER_COUNT 3
  78. #define BLINKER_IDX_LED 0
  79. #define BLINKER_IDX_SPEAKER 1
  80. #define BLINKER_IDX_LED_NET 2
  81. #else //FUNC_AW48_NET_LED
  82. #define BLINKER_COUNT 2
  83. #define BLINKER_IDX_LED 0
  84. #define BLINKER_IDX_SPEAKER 1
  85. #endif //FUNC_AW48_NET_LED
  86. #define FLICKER_COUNT 2
  87. #define FLICKER_IDX_BREATHE 0
  88. #define FLICKER_IDX_1 1
  89. #define BREATHE_LED_LOW_BOUNDARY 100 //Noode 200 , BYton and standard 100
  90. //---------------------------------------------------------------
  91. /* USER CODE END Private defines */
  92. void MX_RTC_Init(void);
  93. /* USER CODE BEGIN Prototypes */
  94. extern void timerEnable(uint8_t tmrIdx, uint32_t timeoutSpec);
  95. extern void timerDisable(uint8_t tmrIdx);
  96. extern void timerRefresh(uint8_t tmrIdx);
  97. extern void blinkerTimeSet(uint8_t idx, uint16_t on, uint16_t off, uint16_t rest, uint8_t count);
  98. extern void flickerTimeSet(uint8_t idx, uint16_t on, uint16_t off);
  99. 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);
  100. extern void disblinkerTime (uint8_t idx) ;
  101. extern void LedOnRGBSet(uint16_t R_color, uint16_t G_color, uint16_t B_color, uint16_t W_color);
  102. extern RTC_DateTypeDef currentDate;
  103. extern RTC_TimeTypeDef currentTime;
  104. extern RTC_DateTypeDef setDate;
  105. extern RTC_TimeTypeDef setTime;
  106. extern struct TIMER
  107. {
  108. uint64_t timeoutSpec; // Timer timeout specification
  109. uint64_t startTime; // Timetick in 1ms
  110. uint8_t isEnable:1; // Timer is enable flag
  111. uint8_t isAlarm:1; // Timer is alarm flag
  112. }timer[TIMER_COUNT];
  113. extern struct BLINK_TIMER
  114. {
  115. uint16_t blinkOnSpec;
  116. uint16_t blinkOffSpec;
  117. uint16_t blinkRestSpec;
  118. uint8_t blinkCountSpec;
  119. uint32_t blinkStartTime;
  120. uint32_t resetStartTime;
  121. uint8_t blinkCount;
  122. uint8_t isOn:1;
  123. uint8_t blinkisFinish:1;
  124. }blinker[BLINKER_COUNT];
  125. extern struct BREATHE_TIMER
  126. {
  127. uint16_t duty[4];
  128. uint16_t RGB[4];
  129. uint8_t isUp;
  130. uint16_t timeUp;
  131. uint16_t countUp;
  132. uint16_t timeDown;
  133. uint16_t countDown;
  134. uint16_t countPause;
  135. }breathe;
  136. extern struct FLICKER_TIMER
  137. {
  138. uint16_t OnSpec;
  139. uint16_t OffSpec;
  140. uint32_t StartTime;
  141. uint8_t isOn;
  142. }flicker[FLICKER_COUNT];
  143. /* USER CODE END Prototypes */
  144. #ifdef __cplusplus
  145. }
  146. #endif
  147. #endif /*__ rtc_H */
  148. /**
  149. * @}
  150. */
  151. /**
  152. * @}
  153. */
  154. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/