You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.1 KiB

9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
8 months ago
9 months ago
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file fatfs.c
  5. * @brief Code for fatfs applications
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2024 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* USER CODE END Header */
  19. #include "fatfs.h"
  20. uint8_t retUSBH; /* Return value for USBH */
  21. char USBHPath[4]; /* USBH logical drive path */
  22. FATFS USBHFatFS; /* File system object for USBH logical drive */
  23. FIL USBHFile; /* File object for USBH */
  24. /* USER CODE BEGIN Variables */
  25. /* USER CODE END Variables */
  26. void MX_FATFS_Init(void) {
  27. /*## FatFS: Link the USBH driver ###########################*/
  28. retUSBH = FATFS_LinkDriver(&USBH_Driver, USBHPath);
  29. /* USER CODE BEGIN Init */
  30. /* additional user code for init */
  31. /* USER CODE END Init */
  32. }
  33. /**
  34. * @brief Gets Time from RTC
  35. * @param None
  36. * @retval Time in DWORD
  37. */
  38. extern RTC_HandleTypeDef hrtc;
  39. DWORD get_fattime(void) {
  40. /* USER CODE BEGIN get_fattime */
  41. DWORD u16_dateTime;
  42. uint16_t date_time[6] = {2024, 5, 20, 01, 20, 10};
  43. RTC_DateTypeDef GetData;
  44. RTC_TimeTypeDef GetTime;
  45. HAL_RTC_GetTime(&hrtc, &GetTime, RTC_FORMAT_BIN);
  46. HAL_RTC_GetDate(&hrtc, &GetData, RTC_FORMAT_BIN);
  47. date_time[0] = 1900 + GetData.Year;
  48. date_time[1] = GetData.Month;
  49. date_time[2] = GetData.Date;
  50. date_time[3] = GetTime.Hours;
  51. date_time[4] = GetTime.Minutes;
  52. date_time[5] = GetTime.Seconds;
  53. u16_dateTime = date_time[0] - 1980;
  54. u16_dateTime = u16_dateTime << 25;
  55. u16_dateTime |= date_time[1] << 21;
  56. u16_dateTime |= date_time[2] << 16;
  57. u16_dateTime |= date_time[3] << 11;
  58. u16_dateTime |= date_time[4] << 5;
  59. u16_dateTime |= date_time[5];
  60. return u16_dateTime;
  61. /* USER CODE END get_fattime */
  62. }
  63. /* USER CODE BEGIN Application */
  64. /* USER CODE END Application */