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.
|
|
/* USER CODE BEGIN Header */ /**
****************************************************************************** * @file fatfs.c * @brief Code for fatfs applications ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ #include "fatfs.h"
uint8_t retUSBH; /* Return value for USBH */ char USBHPath[4]; /* USBH logical drive path */ FATFS USBHFatFS; /* File system object for USBH logical drive */ FIL USBHFile; /* File object for USBH */
/* USER CODE BEGIN Variables */
/* USER CODE END Variables */
void MX_FATFS_Init(void) { /*## FatFS: Link the USBH driver ###########################*/ retUSBH = FATFS_LinkDriver(&USBH_Driver, USBHPath);
/* USER CODE BEGIN Init */ /* additional user code for init */ /* USER CODE END Init */ }
/**
* @brief Gets Time from RTC * @param None * @retval Time in DWORD */ extern RTC_HandleTypeDef hrtc;
DWORD get_fattime(void) { /* USER CODE BEGIN get_fattime */
DWORD u16_dateTime; uint16_t date_time[6] = {2024, 5, 20, 01, 20, 10};
RTC_DateTypeDef GetData; RTC_TimeTypeDef GetTime; HAL_RTC_GetTime(&hrtc, &GetTime, RTC_FORMAT_BIN); HAL_RTC_GetDate(&hrtc, &GetData, RTC_FORMAT_BIN);
date_time[0] = 1900 + GetData.Year; date_time[1] = GetData.Month; date_time[2] = GetData.Date; date_time[3] = GetTime.Hours; date_time[4] = GetTime.Minutes; date_time[5] = GetTime.Seconds;
u16_dateTime = date_time[0] - 1980; u16_dateTime = u16_dateTime << 25; u16_dateTime |= date_time[1] << 21; u16_dateTime |= date_time[2] << 16; u16_dateTime |= date_time[3] << 11; u16_dateTime |= date_time[4] << 5; u16_dateTime |= date_time[5];
return u16_dateTime;
/* USER CODE END get_fattime */ }
/* USER CODE BEGIN Application */
/* USER CODE END Application */
|