first 2016/02 SDFileSystemDMA inherited from Official SDFileSystem.
Dependents: SDFileSystemDMA-test DmdFullRGB_0_1
Fork of SDFileSystemDMA by
SDFileSystemDMA is enhanced SDFileSystem library for STM32 micros by using DMA functionality.
Max read transfer rate reaches over 2MByte/sec at 24MHz SPI clock if enough read buffer size is set.
Even though minimum read buffer size (512Byte) is set, read transfer rate will reach over 1MByte/sec at 24MHz SPI Clock.
( but depends on the ability of each SD card)
Test program is here.
https://developer.mbed.org/users/mimi3/code/SDFileSystemDMA-test/
Supported SPI port is shown below table.
(v): Verified. It works well.
(w): Probably it will work well. (not tested)
(c): Only compiled. (not tested)
(f): Over flash.
(r): Only read mode. (when _FS_READONLY==1)
(u) Under construction
(z): Dose not work.
Caution
If your board has SRAM less than or equal to 8KB, the buffer size must be set to 512 Bytes.
Supported Boards:
Cortex-M0
Board | SRAM | SPI1 | SPI2 | SPI3 |
---|---|---|---|---|
NUCLEO-F030R8 | 8KB | (v) | ||
DISCO-F051R8 | 8KB | (w) | ||
4KB | (f) | |||
NUCLEO-F042K6 | 6KB | (r) | ||
NUCLEO-F070RB | 16KB | (w) | ||
NUCLEO-F072RB | 16KB | (w) | ||
NUCLEO-F091RC | 32KB | (c) |
Cortex-L0
Board | SRAM | SPI1 | SPI2 | SPI3 |
---|---|---|---|---|
DISCO-L053C8 | 8KB | (c) | ||
NUCLEO-L053R8 | 8KB | (c) | ||
NUCLEO-L073RZ | 20KB | (c) |
Cortex-M3
Board | SRAM | SPI1 | SPI2 | SPI3 |
---|---|---|---|---|
DISCO-F100RB | 8KB | (v) | (v) | - |
BLUEPILL-F103CB | 20KB | (w) | (w) | - |
NUCLEO-F103RB | 20KB | (v) | (v) | - |
NUCLEO-L152RE | 80KB | (v) | (w) | - |
MOTE-L152RC | 32KB | (w) | (w) | - |
Cortex-M4
F3
Board | SRAM | SPI1 | SPI2 | SPI3 |
---|---|---|---|---|
DISCO-F303VC | 40KB | - | (v) | (v) |
NUCLEO-F303RE | 64KB | (w) | (w) | (w) |
NUCLEO-F302R8 | 16KB | - | - | (c) |
NUCLEO-F303K8 | 12KB | (c) | - | - |
DISCO-F334C8 | 12KB | (c) | - | - |
NUCLEO-F334R8 | 12KB | (c) | - | - |
F4
Board | SPI1 | SPI2 | SPI3 |
---|---|---|---|
ELMO-F411RE | (w) | - | (w) |
MTS-MDOT-F411RE | (u) | - | (u) |
MTS-DRAGONFLY-F411RE | (w) | - | (w) |
NUCLEO-F411RE | (v) | - | (v) |
NUCLEO-F401RE | (w) | - | (w) |
MTS-MDOT-F405RG | (u) | - | (u) |
NUCLEO-F410RB | (c) | - | (c) |
NUCLEO-F446RE | (c) | - | (c) |
NUCLEO-F429ZI | (c) | - | (c) |
B96B-F446VE | (c) | - | (c) |
NUCLEO-F446ZE | (c) | - | (c) |
DISCO-F429ZI | (u) | - | (u) |
DISCO-F469NI | (c) | - | (c) |
Information
This library is set to use "short file name" in SDFileSystemDMA/FATFileSystem/ChaN/ffconf.h . ( _USE_LFN=0)
You can change this option to _USE_LFN=1 .
FATFileSystem/ChaN/diskio.cpp@38:7077795dbf81, 2017-01-22 (annotated)
- Committer:
- mimi3
- Date:
- Sun Jan 22 23:13:11 2017 +0900
- Revision:
- 38:7077795dbf81
- Parent:
- 10:b48d3ace55db
change: table.md
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mimi3 | 10:b48d3ace55db | 1 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 2 | /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */ |
mimi3 | 10:b48d3ace55db | 3 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 4 | /* If a working storage control module is available, it should be */ |
mimi3 | 10:b48d3ace55db | 5 | /* attached to the FatFs via a glue function rather than modifying it. */ |
mimi3 | 10:b48d3ace55db | 6 | /* This is an example of glue functions to attach various exsisting */ |
mimi3 | 10:b48d3ace55db | 7 | /* storage control modules to the FatFs module with a defined API. */ |
mimi3 | 10:b48d3ace55db | 8 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 9 | |
mimi3 | 10:b48d3ace55db | 10 | #include "diskio.h" |
mimi3 | 10:b48d3ace55db | 11 | #include "mbed_debug.h" |
mimi3 | 10:b48d3ace55db | 12 | #include "FATFileSystem.h" |
mimi3 | 10:b48d3ace55db | 13 | |
mimi3 | 10:b48d3ace55db | 14 | using namespace mbed; |
mimi3 | 10:b48d3ace55db | 15 | |
mimi3 | 10:b48d3ace55db | 16 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 17 | /* Get Drive Status */ |
mimi3 | 10:b48d3ace55db | 18 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 19 | |
mimi3 | 10:b48d3ace55db | 20 | DSTATUS disk_status ( |
mimi3 | 10:b48d3ace55db | 21 | BYTE pdrv /* Physical drive nmuber to identify the drive */ |
mimi3 | 10:b48d3ace55db | 22 | ) |
mimi3 | 10:b48d3ace55db | 23 | { |
mimi3 | 10:b48d3ace55db | 24 | debug_if(FFS_DBG, "disk_status on pdrv [%d]\n", pdrv); |
mimi3 | 10:b48d3ace55db | 25 | return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_status(); |
mimi3 | 10:b48d3ace55db | 26 | } |
mimi3 | 10:b48d3ace55db | 27 | |
mimi3 | 10:b48d3ace55db | 28 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 29 | /* Inidialize a Drive */ |
mimi3 | 10:b48d3ace55db | 30 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 31 | |
mimi3 | 10:b48d3ace55db | 32 | DSTATUS disk_initialize ( |
mimi3 | 10:b48d3ace55db | 33 | BYTE pdrv /* Physical drive nmuber to identify the drive */ |
mimi3 | 10:b48d3ace55db | 34 | ) |
mimi3 | 10:b48d3ace55db | 35 | { |
mimi3 | 10:b48d3ace55db | 36 | debug_if(FFS_DBG, "disk_initialize on pdrv [%d]\n", pdrv); |
mimi3 | 10:b48d3ace55db | 37 | return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_initialize(); |
mimi3 | 10:b48d3ace55db | 38 | } |
mimi3 | 10:b48d3ace55db | 39 | |
mimi3 | 10:b48d3ace55db | 40 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 41 | /* Read Sector(s) */ |
mimi3 | 10:b48d3ace55db | 42 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 43 | |
mimi3 | 10:b48d3ace55db | 44 | DRESULT disk_read ( |
mimi3 | 10:b48d3ace55db | 45 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ |
mimi3 | 10:b48d3ace55db | 46 | BYTE* buff, /* Data buffer to store read data */ |
mimi3 | 10:b48d3ace55db | 47 | DWORD sector, /* Sector address in LBA */ |
mimi3 | 10:b48d3ace55db | 48 | UINT count /* Number of sectors to read */ |
mimi3 | 10:b48d3ace55db | 49 | ) |
mimi3 | 10:b48d3ace55db | 50 | { |
mimi3 | 10:b48d3ace55db | 51 | debug_if(FFS_DBG, "disk_read(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv); |
mimi3 | 10:b48d3ace55db | 52 | if (FATFileSystem::_ffs[pdrv]->disk_read((uint8_t*)buff, sector, count)) |
mimi3 | 10:b48d3ace55db | 53 | return RES_PARERR; |
mimi3 | 10:b48d3ace55db | 54 | else |
mimi3 | 10:b48d3ace55db | 55 | return RES_OK; |
mimi3 | 10:b48d3ace55db | 56 | } |
mimi3 | 10:b48d3ace55db | 57 | |
mimi3 | 10:b48d3ace55db | 58 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 59 | /* Write Sector(s) */ |
mimi3 | 10:b48d3ace55db | 60 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 61 | |
mimi3 | 10:b48d3ace55db | 62 | #if _USE_WRITE |
mimi3 | 10:b48d3ace55db | 63 | DRESULT disk_write ( |
mimi3 | 10:b48d3ace55db | 64 | BYTE pdrv, /* Physical drive nmuber to identify the drive */ |
mimi3 | 10:b48d3ace55db | 65 | const BYTE* buff, /* Data to be written */ |
mimi3 | 10:b48d3ace55db | 66 | DWORD sector, /* Sector address in LBA */ |
mimi3 | 10:b48d3ace55db | 67 | UINT count /* Number of sectors to write */ |
mimi3 | 10:b48d3ace55db | 68 | ) |
mimi3 | 10:b48d3ace55db | 69 | { |
mimi3 | 10:b48d3ace55db | 70 | debug_if(FFS_DBG, "disk_write(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv); |
mimi3 | 10:b48d3ace55db | 71 | if (FATFileSystem::_ffs[pdrv]->disk_write((uint8_t*)buff, sector, count)) |
mimi3 | 10:b48d3ace55db | 72 | return RES_PARERR; |
mimi3 | 10:b48d3ace55db | 73 | else |
mimi3 | 10:b48d3ace55db | 74 | return RES_OK; |
mimi3 | 10:b48d3ace55db | 75 | } |
mimi3 | 10:b48d3ace55db | 76 | #endif |
mimi3 | 10:b48d3ace55db | 77 | |
mimi3 | 10:b48d3ace55db | 78 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 79 | /* Miscellaneous Functions */ |
mimi3 | 10:b48d3ace55db | 80 | /*-----------------------------------------------------------------------*/ |
mimi3 | 10:b48d3ace55db | 81 | |
mimi3 | 10:b48d3ace55db | 82 | #if _USE_IOCTL |
mimi3 | 10:b48d3ace55db | 83 | DRESULT disk_ioctl ( |
mimi3 | 10:b48d3ace55db | 84 | BYTE pdrv, /* Physical drive nmuber (0..) */ |
mimi3 | 10:b48d3ace55db | 85 | BYTE cmd, /* Control code */ |
mimi3 | 10:b48d3ace55db | 86 | void* buff /* Buffer to send/receive control data */ |
mimi3 | 10:b48d3ace55db | 87 | ) |
mimi3 | 10:b48d3ace55db | 88 | { |
mimi3 | 10:b48d3ace55db | 89 | debug_if(FFS_DBG, "disk_ioctl(%d)\n", cmd); |
mimi3 | 10:b48d3ace55db | 90 | switch(cmd) { |
mimi3 | 10:b48d3ace55db | 91 | case CTRL_SYNC: |
mimi3 | 10:b48d3ace55db | 92 | if(FATFileSystem::_ffs[pdrv] == NULL) { |
mimi3 | 10:b48d3ace55db | 93 | return RES_NOTRDY; |
mimi3 | 10:b48d3ace55db | 94 | } else if(FATFileSystem::_ffs[pdrv]->disk_sync()) { |
mimi3 | 10:b48d3ace55db | 95 | return RES_ERROR; |
mimi3 | 10:b48d3ace55db | 96 | } |
mimi3 | 10:b48d3ace55db | 97 | return RES_OK; |
mimi3 | 10:b48d3ace55db | 98 | case GET_SECTOR_COUNT: |
mimi3 | 10:b48d3ace55db | 99 | if(FATFileSystem::_ffs[pdrv] == NULL) { |
mimi3 | 10:b48d3ace55db | 100 | return RES_NOTRDY; |
mimi3 | 10:b48d3ace55db | 101 | } else { |
mimi3 | 10:b48d3ace55db | 102 | DWORD res = FATFileSystem::_ffs[pdrv]->disk_sectors(); |
mimi3 | 10:b48d3ace55db | 103 | if(res > 0) { |
mimi3 | 10:b48d3ace55db | 104 | *((DWORD*)buff) = res; // minimum allowed |
mimi3 | 10:b48d3ace55db | 105 | return RES_OK; |
mimi3 | 10:b48d3ace55db | 106 | } else { |
mimi3 | 10:b48d3ace55db | 107 | return RES_ERROR; |
mimi3 | 10:b48d3ace55db | 108 | } |
mimi3 | 10:b48d3ace55db | 109 | } |
mimi3 | 10:b48d3ace55db | 110 | case GET_BLOCK_SIZE: |
mimi3 | 10:b48d3ace55db | 111 | *((DWORD*)buff) = 1; // default when not known |
mimi3 | 10:b48d3ace55db | 112 | return RES_OK; |
mimi3 | 10:b48d3ace55db | 113 | |
mimi3 | 10:b48d3ace55db | 114 | } |
mimi3 | 10:b48d3ace55db | 115 | return RES_PARERR; |
mimi3 | 10:b48d3ace55db | 116 | } |
mimi3 | 10:b48d3ace55db | 117 | #endif |