hw_init.c 2.3 KB

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