main.c 3.0 KB

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