main.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. es_event_t event = eventNull;
  45. RTC_ReadAll(&Clock);
  46. showTime();
  47. /** Set tasks for Sheduler */
  48. RTOS_SetTask(btnProcess, 1, BTN_SCAN_PERIOD);
  49. /* Infinite loop */
  50. while (1)
  51. {
  52. /* new second interrupt from RTC */
  53. if (Flag.RTC_IRQ != 0) {
  54. Flag.RTC_IRQ = 0;
  55. new_Second();
  56. } /* end of New second */
  57. event = ES_GetEvent();
  58. if (event) {
  59. ES_Dispatch(event);
  60. }
  61. RTOS_DispatchTask();
  62. __WFI();
  63. }
  64. } /* End of mine() */
  65. /**
  66. * @brief This function is executed in case of error occurrence.
  67. * @retval None
  68. */
  69. void Error_Handler(void)
  70. {
  71. /* User can add his own implementation to report the HAL error return state */
  72. __disable_irq();
  73. while (1)
  74. {
  75. }
  76. }
  77. #ifdef USE_FULL_ASSERT
  78. /**
  79. * @brief Reports the name of the source file and the source line number
  80. * where the assert_param error has occurred.
  81. * @param file: pointer to the source file name
  82. * @param line: assert_param error line source number
  83. * @retval None
  84. */
  85. void assert_failed(uint8_t *file, uint32_t line)
  86. {
  87. /* User can add his own implementation to report the file name and line number,
  88. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  89. }
  90. #endif /* USE_FULL_ASSERT */
  91. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/