hpw422移植新的sdk

This commit is contained in:
xushaoxiang
2026-07-03 18:08:25 +08:00
commit 945a5a5b0b
2583 changed files with 713209 additions and 0 deletions
@@ -0,0 +1,78 @@
/*!
* \file fatfs.c
*
* \brief Target FatFS implementation
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
*
* _ __ _ ________ _
* | |/ /(_)___ / ____/ /_ (_)___
* | // / __ \/ / / __ \/ / __ \
* / |/ / / / / /___/ / / / / /_/ /
* /_/|_/_/_/ /_/\____/_/ /_/_/ .___/
* /_/
* (C) 2022-2025 XinChip
*
* \endcode
*
* \author ( XinChip ) Alex-J
*
* \author ( XinChip )
*/
/*-----------------------------------------------------------------------------------
INCLUDE HEADE FILES
------------------------------------------------------------------------------------*/
#include "fatfs.h"
#include "xc6xxx.h"
/*------------------------------------------------------------------------------------
Local Variables
-------------------------------------------------------------------------------------*/
char Path[4]; /* Logical drive path */
FATFS FatFS; /* File system object for Logical drive */
FIL File; /* File object */
DIR Dir;
uint8_t buffer[_MAX_SS];
/*------------------------------------------------------------------------------------
Functions
------------------------------------------------------------------------------------*/
/**
* @brief FatFS Initalization
* @param void
* @retval void
*/
void FATFS_Init(void)
{
FRESULT res;
DEBUG("FatFS Init\r\n");
res = f_mount(&FatFS, "0:", 1);
DEBUG("Mount FRESULT: %d\r\n", res);
res = f_opendir(&Dir, "0:");
DEBUG("Read Dir: %d\r\n", res);
if (FR_NO_FILESYSTEM == res) {
res = f_mkfs("0:", FM_FAT, _MAX_SS, buffer, sizeof(buffer));
DEBUG("Format FRESULT: %d\r\n", res);
res = f_unmount("0:");
DEBUG("Umount FRESULT: %d\r\n", res);
// res = f_setlabel( "XinChip" );
// DEBUG("Set label: %d\r\n", res);
res = f_mount(&FatFS, "0:", 1);
DEBUG("Remount FRESULT: %d\r\n", res);
res = f_unmount("0:");
DEBUG("Umount FRESULT: %d\r\n", res);
} else {
res = f_unmount("0:");
DEBUG("Umount FRESULT: %d\r\n", res);
}
}