hw_init.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 "hw_init.h"
  14. #include "wdg.h"
  15. #include "usart.h"
  16. #include "settings_api.h"
  17. #include "bt_6701_settings.h"
  18. #include "buttons.h"
  19. #include "commands_api.h"
  20. #include "led.h"
  21. #include "rtc.h"
  22. #include "gpio.h"
  23. #include "spi_flash.h"
  24. #include "stm32_uid.h"
  25. #include "port_microrl.h"
  26. #include "FreeRTOS.h"
  27. #include "task.h"
  28. #ifdef PRINTF_STDLIB
  29. #include <stdio.h>
  30. #endif
  31. #ifdef PRINTF_CUSTOM
  32. #include "tinystdio.h"
  33. #endif
  34. char STM_ID[33];
  35. char STM_ID_HEX[12];
  36. void service_com_task(void* params)
  37. {
  38. int c;
  39. for(;;){
  40. c = service_getchar(portMAX_DELAY);
  41. if(c >= 0)
  42. {
  43. MICRORL_GetChar((uint8_t)c);
  44. }
  45. }
  46. }
  47. uint32_t time_test =0;
  48. /**
  49. * @brief Инициализация необходимых модулей
  50. */
  51. void BT_6702_Init(void)
  52. {
  53. uint8_t len;
  54. gpio_init();
  55. WDG_Init();
  56. spi_flash_init();
  57. InitUSART();
  58. MICRORL_Init();
  59. init_settings();
  60. SETTINGS_Load();
  61. Service_SETTINGS_SetWebParamsDef();
  62. Service_SETTINGS_SetTempWebParamsDef();
  63. SETTINGS_Save();
  64. COM_ReadTestState();
  65. memset(STM_ID, 0, 33);
  66. GetSTM32IDStr(STM_ID, &len); // Уникальный ID чипа
  67. GetSTM32IDInt(STM_ID_HEX);
  68. BUTTON_Init(); // Кнопки
  69. LED_Init();
  70. TM_RTC_Init(TM_RTC_ClockSource_External);
  71. time_test = RTC_GetUnixTime();
  72. xTaskCreate(service_com_task, ( char * ) "service_com_task", configMINIMAL_STACK_SIZE * 2, NULL, tskIDLE_PRIORITY, NULL);
  73. // Создает таски для выполнения команд тестера
  74. xTaskCreate(vTestCommands, "TestProcessing", 2*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);
  75. printf("Hello world\r\n");
  76. }
  77. /********************************* (C) РОТЕК **********************************/