main.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "main.h"
  22. /* Private includes ----------------------------------------------------------*/
  23. /* USER CODE BEGIN Includes */
  24. /* USER CODE END Includes */
  25. /* Private typedef -----------------------------------------------------------*/
  26. /* USER CODE BEGIN PTD */
  27. /* USER CODE END PTD */
  28. /* Private define ------------------------------------------------------------*/
  29. /* USER CODE BEGIN PD */
  30. /* USER CODE END PD */
  31. /* Private macro -------------------------------------------------------------*/
  32. /* USER CODE BEGIN PM */
  33. /* USER CODE END PM */
  34. /* Private variables ---------------------------------------------------------*/
  35. /* USER CODE BEGIN PV */
  36. volatile flag_t Flag = {0};
  37. /* USER CODE END PV */
  38. /* Private function prototypes -----------------------------------------------*/
  39. /* USER CODE BEGIN PFP */
  40. /* USER CODE END PFP */
  41. /* Private user code ---------------------------------------------------------*/
  42. /* USER CODE BEGIN 0 */
  43. /* USER CODE END 0 */
  44. /**
  45. * @brief The application entry point.
  46. * @retval int
  47. */
  48. int main(void)
  49. {
  50. /* Initialize onBoard Hardware */
  51. Board_Init();
  52. /* Initialize Scheduler */
  53. RTOS_Init();
  54. /* tdelay_ms() work now, I2C can work too */
  55. RTC_Init();
  56. RTC_ReadAll(&Clock);
  57. sensor_Init();
  58. /* Initialize Event State Machine */
  59. ES_Init(stShowTime);
  60. showTime();
  61. es_event_t event = eventNull;
  62. /** Set tasks for Sheduler */
  63. RTOS_SetTask(btnProcess, 1, BTN_SCAN_PERIOD);
  64. /* USER CODE BEGIN WHILE */
  65. /* Infinite loop */
  66. while (1)
  67. {
  68. /* new second interrupt from RTC */
  69. if (Flag.RTC_IRQ != 0) {
  70. Flag.RTC_IRQ = 0;
  71. new_Second();
  72. } /* end of New second */
  73. /* USER CODE END WHILE */
  74. /* USER CODE BEGIN 3 */
  75. event = ES_GetEvent();
  76. if (event) {
  77. ES_Dispatch(event);
  78. }
  79. RTOS_DispatchTask();
  80. __WFI();
  81. }
  82. /* USER CODE END 3 */
  83. } /* End of mine() */
  84. /* USER CODE BEGIN 4 */
  85. /* USER CODE END 4 */
  86. /**
  87. * @brief This function is executed in case of error occurrence.
  88. * @retval None
  89. */
  90. void Error_Handler(void)
  91. {
  92. /* USER CODE BEGIN Error_Handler_Debug */
  93. /* User can add his own implementation to report the HAL error return state */
  94. __disable_irq();
  95. while (1)
  96. {
  97. }
  98. /* USER CODE END Error_Handler_Debug */
  99. }
  100. #ifdef USE_FULL_ASSERT
  101. /**
  102. * @brief Reports the name of the source file and the source line number
  103. * where the assert_param error has occurred.
  104. * @param file: pointer to the source file name
  105. * @param line: assert_param error line source number
  106. * @retval None
  107. */
  108. void assert_failed(uint8_t *file, uint32_t line)
  109. {
  110. /* USER CODE BEGIN 6 */
  111. /* User can add his own implementation to report the file name and line number,
  112. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  113. /* USER CODE END 6 */
  114. }
  115. #endif /* USE_FULL_ASSERT */
  116. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/