main.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. /* Initialize Event State Machine */
  56. ES_Init(stShowTime);
  57. /* Init devices at I2C bus */
  58. // RTC_Init();
  59. // tdelay_ms(10);
  60. RTC_Init();
  61. sensor_Init();
  62. es_event_t event = eventNull;
  63. RTC_ReadAll(&Clock);
  64. showTime();
  65. /** Set tasks for Sheduler */
  66. RTOS_SetTask(btnProcess, 1, BTN_SCAN_PERIOD);
  67. /* USER CODE BEGIN WHILE */
  68. /* Infinite loop */
  69. while (1)
  70. {
  71. /* new second interrupt from RTC */
  72. if (Flag.RTC_IRQ != 0) {
  73. Flag.RTC_IRQ = 0;
  74. new_Second();
  75. } /* end of New second */
  76. /* USER CODE END WHILE */
  77. /* USER CODE BEGIN 3 */
  78. event = ES_GetEvent();
  79. if (event) {
  80. ES_Dispatch(event);
  81. }
  82. RTOS_DispatchTask();
  83. __WFI();
  84. }
  85. /* USER CODE END 3 */
  86. } /* End of mine() */
  87. /* USER CODE BEGIN 4 */
  88. /* USER CODE END 4 */
  89. /**
  90. * @brief This function is executed in case of error occurrence.
  91. * @retval None
  92. */
  93. void Error_Handler(void)
  94. {
  95. /* USER CODE BEGIN Error_Handler_Debug */
  96. /* User can add his own implementation to report the HAL error return state */
  97. __disable_irq();
  98. while (1)
  99. {
  100. }
  101. /* USER CODE END Error_Handler_Debug */
  102. }
  103. #ifdef USE_FULL_ASSERT
  104. /**
  105. * @brief Reports the name of the source file and the source line number
  106. * where the assert_param error has occurred.
  107. * @param file: pointer to the source file name
  108. * @param line: assert_param error line source number
  109. * @retval None
  110. */
  111. void assert_failed(uint8_t *file, uint32_t line)
  112. {
  113. /* USER CODE BEGIN 6 */
  114. /* User can add his own implementation to report the file name and line number,
  115. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  116. /* USER CODE END 6 */
  117. }
  118. #endif /* USE_FULL_ASSERT */
  119. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/