hw_init.c 2.2 KB

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