115 lines
3.1 KiB
C
115 lines
3.1 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file app_fatfs.c
|
|
* @brief Code for fatfs applications
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* <h2><center>© Copyright (c) 2022 STMicroelectronics.
|
|
* All rights reserved.</center></h2>
|
|
*
|
|
* This software component is licensed by ST under Ultimate Liberty license
|
|
* SLA0044, the "License"; You may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at:
|
|
* www.st.com/SLA0044
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "app_fatfs.h"
|
|
#include "main.h"
|
|
|
|
/* Private includes ----------------------------------------------------------*/
|
|
/* USER CODE BEGIN Includes */
|
|
|
|
/* USER CODE END Includes */
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
/* USER CODE BEGIN PTD */
|
|
typedef enum {
|
|
APPLICATION_IDLE = 0,
|
|
APPLICATION_INIT,
|
|
APPLICATION_RUNNING,
|
|
APPLICATION_SD_UNPLUGGED,
|
|
}FS_FileOperationsTypeDef;
|
|
/* USER CODE END PTD */
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
/* USER CODE BEGIN PD */
|
|
|
|
/* USER CODE END PD */
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
/* USER CODE BEGIN PM */
|
|
|
|
/* USER CODE END PM */
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
FATFS USERFatFs; /* File system object for USER logical drive */
|
|
FIL USERFile; /* File object for USER */
|
|
char USERPath[4]; /* USER logical drive path */
|
|
/* USER CODE BEGIN PV */
|
|
FS_FileOperationsTypeDef Appli_state = APPLICATION_IDLE;
|
|
/* USER CODE END PV */
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
/* USER CODE BEGIN PFP */
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
/**
|
|
* @brief FatFs initialization
|
|
* @param None
|
|
* @retval Initialization result
|
|
*/
|
|
int32_t MX_FATFS_Init(void)
|
|
{
|
|
/*## FatFS: Link the disk I/O driver(s) ###########################*/
|
|
|
|
if (FATFS_LinkDriver(&USER_Driver, USERPath) != 0)
|
|
/* USER CODE BEGIN FATFS_Init */
|
|
{
|
|
return APP_ERROR;
|
|
}
|
|
else
|
|
{
|
|
Appli_state = APPLICATION_INIT;
|
|
return APP_OK;
|
|
}
|
|
/* USER CODE END FATFS_Init */
|
|
}
|
|
|
|
/**
|
|
* @brief FatFs application main process
|
|
* @param None
|
|
* @retval Process result
|
|
*/
|
|
int32_t MX_FATFS_Process(void)
|
|
{
|
|
/* USER CODE BEGIN FATFS_Process */
|
|
int32_t process_res = APP_OK;
|
|
|
|
return process_res;
|
|
/* USER CODE END FATFS_Process */
|
|
}
|
|
|
|
/**
|
|
* @brief Gets Time from RTC (generated when FS_NORTC==0; see ff.c)
|
|
* @param None
|
|
* @retval Time in DWORD
|
|
*/
|
|
DWORD get_fattime(void)
|
|
{
|
|
/* USER CODE BEGIN get_fattime */
|
|
return 0;
|
|
/* USER CODE END get_fattime */
|
|
}
|
|
|
|
/* Private user code ---------------------------------------------------------*/
|
|
/* USER CODE BEGIN Application */
|
|
|
|
/* USER CODE END Application */
|