User manual
402
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Prototype
sub function Mmc_Fat_Get_Swap_File(dim sectors_cnt as longword, dim byref
lename as string[11], dim le_attr as byte) as longword
Description This function is used to create a swap le of predened name and size on the MMC/SD media. If a
le with specied name already exists on the media, search for consecutive sectors will ignore sectors
occupied by this le. Therefore, it is recommended to erase such le if it already exists before calling
this function. If it is not erased and there is still enough space for a new swap le, this function will
delete it after allocating new memory space for a new swap le.
The purpose of the swap le is to make reading and writing to MMC/SD media as fast as possible,
by using the Mmc_Read_Sector() and Mmc_Write_Sector() functions directly, without potentially
damaging the FAT system. The swap le can be considered as a “window” on the media where the
user can freely write/read data. It’s main purpose in this library is to be used for fast data acquisition;
when the time-critical acquisition has nished, the data can be re-written into a “normal” le, and
formatted in the most suitable way.
Parameters - sectors_cnt: number of consecutive sectors that user wants the swap le to have.
- lename: name of the le that should be assigned for le operations. File name should be in DOS 8.3
(le_name.extension) format. The le name and extension will be automatically padded with spaces
by the library if they have less than length required (i.e. “mikro.tx” -> “mikro .tx “), so the user does no
have to take care of that. The le name and extension are case insensitive. The library will convert
them to proper case automatically, so the user does not have to take care of that.
Also, in order to keep backward compatibility with the rst version of this library, le names can be
entered as UPPERCASE string of 11 bytes in length with no dot character between le name and
extension (i.e. “MIKROELETXT” -> MIKROELE.TXT). In this case last 3 characters of the string are
considered to be le extension.
- le_attr: le creation and attributes ags. Each bit corresponds to the appropriate le attribute:
Returns - Number of the start sector for the newly created swap le, if there was enough free space on the
MMC/SD card to create le of required size.
- 0 - otherwise.
Requires MMC/SD card and MMC library must be initialized for le operations. See Mmc_Fat_Init.
Mmc_Fat_Get_Swap_File
Bit Mask Description
0 0x01 Read Only
1 0x02 Hidden
2 0x04 System
3 0x08 Volume Label
4 0x10 Subdirectory
5 0x20 Archive
6 0x40 Device (internal use only, never found on disk)
7 0x80 Not used