hw_init.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /********************************* (C) РОТЕК ***********************************
  2. * @module hw_init
  3. * @file hw_init.c
  4. * @version 1.0.0
  5. * @date XX.XX.XXXX
  6. * $brief hw_init
  7. *******************************************************************************
  8. * @history Version Author Comment
  9. * XX.XX.XXXX 1.0.0 Telenkov D.A. First release.
  10. *******************************************************************************
  11. */
  12. #include "stm32f4xx.h"
  13. #include "common_config.h"
  14. #include "hw_init.h"
  15. #include "wdg.h"
  16. #include "usart.h"
  17. #include "settings_api.h"
  18. #include "bt_6701_settings.h"
  19. #include "buttons.h"
  20. #include "commands_api.h"
  21. #include "led.h"
  22. #include "rtc.h"
  23. #include "gpio.h"
  24. #include "spi_flash.h"
  25. #include "stm32_uid.h"
  26. #include "port_microrl.h"
  27. #ifdef RS485_USART
  28. #include "rs485_echo.h"
  29. #endif
  30. #include "FreeRTOS.h"
  31. #include "task.h"
  32. #ifdef PRINTF_STDLIB
  33. #include <stdio.h>
  34. #endif
  35. #ifdef PRINTF_CUSTOM
  36. #include "tinystdio.h"
  37. #endif
  38. char STM_ID[33];
  39. char STM_ID_HEX[12];
  40. void service_com_task(void* params)
  41. {
  42. int c;
  43. for(;;){
  44. c = service_getchar(portMAX_DELAY);
  45. if(c >= 0)
  46. {
  47. MICRORL_GetChar((uint8_t)c);
  48. }
  49. }
  50. }
  51. uint32_t time_test =0;
  52. /**
  53. * @brief Инициализация необходимых модулей
  54. */
  55. void BT_6702_Init(void)
  56. {
  57. uint8_t len;
  58. gpio_init();
  59. WDG_Init();
  60. spi_flash_init();
  61. InitUSART();
  62. MICRORL_Init();
  63. init_settings();
  64. SETTINGS_Load();
  65. Service_SETTINGS_SetWebParamsDef();
  66. Service_SETTINGS_SetTempWebParamsDef();
  67. SETTINGS_Save();
  68. COM_ReadTestState();
  69. memset(STM_ID, 0, 33);
  70. GetSTM32IDStr(STM_ID, &len); // Уникальный ID чипа
  71. GetSTM32IDInt(STM_ID_HEX);
  72. BUTTON_Init(); // Кнопки
  73. LED_Init();
  74. TM_RTC_Init(TM_RTC_ClockSource_External);
  75. time_test = RTC_GetUnixTime();
  76. #ifdef RS485_USART
  77. /* RS485 echo loop */
  78. rs485echo_init();
  79. #endif
  80. xTaskCreate(service_com_task, ( char * ) "service_com_task", configMINIMAL_STACK_SIZE * 2, NULL, tskIDLE_PRIORITY, NULL);
  81. // Создает таски для выполнения команд тестера
  82. xTaskCreate(vTestCommands, "TestProcessing", 2*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
  83. printf("Hello world\r\n");
  84. }
  85. /********************************* (C) РОТЕК **********************************/