-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial release based on FatFs R0.11 modified by ST.
Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
- Loading branch information
Showing
30 changed files
with
38,485 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
See [license page](http://elm-chan.org/fsw/ff/doc/appnote.html#license) | ||
|
||
> /*----------------------------------------------------------------------------/<br> | ||
> / FatFs - Generic FAT Filesystem Module Rx.xx /<br> | ||
> /-----------------------------------------------------------------------------/<br> | ||
> /<br> | ||
> / Copyright (C) 20xx, ChaN, all right reserved.<br> | ||
> /<br> | ||
> / FatFs module is an open source software. Redistribution and use of FatFs in<br> | ||
> / source and binary forms, with or without modification, are permitted provided<br> | ||
> / that the following condition is met:<br> | ||
> /<br> | ||
> / 1. Redistributions of source code must retain the above copyright notice,<br> | ||
> / this condition and the following disclaimer.<br> | ||
> /<br> | ||
> / This software is provided by the copyright holder and contributors "AS IS"<br> | ||
> / and any warranties related to this software are DISCLAIMED.<br> | ||
> / The copyright owner or contributors be NOT LIABLE for any damages caused<br> | ||
> / by use of this software.<br> | ||
> /----------------------------------------------------------------------------*/<br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
# FatFs | ||
FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture. | ||
|
||
FatFs has being developped as a personal project of the author, ChaN. | ||
|
||
See [elm-chan.org/fsw/ff](http://elm-chan.org/fsw/ff/00index_e.html) | ||
|
||
Modified by ST, see the st_readme.txt. | ||
Modified to fit Arduino libraries specifications. | ||
|
||
It is used by the STM32SD library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name=FatFs | ||
version=1.4.1 | ||
author=Chan <user5@elm-chan org>, ST | ||
maintainer=stm32duino | ||
sentence=FAT file system based on open-source FatFS solution. | ||
paragraph=FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture. | ||
category=Data Storage | ||
url=https://github.com/stm32duino/FatFs | ||
architectures=stm32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FatFs Module Source Files R0.11 | ||
|
||
|
||
FILES | ||
|
||
00readme.txt This file. | ||
history.txt Revision history. | ||
ffconf.h Configuration file for FatFs module. | ||
ff.h Common include file for FatFs and application module. | ||
ff.c FatFs module. | ||
diskio.h Common include file for FatFs and disk I/O module. | ||
diskio.c An example of glue function to attach existing disk I/O module to FatFs. | ||
integer.h Integer type definitions for FatFs. | ||
option Optional external functions. | ||
|
||
|
||
Low level disk I/O module is not included in this archive because the FatFs | ||
module is only a generic file system layer and not depend on any specific | ||
storage device. You have to provide a low level disk I/O module that written | ||
to control the target storage device. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
****************************************************************************** | ||
* @file FatFs.h | ||
* @author Frederic Pillon <frederic.pillon@st.com> for STMicroelectronics | ||
* @version V1.0.0 | ||
* @date 30-Aug-2017 | ||
* @brief Include FatFs source files | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* 3. Neither the name of STMicroelectronics nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
****************************************************************************** | ||
*/ | ||
/* Define to prevent recursive inclusion -------------------------------------*/ | ||
#ifndef __FATFS_H__ | ||
#define __FATFS_H__ | ||
|
||
/* This file is the enter point of the library for Arduino */ | ||
#include "ff_gen_drv.h" | ||
#include "drivers/sd_diskio.h" | ||
|
||
#endif /* __FATFS_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
/*-----------------------------------------------------------------------*/ | ||
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */ | ||
/* */ | ||
/* Portions COPYRIGHT 2017 STMicroelectronics */ | ||
/* Portions Copyright (C) 2014, ChaN, all right reserved */ | ||
/*-----------------------------------------------------------------------*/ | ||
/* If a working storage control module is available, it should be */ | ||
/* attached to the FatFs via a glue function rather than modifying it. */ | ||
/* This is an example of glue functions to attach various exsisting */ | ||
/* storage control modules to the FatFs module with a defined API. */ | ||
/*-----------------------------------------------------------------------*/ | ||
|
||
/** | ||
****************************************************************************** | ||
* @file diskio.c | ||
* @author MCD Application Team | ||
* @version V1.4.1 | ||
* @date 14-February-2017 | ||
* @brief FatFs low level disk I/O module. | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted, provided that the following conditions are met: | ||
* | ||
* 1. Redistribution of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* 3. Neither the name of STMicroelectronics nor the names of other | ||
* contributors to this software may be used to endorse or promote products | ||
* derived from this software without specific written permission. | ||
* 4. This software, including modifications and/or derivative works of this | ||
* software, must execute solely and exclusively on microcontroller or | ||
* microprocessor devices manufactured by or for STMicroelectronics. | ||
* 5. Redistribution and use of this software other than as permitted under | ||
* this license is void and will automatically terminate your rights under | ||
* this license. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY | ||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT | ||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
****************************************************************************** | ||
*/ | ||
|
||
/* Includes ------------------------------------------------------------------*/ | ||
#include "diskio.h" | ||
#include "ff_gen_drv.h" | ||
|
||
/* Private typedef -----------------------------------------------------------*/ | ||
/* Private define ------------------------------------------------------------*/ | ||
/* Private variables ---------------------------------------------------------*/ | ||
extern Disk_drvTypeDef disk; | ||
|
||
/* Private function prototypes -----------------------------------------------*/ | ||
/* Private functions ---------------------------------------------------------*/ | ||
|
||
/** | ||
* @brief Gets Disk Status | ||
* @param pdrv: Physical drive number (0..) | ||
* @retval DSTATUS: Operation status | ||
*/ | ||
DSTATUS disk_status ( | ||
BYTE pdrv /* Physical drive nmuber to identify the drive */ | ||
) | ||
{ | ||
DSTATUS stat; | ||
|
||
stat = disk.drv[pdrv]->disk_status(disk.lun[pdrv]); | ||
return stat; | ||
} | ||
|
||
/** | ||
* @brief Initializes a Drive | ||
* @param pdrv: Physical drive number (0..) | ||
* @retval DSTATUS: Operation status | ||
*/ | ||
DSTATUS disk_initialize ( | ||
BYTE pdrv /* Physical drive nmuber to identify the drive */ | ||
) | ||
{ | ||
DSTATUS stat = RES_OK; | ||
|
||
if(disk.is_initialized[pdrv] == 0) | ||
{ | ||
disk.is_initialized[pdrv] = 1; | ||
stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]); | ||
} | ||
return stat; | ||
} | ||
|
||
/** | ||
* @brief Reads Sector(s) | ||
* @param pdrv: Physical drive number (0..) | ||
* @param *buff: Data buffer to store read data | ||
* @param sector: Sector address (LBA) | ||
* @param count: Number of sectors to read (1..128) | ||
* @retval DRESULT: Operation result | ||
*/ | ||
DRESULT disk_read ( | ||
BYTE pdrv, /* Physical drive nmuber to identify the drive */ | ||
BYTE *buff, /* Data buffer to store read data */ | ||
DWORD sector, /* Sector address in LBA */ | ||
UINT count /* Number of sectors to read */ | ||
) | ||
{ | ||
DRESULT res; | ||
|
||
res = disk.drv[pdrv]->disk_read(disk.lun[pdrv], buff, sector, count); | ||
return res; | ||
} | ||
|
||
/** | ||
* @brief Writes Sector(s) | ||
* @param pdrv: Physical drive number (0..) | ||
* @param *buff: Data to be written | ||
* @param sector: Sector address (LBA) | ||
* @param count: Number of sectors to write (1..128) | ||
* @retval DRESULT: Operation result | ||
*/ | ||
#if _USE_WRITE == 1 | ||
DRESULT disk_write ( | ||
BYTE pdrv, /* Physical drive nmuber to identify the drive */ | ||
const BYTE *buff, /* Data to be written */ | ||
DWORD sector, /* Sector address in LBA */ | ||
UINT count /* Number of sectors to write */ | ||
) | ||
{ | ||
DRESULT res; | ||
|
||
res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count); | ||
return res; | ||
} | ||
#endif /* _USE_WRITE == 1 */ | ||
|
||
/** | ||
* @brief I/O control operation | ||
* @param pdrv: Physical drive number (0..) | ||
* @param cmd: Control code | ||
* @param *buff: Buffer to send/receive control data | ||
* @retval DRESULT: Operation result | ||
*/ | ||
#if _USE_IOCTL == 1 | ||
DRESULT disk_ioctl ( | ||
BYTE pdrv, /* Physical drive nmuber (0..) */ | ||
BYTE cmd, /* Control code */ | ||
void *buff /* Buffer to send/receive control data */ | ||
) | ||
{ | ||
DRESULT res; | ||
|
||
res = disk.drv[pdrv]->disk_ioctl(disk.lun[pdrv], cmd, buff); | ||
return res; | ||
} | ||
#endif /* _USE_IOCTL == 1 */ | ||
|
||
/** | ||
* @brief Gets Time from RTC | ||
* @param None | ||
* @retval Time in DWORD | ||
*/ | ||
__weak DWORD get_fattime (void) | ||
{ | ||
return 0; | ||
} | ||
|
||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/*-----------------------------------------------------------------------/ | ||
/ Low level disk interface modlue include file (C)ChaN, 2014 / | ||
/-----------------------------------------------------------------------*/ | ||
|
||
#ifndef _DISKIO_DEFINED | ||
#define _DISKIO_DEFINED | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#define _USE_WRITE 1 /* 1: Enable disk_write function */ | ||
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ | ||
|
||
#include "integer.h" | ||
|
||
|
||
/* Status of Disk Functions */ | ||
typedef BYTE DSTATUS; | ||
|
||
/* Results of Disk Functions */ | ||
typedef enum { | ||
RES_OK = 0, /* 0: Successful */ | ||
RES_ERROR, /* 1: R/W Error */ | ||
RES_WRPRT, /* 2: Write Protected */ | ||
RES_NOTRDY, /* 3: Not Ready */ | ||
RES_PARERR /* 4: Invalid Parameter */ | ||
} DRESULT; | ||
|
||
|
||
/*---------------------------------------*/ | ||
/* Prototypes for disk control functions */ | ||
|
||
|
||
DSTATUS disk_initialize (BYTE pdrv); | ||
DSTATUS disk_status (BYTE pdrv); | ||
DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); | ||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); | ||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); | ||
DWORD get_fattime (void); | ||
|
||
/* Disk Status Bits (DSTATUS) */ | ||
|
||
#define STA_NOINIT 0x01 /* Drive not initialized */ | ||
#define STA_NODISK 0x02 /* No medium in the drive */ | ||
#define STA_PROTECT 0x04 /* Write protected */ | ||
|
||
|
||
/* Command code for disk_ioctrl fucntion */ | ||
|
||
/* Generic command (Used by FatFs) */ | ||
#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */ | ||
#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */ | ||
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */ | ||
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */ | ||
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */ | ||
|
||
/* Generic command (Not used by FatFs) */ | ||
#define CTRL_POWER 5 /* Get/Set power status */ | ||
#define CTRL_LOCK 6 /* Lock/Unlock media removal */ | ||
#define CTRL_EJECT 7 /* Eject media */ | ||
#define CTRL_FORMAT 8 /* Create physical format on the media */ | ||
|
||
/* MMC/SDC specific ioctl command */ | ||
#define MMC_GET_TYPE 10 /* Get card type */ | ||
#define MMC_GET_CSD 11 /* Get CSD */ | ||
#define MMC_GET_CID 12 /* Get CID */ | ||
#define MMC_GET_OCR 13 /* Get OCR */ | ||
#define MMC_GET_SDSTAT 14 /* Get SD status */ | ||
|
||
/* ATA/CF specific ioctl command */ | ||
#define ATA_GET_REV 20 /* Get F/W revision */ | ||
#define ATA_GET_MODEL 21 /* Get model name */ | ||
#define ATA_GET_SN 22 /* Get serial number */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.