update version to v2.1.0

This commit is contained in:
Artery-MCU
2023-08-08 19:30:55 +08:00
parent d7bcb64bf8
commit f49a554036
408 changed files with 224076 additions and 1271 deletions

View File

@@ -16,4 +16,4 @@
- sdio1_d3 pc11 ---> dat3
- sdio1_ck pc12 ---> clk
- sdio1_cmd pd2 ---> cmd
for more detailed information. please refer to the application note document AN0105.
for more detailed information. please refer to the application note document AN0105.

View File

@@ -143,8 +143,8 @@ sd_error_status_type sd_init(void)
{
if(sd_card_info.card_type == SDIO_STD_CAPACITY_SD_CARD_V1_1 || sd_card_info.card_type == SDIO_STD_CAPACITY_SD_CARD_V2_0)
{
/* set sdio_ck to 12mhz */
clkdiv = system_core_clock / 12000000;
/* set sdio_ck to 4mhz */
clkdiv = system_core_clock / 4000000;
if(clkdiv >= 2)
{
@@ -153,8 +153,8 @@ sd_error_status_type sd_init(void)
}
else
{
/* set sdio_ck to 48mhz */
clkdiv = system_core_clock / 48000000;
/* set sdio_ck to 4mhz */
clkdiv = system_core_clock / 4000000;
if(clkdiv >= 2)
{

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -2,20 +2,20 @@
/ FatFs Functional Configurations
/---------------------------------------------------------------------------*/
#define FFCONF_DEF 86631 /* Revision ID */
#define FFCONF_DEF 86631 /* Revision ID */
/*---------------------------------------------------------------------------/
/ Function Configurations
/---------------------------------------------------------------------------*/
#define FF_FS_READONLY 0
#define FF_FS_READONLY 0
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
/ and optional writing functions as well. */
#define FF_FS_MINIMIZE 0
#define FF_FS_MINIMIZE 0
/* This option defines minimization level to remove some basic API functions.
/
/ 0: Basic functions are fully enabled.
@@ -25,41 +25,41 @@
/ 3: f_lseek() function is removed in addition to 2. */
#define FF_USE_FIND 0
#define FF_USE_FIND 0
/* This option switches filtered directory read functions, f_findfirst() and
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
#define FF_USE_MKFS 1//0
#define FF_USE_MKFS 1//0
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
#define FF_USE_FASTSEEK 1//0
#define FF_USE_FASTSEEK 1//0
/* This option switches fast seek function. (0:Disable or 1:Enable) */
#define FF_USE_EXPAND 0
#define FF_USE_EXPAND 0
/* This option switches f_expand function. (0:Disable or 1:Enable) */
#define FF_USE_CHMOD 0
#define FF_USE_CHMOD 0
/* This option switches attribute manipulation functions, f_chmod() and f_utime().
/ (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
#define FF_USE_LABEL 0
#define FF_USE_LABEL 0
/* This option switches volume label functions, f_getlabel() and f_setlabel().
/ (0:Disable or 1:Enable) */
#define FF_USE_FORWARD 0
#define FF_USE_FORWARD 0
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
#define FF_USE_STRFUNC 0
#define FF_PRINT_LLI 0
#define FF_PRINT_FLOAT 0
#define FF_STRF_ENCODE 0
#define FF_USE_STRFUNC 0
#define FF_PRINT_LLI 0
#define FF_PRINT_FLOAT 0
#define FF_STRF_ENCODE 0
/* FF_USE_STRFUNC switches string functions, f_gets(), f_putc(), f_puts() and
/ f_printf().
/
@@ -84,7 +84,7 @@
/ Locale and Namespace Configurations
/---------------------------------------------------------------------------*/
#define FF_CODE_PAGE 932
#define FF_CODE_PAGE 932
/* This option specifies the OEM code page to be used on the target system.
/ Incorrect code page setting can cause a file open failure.
/
@@ -113,8 +113,8 @@
*/
#define FF_USE_LFN 0
#define FF_MAX_LFN 255
#define FF_USE_LFN 0
#define FF_MAX_LFN 255
/* The FF_USE_LFN switches the support for LFN (long file name).
/
/ 0: Disable LFN. FF_MAX_LFN has no effect.
@@ -133,7 +133,7 @@
/ ff_memfree() exemplified in ffsystem.c, need to be added to the project. */
#define FF_LFN_UNICODE 0
#define FF_LFN_UNICODE 0
/* This option switches the character encoding on the API when LFN is enabled.
/
/ 0: ANSI/OEM in current CP (TCHAR = char)
@@ -145,15 +145,15 @@
/ When LFN is not enabled, this option has no effect. */
#define FF_LFN_BUF 255
#define FF_SFN_BUF 12
#define FF_LFN_BUF 255
#define FF_SFN_BUF 12
/* This set of options defines size of file name members in the FILINFO structure
/ which is used to read out directory items. These values should be suffcient for
/ the file names to read. The maximum possible length of the read file name depends
/ on character encoding. When LFN is not enabled, these options have no effect. */
#define FF_FS_RPATH 0
#define FF_FS_RPATH 0
/* This option configures support for relative path.
/
/ 0: Disable relative path and remove related functions.
@@ -166,12 +166,12 @@
/ Drive/Volume Configurations
/---------------------------------------------------------------------------*/
#define FF_VOLUMES 3//1
#define FF_VOLUMES 3//1
/* Number of volumes (logical drives) to be used. (1-10) */
#define FF_STR_VOLUME_ID 0
#define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
#define FF_STR_VOLUME_ID 0
#define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
@@ -184,7 +184,7 @@
*/
#define FF_MULTI_PARTITION 0
#define FF_MULTI_PARTITION 0
/* This option switches support for multiple volumes on the physical drive.
/ By default (0), each logical drive number is bound to the same physical drive
/ number and only an FAT volume found on the physical drive will be mounted.
@@ -193,8 +193,8 @@
/ funciton will be available. */
#define FF_MIN_SS 512
#define FF_MAX_SS 512
#define FF_MIN_SS 512
#define FF_MAX_SS 512
/* This set of options configures the range of sector size to be supported. (512,
/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
/ harddisk, but a larger value may be required for on-board flash memory and some
@@ -203,17 +203,17 @@
/ GET_SECTOR_SIZE command. */
#define FF_LBA64 0
#define FF_LBA64 0
/* This option switches support for 64-bit LBA. (0:Disable or 1:Enable)
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
#define FF_MIN_GPT 0x10000000
#define FF_MIN_GPT 0x10000000
/* Minimum number of sectors to switch GPT as partitioning format in f_mkfs and
/ f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */
#define FF_USE_TRIM 0
#define FF_USE_TRIM 0
/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
/ To enable Trim function, also CTRL_TRIM command should be implemented to the
/ disk_ioctl() function. */
@@ -224,23 +224,23 @@
/ System Configurations
/---------------------------------------------------------------------------*/
#define FF_FS_TINY 0
#define FF_FS_TINY 0
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
/ At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
/ Instead of private sector buffer eliminated from the file object, common sector
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
#define FF_FS_EXFAT 0
#define FF_FS_EXFAT 0
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
#define FF_FS_NORTC 1//0
#define FF_NORTC_MON 1
#define FF_NORTC_MDAY 1
#define FF_NORTC_YEAR 2020
#define FF_FS_NORTC 1//0
#define FF_NORTC_MON 1
#define FF_NORTC_MDAY 1
#define FF_NORTC_YEAR 2020
/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
/ any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
/ the timestamp function. Every object modified by FatFs will have a fixed timestamp
@@ -251,7 +251,7 @@
/ These options have no effect in read-only configuration (FF_FS_READONLY = 1). */
#define FF_FS_NOFSINFO 0
#define FF_FS_NOFSINFO 0
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
/ option, and f_getfree() function at first time after volume mount will force
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
@@ -263,7 +263,7 @@
*/
#define FF_FS_LOCK 0
#define FF_FS_LOCK 0
/* The option FF_FS_LOCK switches file lock function to control duplicated file open
/ and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
/ is 1.
@@ -275,10 +275,10 @@
/ lock control is independent of re-entrancy. */
/* #include <somertos.h> // O/S definitions */
#define FF_FS_REENTRANT 0
#define FF_FS_TIMEOUT 1000
#define FF_SYNC_t HANDLE
/* #include <somertos.h> // O/S definitions */
#define FF_FS_REENTRANT 0
#define FF_FS_TIMEOUT 1000
#define FF_SYNC_t HANDLE
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
/ module itself. Note that regardless of this option, file access to different
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()

View File

@@ -144,8 +144,8 @@ sd_error_status_type sd_init(void)
{
if(sd_card_info.card_type == SDIO_STD_CAPACITY_SD_CARD_V1_1 || sd_card_info.card_type == SDIO_STD_CAPACITY_SD_CARD_V2_0)
{
/* set sdio_ck to 12mhz */
clkdiv = system_core_clock / 12000000;
/* set sdio_ck to 4mhz */
clkdiv = system_core_clock / 4000000;
if(clkdiv >= 2)
{
@@ -154,8 +154,8 @@ sd_error_status_type sd_init(void)
}
else
{
/* set sdio_ck to 48mhz */
clkdiv = system_core_clock / 48000000;
/* set sdio_ck to 4mhz */
clkdiv = system_core_clock / 4000000;
if(clkdiv >= 2)
{

View File

@@ -28,9 +28,9 @@
/**
* @brief system clock config program
* @note the system clock is configured as follow:
* - system clock = hext / 2 * pll_mult
* - system clock source = pll (hext)
* - hext = 8000000
* system clock (sclk) = hext / 2 * pll_mult
* system clock source = pll (hext)
* - hext = HEXT_VALUE
* - sclk = 144000000
* - ahbdiv = 1
* - ahbclk = 144000000

View File

@@ -8,16 +8,16 @@
/*-----------------------------------------------------------------------*/
#include "ff.h" /* Obtains integer types */
#include "diskio.h" /* Declarations of disk functions */
#include "ff.h" /* Obtains integer types */
#include "diskio.h" /* Declarations of disk functions */
#include <string.h>
#include "at32_sdio.h" /* Example: Header file of existing MMC/SDC contorl module */
#include "at32_sdio.h" /* Example: Header file of existing MMC/SDC contorl module */
/* Definitions of physical drive number for each drive */
#define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */
#define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */
#define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */
#define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */
#define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */
#define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */
__align(4) uint8_t sdio_data_buffer[512]; /* buf for sd_read_disk/sd_write_disk function used. */
@@ -108,29 +108,29 @@ sd_error_status_type sd_write_disk(const uint8_t *buf, uint32_t sector, uint8_t
/* Get Drive Status */
/*-----------------------------------------------------------------------*/
DSTATUS disk_status (
BYTE pdrv /* Physical drive nmuber to identify the drive */
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
DSTATUS stat;
int result;
DSTATUS stat;
int result;
switch (pdrv) {
case DEV_RAM :
switch (pdrv) {
case DEV_RAM :
result = 1;
stat = (DSTATUS)result;
return stat;
return stat;
case DEV_MMC :
case DEV_MMC :
result = 0;
stat = (DSTATUS)result;
return stat;
return stat;
case DEV_USB :
case DEV_USB :
result = 1;
stat = (DSTATUS)result;
return stat;
}
return STA_NOINIT;
return stat;
}
return STA_NOINIT;
}
@@ -139,29 +139,29 @@ DSTATUS disk_status (
/* Inidialize a Drive */
/*-----------------------------------------------------------------------*/
DSTATUS disk_initialize (
BYTE pdrv /* Physical drive nmuber to identify the drive */
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
DSTATUS stat;
int result;
DSTATUS stat;
int result;
switch (pdrv) {
case DEV_RAM :
switch (pdrv) {
case DEV_RAM :
result = 1;
stat = (DSTATUS)result;
return stat;
return stat;
case DEV_MMC :
case DEV_MMC :
result = sd_init();
stat = (DSTATUS)result;
return stat;
return stat;
case DEV_USB :
case DEV_USB :
result = 1;
stat = (DSTATUS)result;
return stat;
}
return STA_NOINIT;
return stat;
}
return STA_NOINIT;
}
@@ -170,33 +170,33 @@ DSTATUS disk_initialize (
/* Read Sector(s) */
/*-----------------------------------------------------------------------*/
DRESULT disk_read (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE *buff, /* Data buffer to store read data */
LBA_t sector, /* Start sector in LBA */
UINT count /* Number of sectors to read */
BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE *buff, /* Data buffer to store read data */
LBA_t sector, /* Start sector in LBA */
UINT count /* Number of sectors to read */
)
{
DRESULT res;
int result;
DRESULT res;
int result;
switch (pdrv) {
case DEV_RAM :
switch (pdrv) {
case DEV_RAM :
result = 1;
res = (DRESULT)result;
return res;
return res;
case DEV_MMC :
case DEV_MMC :
result = sd_read_disk(buff, sector, count);
res = (DRESULT)result;
return res;
return res;
case DEV_USB :
case DEV_USB :
result = 1;
res = (DRESULT)result;
return res;
}
return res;
}
return RES_PARERR;
return RES_PARERR;
}
@@ -207,33 +207,33 @@ DRESULT disk_read (
#if FF_FS_READONLY == 0
DRESULT disk_write (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
const BYTE *buff, /* Data to be written */
LBA_t sector, /* Start sector in LBA */
UINT count /* Number of sectors to write */
BYTE pdrv, /* Physical drive nmuber to identify the drive */
const BYTE *buff, /* Data to be written */
LBA_t sector, /* Start sector in LBA */
UINT count /* Number of sectors to write */
)
{
DRESULT res;
int result;
DRESULT res;
int result;
switch (pdrv) {
case DEV_RAM :
switch (pdrv) {
case DEV_RAM :
result = 1;
res = (DRESULT)result;
return res;
return res;
case DEV_MMC :
case DEV_MMC :
result = sd_write_disk(buff, sector, count);
res = (DRESULT)result;
return res;
return res;
case DEV_USB :
case DEV_USB :
result = 1;
res = (DRESULT)result;
return res;
}
return res;
}
return RES_PARERR;
return RES_PARERR;
}
#endif
@@ -243,21 +243,21 @@ DRESULT disk_write (
/* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/
DRESULT disk_ioctl (
BYTE pdrv, /* Physical drive nmuber (0..) */
BYTE cmd, /* Control code */
void *buff /* Buffer to send/receive control data */
BYTE pdrv, /* Physical drive nmuber (0..) */
BYTE cmd, /* Control code */
void *buff /* Buffer to send/receive control data */
)
{
DRESULT res;
int result;
DRESULT res;
int result;
switch (pdrv) {
case DEV_RAM :
switch (pdrv) {
case DEV_RAM :
result = 1;
res = (DRESULT)result;
return res;
return res;
case DEV_MMC :
case DEV_MMC :
switch(cmd){
case CTRL_SYNC:
result = RES_OK;
@@ -279,13 +279,13 @@ DRESULT disk_ioctl (
break;
}
res = (DRESULT)result;
return res;
return res;
case DEV_USB :
case DEV_USB :
result = 1;
res = (DRESULT)result;
return res;
}
return res;
}
return RES_PARERR;
return RES_PARERR;
}