From 4c4f2603f58380742b28fc79054eedda111f8063 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 12 Jun 2016 19:18:47 +0200 Subject: [PATCH] Attic: tar up 'original-pff' for less clutter on grep'ing. --- .../README-Teacup => original-pff-README} | 0 attic/original-pff.tar.gz | Bin 0 -> 17452 bytes attic/original-pff/00readme.txt | 46 - attic/original-pff/avr_mmcp.c | 261 ---- attic/original-pff/diskio.c | 72 -- attic/original-pff/diskio.h | 42 - attic/original-pff/integer.h | 33 - attic/original-pff/pff.c | 1107 ----------------- attic/original-pff/pff.h | 159 --- attic/original-pff/pffconf.h | 89 -- attic/original-pff/pic24_mmcp.c | 290 ----- 11 files changed, 2099 deletions(-) rename attic/{original-pff/README-Teacup => original-pff-README} (100%) create mode 100644 attic/original-pff.tar.gz delete mode 100644 attic/original-pff/00readme.txt delete mode 100644 attic/original-pff/avr_mmcp.c delete mode 100644 attic/original-pff/diskio.c delete mode 100644 attic/original-pff/diskio.h delete mode 100644 attic/original-pff/integer.h delete mode 100644 attic/original-pff/pff.c delete mode 100644 attic/original-pff/pff.h delete mode 100644 attic/original-pff/pffconf.h delete mode 100644 attic/original-pff/pic24_mmcp.c diff --git a/attic/original-pff/README-Teacup b/attic/original-pff-README similarity index 100% rename from attic/original-pff/README-Teacup rename to attic/original-pff-README diff --git a/attic/original-pff.tar.gz b/attic/original-pff.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..439938946d3a242f672c9d1d4344f243284fc8a7 GIT binary patch literal 17452 zcmZ^qQ;aZN53R?xZQHhO+qP}nwr$(CZO^=8^L!`g^5k#Q-Ieb9CVjGs9}NKjlBuf> z0DPn4nY<;@^wxh*In|7)*AST2v2E)OOu}d;BMjd1?`4}^utIdPmQ|vLdz#QvkdBd=Lw zp5qJ9q}S<1_zH~a^3&sPAonPQ<^}?+$Ar1>XfMVaQF}}7AbjT4%%<-(XX2$d!82$6 zJw}wT`+!67b|*A{@+AQI5s2*1u)aQ1+v0(1S0KS1y#E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~}uA!7*eo1IuooYnx}ROEnp7`0Vg9kA{pK`^l$ zh_ydl+C@P^E+tyJ>tZm=*(PK0Oi;tg1!aQLNr#pq>zi0E>pI+tYK@Wun8bNY(Za28 zsY1v37AlUn3FYDUt#G_LI7LFUGEnMLFjk>stg6;8rS8(i)wJVYBs47pndvZQF|>VD z0rn+Bl9zaCt?3{-zya0;hG2xa@FaD^KDaIa^ikXtd{d~wq(oi4@@F4#UGeKa<8FQX zR&>gg_zGQ?b%I-14wPwEd7-KEg`k8$-FlX6rz$EJBC9oY3G$6%q-+OZWzRcfIr z2E5PkEn#+@{$0tzJON7?AIVC%m1!t?anv6-1Fzv+@I>*T@aU*KVmJGpv7VtnoNFO zgx6jLUta@G3Lpt{;UJO?+VM?IEH$iNTT}JoMfLjW`s&t~N)}DYrd /* Device specific include files */ - -#define SELECT() PORTB &= ~_BV(3) /* CS = L */ -#define DESELECT() PORTB |= _BV(3) /* CS = H */ -#define SELECTING !(PORTB & _BV(3)) /* CS status (true:CS low) */ -#define FORWARD(d) xmit(d) /* Data forwarding function (console out) */ - -void xmit (char); /* suart.S: Send a byte via software UART */ -void dly_100us (void); /* usi.S: Delay 100 microseconds */ -void init_spi (void); /* usi.S: Initialize MMC control ports */ -void xmit_spi (BYTE d); /* usi.S: Send a byte to the MMC */ -BYTE rcv_spi (void); /* usi.S: Send a 0xFF to the MMC and get the received byte */ - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - -/* Definitions for MMC/SDC command */ -#define CMD0 (0x40+0) /* GO_IDLE_STATE */ -#define CMD1 (0x40+1) /* SEND_OP_COND (MMC) */ -#define ACMD41 (0xC0+41) /* SEND_OP_COND (SDC) */ -#define CMD8 (0x40+8) /* SEND_IF_COND */ -#define CMD16 (0x40+16) /* SET_BLOCKLEN */ -#define CMD17 (0x40+17) /* READ_SINGLE_BLOCK */ -#define CMD24 (0x40+24) /* WRITE_BLOCK */ -#define CMD55 (0x40+55) /* APP_CMD */ -#define CMD58 (0x40+58) /* READ_OCR */ - - -/* Card type flags (CardType) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -static -BYTE CardType; - - -/*-----------------------------------------------------------------------*/ -/* Send a command packet to MMC */ -/*-----------------------------------------------------------------------*/ - -static -BYTE send_cmd ( - BYTE cmd, /* 1st byte (Start + Index) */ - DWORD arg /* Argument (32 bits) */ -) -{ - BYTE n, res; - - - if (cmd & 0x80) { /* ACMD is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card */ - DESELECT(); - rcv_spi(); - SELECT(); - rcv_spi(); - - /* Send a command packet */ - xmit_spi(cmd); /* Start + Command index */ - xmit_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xmit_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xmit_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xmit_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */ - xmit_spi(n); - - /* Receive a command response */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do { - res = rcv_spi(); - } while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize (void) -{ - BYTE n, cmd, ty, ocr[4]; - UINT tmr; - -#if _USE_WRITE - if (CardType && SELECTING) disk_writep(0, 0); /* Finalize write process if it is in progress */ -#endif - init_spi(); /* Initialize ports to control MMC */ - DESELECT(); - for (n = 10; n; n--) rcv_spi(); /* 80 dummy clocks with CS=H */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* GO_IDLE_STATE */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2 */ - for (n = 0; n < 4; n++) ocr[n] = rcv_spi(); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - for (tmr = 10000; tmr && send_cmd(ACMD41, 1UL << 30); tmr--) dly_100us(); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (tmr && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = rcv_spi(); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 (HC or SC) */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - for (tmr = 10000; tmr && send_cmd(cmd, 0); tmr--) dly_100us(); /* Wait for leaving idle state */ - if (!tmr || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - DESELECT(); - rcv_spi(); - - return ty ? 0 : STA_NOINIT; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read partial sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_readp ( - BYTE *buff, /* Pointer to the read buffer (NULL:Forward to the stream) */ - DWORD sector, /* Sector number (LBA) */ - UINT offset, /* Byte offset to read from (0..511) */ - UINT count /* Number of bytes to read (ofs + cnt mus be <= 512) */ -) -{ - DRESULT res; - BYTE rc; - UINT bc; - - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - res = RES_ERROR; - if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */ - - bc = 40000; /* Time counter */ - do { /* Wait for data packet */ - rc = rcv_spi(); - } while (rc == 0xFF && --bc); - - if (rc == 0xFE) { /* A data packet arrived */ - - bc = 512 + 2 - offset - count; /* Number of trailing bytes to skip */ - - /* Skip leading bytes */ - while (offset--) rcv_spi(); - - /* Receive a part of the sector */ - if (buff) { /* Store data to the memory */ - do { - *buff++ = rcv_spi(); - } while (--count); - } else { /* Forward data to the outgoing stream */ - do { - FORWARD(rcv_spi()); - } while (--count); - } - - /* Skip trailing bytes and CRC */ - do rcv_spi(); while (--bc); - - res = RES_OK; - } - } - - DESELECT(); - rcv_spi(); - - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write partial sector */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_writep ( - const BYTE *buff, /* Pointer to the bytes to be written (NULL:Initiate/Finalize sector write) */ - DWORD sc /* Number of bytes to send, Sector number (LBA) or zero */ -) -{ - DRESULT res; - UINT bc; - static UINT wc; /* Sector write counter */ - - res = RES_ERROR; - - if (buff) { /* Send data bytes */ - bc = sc; - while (bc && wc) { /* Send data bytes to the card */ - xmit_spi(*buff++); - wc--; bc--; - } - res = RES_OK; - } else { - if (sc) { /* Initiate sector write process */ - if (!(CardType & CT_BLOCK)) sc *= 512; /* Convert to byte address if needed */ - if (send_cmd(CMD24, sc) == 0) { /* WRITE_SINGLE_BLOCK */ - xmit_spi(0xFF); xmit_spi(0xFE); /* Data block header */ - wc = 512; /* Set byte counter */ - res = RES_OK; - } - } else { /* Finalize sector write process */ - bc = wc + 2; - while (bc--) xmit_spi(0); /* Fill left bytes and CRC with zeros */ - if ((rcv_spi() & 0x1F) == 0x05) { /* Receive data resp and wait for end of write process in timeout of 500ms */ - for (bc = 5000; rcv_spi() != 0xFF && bc; bc--) /* Wait for ready */ - dly_100us(); - if (bc) res = RES_OK; - } - DESELECT(); - rcv_spi(); - } - } - - return res; -} -#endif diff --git a/attic/original-pff/diskio.c b/attic/original-pff/diskio.c deleted file mode 100644 index b90e148..0000000 --- a/attic/original-pff/diskio.c +++ /dev/null @@ -1,72 +0,0 @@ -/*-----------------------------------------------------------------------*/ -/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2014 */ -/*-----------------------------------------------------------------------*/ - -#include "diskio.h" - - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize (void) -{ - DSTATUS stat; - - // Put your code here - - return stat; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_readp ( - BYTE* buff, /* Pointer to the destination object */ - DWORD sector, /* Sector number (LBA) */ - UINT offset, /* Offset in the sector */ - UINT count /* Byte count (bit15:destination) */ -) -{ - DRESULT res; - - // Put your code here - - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write Partial Sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_writep ( - BYTE* buff, /* Pointer to the data to be written, NULL:Initiate/Finalize write operation */ - DWORD sc /* Sector number (LBA) or Number of bytes to send */ -) -{ - DRESULT res; - - - if (!buff) { - if (sc) { - - // Initiate write process - - } else { - - // Finalize write process - - } - } else { - - // Send data to the disk - - } - - return res; -} diff --git a/attic/original-pff/diskio.h b/attic/original-pff/diskio.h deleted file mode 100644 index 2599dee..0000000 --- a/attic/original-pff/diskio.h +++ /dev/null @@ -1,42 +0,0 @@ -/*----------------------------------------------------------------------- -/ PFF - Low level disk interface modlue include file (C)ChaN, 2014 -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Function succeeded */ - RES_ERROR, /* 1: Disk error */ - RES_NOTRDY, /* 2: Not ready */ - RES_PARERR /* 3: Invalid parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - -DSTATUS disk_initialize (void); -DRESULT disk_readp (BYTE* buff, DWORD sector, UINT offser, UINT count); -DRESULT disk_writep (const BYTE* buff, DWORD sc); - -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ - -#ifdef __cplusplus -} -#endif - -#endif /* _DISKIO_DEFINED */ diff --git a/attic/original-pff/integer.h b/attic/original-pff/integer.h deleted file mode 100644 index f254b2a..0000000 --- a/attic/original-pff/integer.h +++ /dev/null @@ -1,33 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include - -#else /* Embedded platform */ - -/* This type MUST be 8 bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16 bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 16 bit or 32 bit */ -typedef int INT; -typedef unsigned int UINT; - -/* These types MUST be 32 bit */ -typedef long LONG; -typedef unsigned long DWORD; - -#endif - -#endif diff --git a/attic/original-pff/pff.c b/attic/original-pff/pff.c deleted file mode 100644 index 338fedd..0000000 --- a/attic/original-pff/pff.c +++ /dev/null @@ -1,1107 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module R0.03 (C)ChaN, 2014 -/-----------------------------------------------------------------------------/ -/ Petit FatFs module is a generic FAT file system module for small embedded -/ systems. This is a free software that opened for education, research and -/ commercial developments under license policy of following trems. -/ -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * The Petit FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/-----------------------------------------------------------------------------/ -/ Jun 15,'09 R0.01a First release. -/ -/ Dec 14,'09 R0.02 Added multiple code page support. -/ Added write funciton. -/ Changed stream read mode interface. -/ Dec 07,'10 R0.02a Added some configuration options. -/ Fixed fails to open objects with DBCS character. - -/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. -/ Added _USE_LCC option. -/ Added _FS_FAT16 option. -/----------------------------------------------------------------------------*/ - -#include "pff.h" /* Petit FatFs configurations and declarations */ -#include "diskio.h" /* Declarations of low level disk I/O functions */ - - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - - -#if _PFATFS != 4004 /* Revision ID */ -#error Wrong include file (pff.h). -#endif - -#if _FS_FAT32 -#if !_FS_FAT16 && !_FS_FAT12 -#define _FS_32ONLY 1 -#else -#define _FS_32ONLY 0 -#endif -#else -#if !_FS_FAT16 && !_FS_FAT12 -#error Wrong _FS_FATxx setting. -#endif -#define _FS_32ONLY 0 -#endif - -#define ABORT(err) {fs->flag = 0; return err;} - - - -/*--------------------------------------------------------*/ -/* DBCS code ranges and SBCS extend char conversion table */ -/*--------------------------------------------------------*/ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0x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xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0x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xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#else -#error Unknown code page. - -#endif - - - -/* Character code support macros */ - -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) - -#ifndef _EXCVT /* DBCS configuration */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* SBCS configuration */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _EXCVT */ - - -/* FatFs refers the members in the FAT structures with byte offset instead -/ of structure member because there are incompatibility of the packing option -/ between various compilers. */ - -#define BS_jmpBoot 0 -#define BS_OEMName 3 -#define BPB_BytsPerSec 11 -#define BPB_SecPerClus 13 -#define BPB_RsvdSecCnt 14 -#define BPB_NumFATs 16 -#define BPB_RootEntCnt 17 -#define BPB_TotSec16 19 -#define BPB_Media 21 -#define BPB_FATSz16 22 -#define BPB_SecPerTrk 24 -#define BPB_NumHeads 26 -#define BPB_HiddSec 28 -#define BPB_TotSec32 32 -#define BS_55AA 510 - -#define BS_DrvNum 36 -#define BS_BootSig 38 -#define BS_VolID 39 -#define BS_VolLab 43 -#define BS_FilSysType 54 - -#define BPB_FATSz32 36 -#define BPB_ExtFlags 40 -#define BPB_FSVer 42 -#define BPB_RootClus 44 -#define BPB_FSInfo 48 -#define BPB_BkBootSec 50 -#define BS_DrvNum32 64 -#define BS_BootSig32 66 -#define BS_VolID32 67 -#define BS_VolLab32 71 -#define BS_FilSysType32 82 - -#define MBR_Table 446 - -#define DIR_Name 0 -#define DIR_Attr 11 -#define DIR_NTres 12 -#define DIR_CrtTime 14 -#define DIR_CrtDate 16 -#define DIR_FstClusHI 20 -#define DIR_WrtTime 22 -#define DIR_WrtDate 24 -#define DIR_FstClusLO 26 -#define DIR_FileSize 28 - - - -/*-------------------------------------------------------------------------- - - Private Functions - ----------------------------------------------------------------------------*/ - - -static -FATFS *FatFs; /* Pointer to the file system object (logical drive) */ - - -/* Fill memory */ -static -void mem_set (void* dst, int val, int cnt) { - char *d = (char*)dst; - while (cnt--) *d++ = (char)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, int cnt) { - const char *d = (const char *)dst, *s = (const char *)src; - int r = 0; - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ - -static -CLUST get_fat ( /* 1:IO error, Else:Cluster status */ - CLUST clst /* Cluster# to get the link information */ -) -{ - BYTE buf[4]; - FATFS *fs = FatFs; - - if (clst < 2 || clst >= fs->n_fatent) /* Range check */ - return 1; - - switch (fs->fs_type) { -#if _FS_FAT12 - case FS_FAT12 : { - UINT wc, bc, ofs; - - bc = (UINT)clst; bc += bc / 2; - ofs = bc % 512; bc /= 512; - if (ofs != 511) { - if (disk_readp(buf, fs->fatbase + bc, ofs, 2)) break; - } else { - if (disk_readp(buf, fs->fatbase + bc, 511, 1)) break; - if (disk_readp(buf+1, fs->fatbase + bc + 1, 0, 1)) break; - } - wc = LD_WORD(buf); - return (clst & 1) ? (wc >> 4) : (wc & 0xFFF); - } -#endif -#if _FS_FAT16 - case FS_FAT16 : - if (disk_readp(buf, fs->fatbase + clst / 256, ((UINT)clst % 256) * 2, 2)) break; - return LD_WORD(buf); -#endif -#if _FS_FAT32 - case FS_FAT32 : - if (disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break; - return LD_DWORD(buf) & 0x0FFFFFFF; -#endif - } - - return 1; /* An error occured at the disk I/O layer */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# / Get cluster field from directory entry */ -/*-----------------------------------------------------------------------*/ - -static -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - CLUST clst /* Cluster# to be converted */ -) -{ - FATFS *fs = FatFs; - - - clst -= 2; - if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */ - return (DWORD)clst * fs->csize + fs->database; -} - - -static -CLUST get_clust ( - BYTE* dir /* Pointer to directory entry */ -) -{ - FATFS *fs = FatFs; - CLUST clst = 0; - - - if (_FS_32ONLY || (_FS_FAT32 && fs->fs_type == FS_FAT32)) { - clst = LD_WORD(dir+DIR_FstClusHI); - clst <<= 16; - } - clst |= LD_WORD(dir+DIR_FstClusLO); - - return clst; -} - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Rewind directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_rewind ( - DIR *dj /* Pointer to directory object */ -) -{ - CLUST clst; - FATFS *fs = FatFs; - - - dj->index = 0; - clst = dj->sclust; - if (clst == 1 || clst >= fs->n_fatent) /* Check start cluster range */ - return FR_DISK_ERR; - if (_FS_FAT32 && !clst && (_FS_32ONLY || fs->fs_type == FS_FAT32)) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = (CLUST)fs->dirbase; - dj->clust = clst; /* Current cluster */ - dj->sect = (_FS_32ONLY || clst) ? clust2sect(clst) : fs->dirbase; /* Current sector */ - - return FR_OK; /* Seek succeeded */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table */ - DIR *dj /* Pointer to directory object */ -) -{ - CLUST clst; - WORD i; - FATFS *fs = FatFs; - - - i = dj->index + 1; - if (!i || !dj->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % 16)) { /* Sector changed? */ - dj->sect++; /* Next sector */ - - if (dj->clust == 0) { /* Static table */ - if (i >= fs->n_rootdir) /* Report EOT when end of table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / 16) & (fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dj->clust); /* Get next cluster */ - if (clst <= 1) return FR_DISK_ERR; - if (clst >= fs->n_fatent) /* When it reached end of dynamic table */ - return FR_NO_FILE; /* Report EOT */ - dj->clust = clst; /* Initialize data for new cluster */ - dj->sect = clust2sect(clst); - } - } - } - - dj->index = i; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR *dj, /* Pointer to the directory object linked to the file name */ - BYTE *dir /* 32-byte working buffer */ -) -{ - FRESULT res; - BYTE c; - - - res = dir_rewind(dj); /* Rewind directory object */ - if (res != FR_OK) return res; - - do { - res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ? FR_DISK_ERR : FR_OK; - if (res != FR_OK) break; - c = dir[DIR_Name]; /* First character */ - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dj->fn, 11)) /* Is it a valid entry? */ - break; - res = dir_next(dj); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _USE_DIR -static -FRESULT dir_read ( - DIR *dj, /* Pointer to the directory object to store read object name */ - BYTE *dir /* 32-byte working buffer */ -) -{ - FRESULT res; - BYTE a, c; - - - res = FR_NO_FILE; - while (dj->sect) { - res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ - ? FR_DISK_ERR : FR_OK; - if (res != FR_OK) break; - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; - if (c != 0xE5 && c != '.' && !(a & AM_VOL)) /* Is it a valid entry? */ - break; - res = dir_next(dj); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dj->sect = 0; - - return res; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - - -static -FRESULT create_name ( - DIR *dj, /* Pointer to the directory object */ - const char **path /* Pointer to pointer to the segment in the path string */ -) -{ - BYTE c, ni, si, i, *sfn; - const char *p; -#if _USE_LCC -#ifdef _EXCVT - static const BYTE cvt[] = _EXCVT; -#endif -#endif - - /* Create file name in directory form */ - sfn = dj->fn; - mem_set(sfn, ' ', 11); - si = i = 0; ni = 8; - p = *path; - for (;;) { - c = p[si++]; - if (c <= ' ' || c == '/') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') break; - i = 8; ni = 11; - continue; - } -#if _USE_LCC -#ifdef _EXCVT - if (c >= 0x80) /* To upper extended char (SBCS) */ - c = cvt[c - 0x80]; -#endif - if (IsDBCS1(c) && i < ni - 1) { /* DBC 1st byte? */ - BYTE d = p[si++]; /* Get 2nd byte */ - sfn[i++] = c; - sfn[i++] = d; - } else -#endif - { /* Single byte code */ - if (_USE_LCC && IsLower(c)) c -= 0x20; /* toupper */ - sfn[i++] = c; - } - } - *path = &p[si]; /* Rerurn pointer to the next segment */ - - sfn[11] = (c <= ' ') ? 1 : 0; /* Set last segment flag if end of path */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_DIR -static -void get_fileinfo ( /* No return code */ - DIR *dj, /* Pointer to the directory object */ - BYTE *dir, /* 32-byte working buffer */ - FILINFO *fno /* Pointer to store the file information */ -) -{ - BYTE i, c; - char *p; - - - p = fno->fname; - if (dj->sect) { - for (i = 0; i < 8; i++) { /* Copy file name body */ - c = dir[i]; - if (c == ' ') break; - if (c == 0x05) c = 0xE5; - *p++ = c; - } - if (dir[8] != ' ') { /* Copy file name extension */ - *p++ = '.'; - for (i = 8; i < 11; i++) { - c = dir[i]; - if (c == ' ') break; - *p++ = c; - } - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir+DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir+DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir+DIR_WrtTime); /* Time */ - } - *p = 0; -} -#endif /* _USE_DIR */ - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR *dj, /* Directory object to return last directory and found object */ - BYTE *dir, /* 32-byte working buffer */ - const char *path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - - - while (*path == ' ') path++; /* Strip leading spaces */ - if (*path == '/') path++; /* Strip heading separator if exist */ - dj->sclust = 0; /* Set start directory (always root dir) */ - - if ((BYTE)*path < ' ') { /* Null path means the root directory */ - res = dir_rewind(dj); - dir[0] = 0; - - } else { /* Follow path */ - for (;;) { - res = create_name(dj, &path); /* Get a segment */ - if (res != FR_OK) break; - res = dir_find(dj, dir); /* Find it */ - if (res != FR_OK) break; /* Could not find the object */ - if (dj->fn[11]) break; /* Last segment match. Function completed. */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* Cannot follow path because it is a file */ - res = FR_NO_FILE; break; - } - dj->sclust = get_clust(dir); /* Follow next */ - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check a sector if it is an FAT boot record */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */ - BYTE *buf, /* Working buffer */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - if (disk_readp(buf, sect, 510, 2)) /* Read the boot record */ - return 3; - if (LD_WORD(buf) != 0xAA55) /* Check record signature */ - return 2; - - if (!_FS_32ONLY && !disk_readp(buf, sect, BS_FilSysType, 2) && LD_WORD(buf) == 0x4146) /* Check FAT12/16 */ - return 0; - if (_FS_FAT32 && !disk_readp(buf, sect, BS_FilSysType32, 2) && LD_WORD(buf) == 0x4146) /* Check FAT32 */ - return 0; - return 1; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Locical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_mount ( - FATFS *fs /* Pointer to new file system object */ -) -{ - BYTE fmt, buf[36]; - DWORD bsect, fsize, tsect, mclst; - - - FatFs = 0; - - if (disk_initialize() & STA_NOINIT) /* Check if the drive is ready or not */ - return FR_NOT_READY; - - /* Search FAT partition on the drive */ - bsect = 0; - fmt = check_fs(buf, bsect); /* Check sector 0 as an SFD format */ - if (fmt == 1) { /* Not an FAT boot record, it may be FDISK format */ - /* Check a partition listed in top of the partition table */ - if (disk_readp(buf, bsect, MBR_Table, 16)) { /* 1st partition entry */ - fmt = 3; - } else { - if (buf[4]) { /* Is the partition existing? */ - bsect = LD_DWORD(&buf[8]); /* Partition offset in LBA */ - fmt = check_fs(buf, bsect); /* Check the partition */ - } - } - } - if (fmt == 3) return FR_DISK_ERR; - if (fmt) return FR_NO_FILESYSTEM; /* No valid FAT patition is found */ - - /* Initialize the file system object */ - if (disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR; - - fsize = LD_WORD(buf+BPB_FATSz16-13); /* Number of sectors per FAT */ - if (!fsize) fsize = LD_DWORD(buf+BPB_FATSz32-13); - - fsize *= buf[BPB_NumFATs-13]; /* Number of sectors in FAT area */ - fs->fatbase = bsect + LD_WORD(buf+BPB_RsvdSecCnt-13); /* FAT start sector (lba) */ - fs->csize = buf[BPB_SecPerClus-13]; /* Number of sectors per cluster */ - fs->n_rootdir = LD_WORD(buf+BPB_RootEntCnt-13); /* Nmuber of root directory entries */ - tsect = LD_WORD(buf+BPB_TotSec16-13); /* Number of sectors on the file system */ - if (!tsect) tsect = LD_DWORD(buf+BPB_TotSec32-13); - mclst = (tsect /* Last cluster# + 1 */ - - LD_WORD(buf+BPB_RsvdSecCnt-13) - fsize - fs->n_rootdir / 16 - ) / fs->csize + 2; - fs->n_fatent = (CLUST)mclst; - - fmt = 0; /* Determine the FAT sub type */ - if (_FS_FAT12 && mclst < 0xFF7) - fmt = FS_FAT12; - if (_FS_FAT16 && mclst >= 0xFF8 && mclst < 0xFFF7) - fmt = FS_FAT16; - if (_FS_FAT32 && mclst >= 0xFFF7) - fmt = FS_FAT32; - if (!fmt) return FR_NO_FILESYSTEM; - fs->fs_type = fmt; - - if (_FS_32ONLY || (_FS_FAT32 && fmt == FS_FAT32)) - fs->dirbase = LD_DWORD(buf+(BPB_RootClus-13)); /* Root directory start cluster */ - else - fs->dirbase = fs->fatbase + fsize; /* Root directory start sector (lba) */ - fs->database = fs->fatbase + fsize + fs->n_rootdir / 16; /* Data start sector (lba) */ - - fs->flag = 0; - FatFs = fs; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_open ( - const char *path /* Pointer to the file name */ -) -{ - FRESULT res; - DIR dj; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - - fs->flag = 0; - dj.fn = sp; - res = follow_path(&dj, dir, path); /* Follow the file path */ - if (res != FR_OK) return res; /* Follow failed */ - if (!dir[0] || (dir[DIR_Attr] & AM_DIR)) /* It is a directory */ - return FR_NO_FILE; - - fs->org_clust = get_clust(dir); /* File start cluster */ - fs->fsize = LD_DWORD(dir+DIR_FileSize); /* File size */ - fs->fptr = 0; /* File pointer */ - fs->flag = FA_OPENED; - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ -#if _USE_READ - -FRESULT pf_read ( - void* buff, /* Pointer to the read buffer (NULL:Forward data to the stream)*/ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - DRESULT dr; - CLUST clst; - DWORD sect, remain; - UINT rcnt; - BYTE cs, *rbuff = buff; - FATFS *fs = FatFs; - - - *br = 0; - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) /* Check if opened */ - return FR_NOT_OPENED; - - remain = fs->fsize - fs->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - while (btr) { /* Repeat until all data transferred */ - if ((fs->fptr % 512) == 0) { /* On the sector boundary? */ - cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - if (!cs) { /* On the cluster boundary? */ - if (fs->fptr == 0) /* On the top of the file? */ - clst = fs->org_clust; - else - clst = get_fat(fs->curr_clust); - if (clst <= 1) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs->curr_clust); /* Get current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + cs; - } - rcnt = 512 - (UINT)fs->fptr % 512; /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; - dr = disk_readp(!buff ? 0 : rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt); - if (dr) ABORT(FR_DISK_ERR); - fs->fptr += rcnt; rbuff += rcnt; /* Update pointers and counters */ - btr -= rcnt; *br += rcnt; - } - - return FR_OK; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ -#if _USE_WRITE - -FRESULT pf_write ( - const void* buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write (0:Finalize the current write operation) */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - CLUST clst; - DWORD sect, remain; - const BYTE *p = buff; - BYTE cs; - UINT wcnt; - FATFS *fs = FatFs; - - - *bw = 0; - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) /* Check if opened */ - return FR_NOT_OPENED; - - if (!btw) { /* Finalize request */ - if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); - fs->flag &= ~FA__WIP; - return FR_OK; - } else { /* Write data request */ - if (!(fs->flag & FA__WIP)) /* Round-down fptr to the sector boundary */ - fs->fptr &= 0xFFFFFE00; - } - remain = fs->fsize - fs->fptr; - if (btw > remain) btw = (UINT)remain; /* Truncate btw by remaining bytes */ - - while (btw) { /* Repeat until all data transferred */ - if ((UINT)fs->fptr % 512 == 0) { /* On the sector boundary? */ - cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ - if (!cs) { /* On the cluster boundary? */ - if (fs->fptr == 0) /* On the top of the file? */ - clst = fs->org_clust; - else - clst = get_fat(fs->curr_clust); - if (clst <= 1) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; /* Update current cluster */ - } - sect = clust2sect(fs->curr_clust); /* Get current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + cs; - if (disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR); /* Initiate a sector write operation */ - fs->flag |= FA__WIP; - } - wcnt = 512 - (UINT)fs->fptr % 512; /* Number of bytes to write to the sector */ - if (wcnt > btw) wcnt = btw; - if (disk_writep(p, wcnt)) ABORT(FR_DISK_ERR); /* Send data to the sector */ - fs->fptr += wcnt; p += wcnt; /* Update pointers and counters */ - btw -= wcnt; *bw += wcnt; - if ((UINT)fs->fptr % 512 == 0) { - if (disk_writep(0, 0)) ABORT(FR_DISK_ERR); /* Finalize the currtent secter write operation */ - fs->flag &= ~FA__WIP; - } - } - - return FR_OK; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ -#if _USE_LSEEK - -FRESULT pf_lseek ( - DWORD ofs /* File pointer from top of file */ -) -{ - CLUST clst; - DWORD bcs, sect, ifptr; - FATFS *fs = FatFs; - - - if (!fs) return FR_NOT_ENABLED; /* Check file system */ - if (!(fs->flag & FA_OPENED)) /* Check if opened */ - return FR_NOT_OPENED; - - if (ofs > fs->fsize) ofs = fs->fsize; /* Clip offset with the file size */ - ifptr = fs->fptr; - fs->fptr = 0; - if (ofs > 0) { - bcs = (DWORD)fs->csize * 512; /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fs->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fs->fptr; - clst = fs->curr_clust; - } else { /* When seek to back cluster, */ - clst = fs->org_clust; /* start from the first cluster */ - fs->curr_clust = clst; - } - while (ofs > bcs) { /* Cluster following loop */ - clst = get_fat(clst); /* Follow cluster chain */ - if (clst <= 1 || clst >= fs->n_fatent) ABORT(FR_DISK_ERR); - fs->curr_clust = clst; - fs->fptr += bcs; - ofs -= bcs; - } - fs->fptr += ofs; - sect = clust2sect(clst); /* Current sector */ - if (!sect) ABORT(FR_DISK_ERR); - fs->dsect = sect + (fs->fptr / 512 & (fs->csize - 1)); - } - - return FR_OK; -} -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directroy Object */ -/*-----------------------------------------------------------------------*/ -#if _USE_DIR - -FRESULT pf_opendir ( - DIR *dj, /* Pointer to directory object to create */ - const char *path /* Pointer to the directory path */ -) -{ - FRESULT res; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) { /* Check file system */ - res = FR_NOT_ENABLED; - } else { - dj->fn = sp; - res = follow_path(dj, dir, path); /* Follow the path to the directory */ - if (res == FR_OK) { /* Follow completed */ - if (dir[0]) { /* It is not the root dir */ - if (dir[DIR_Attr] & AM_DIR) /* The object is a directory */ - dj->sclust = get_clust(dir); - else /* The object is not a directory */ - res = FR_NO_FILE; - } - if (res == FR_OK) - res = dir_rewind(dj); /* Rewind dir */ - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entry in Sequense */ -/*-----------------------------------------------------------------------*/ - -FRESULT pf_readdir ( - DIR *dj, /* Pointer to the open directory object */ - FILINFO *fno /* Pointer to file information to return */ -) -{ - FRESULT res; - BYTE sp[12], dir[32]; - FATFS *fs = FatFs; - - - if (!fs) { /* Check file system */ - res = FR_NOT_ENABLED; - } else { - dj->fn = sp; - if (!fno) { - res = dir_rewind(dj); - } else { - res = dir_read(dj, dir); /* Get current directory item */ - if (res == FR_NO_FILE) res = FR_OK; - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dj, dir, fno); /* Get the object information */ - res = dir_next(dj); /* Increment read index for next */ - if (res == FR_NO_FILE) res = FR_OK; - } - } - } - - return res; -} - -#endif /* _USE_DIR */ diff --git a/attic/original-pff/pff.h b/attic/original-pff/pff.h deleted file mode 100644 index 4b55be4..0000000 --- a/attic/original-pff/pff.h +++ /dev/null @@ -1,159 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - FAT file system module include file R0.03 (C)ChaN, 2014 -/----------------------------------------------------------------------------/ -/ Petit FatFs module is an open source software to implement FAT file system to -/ small embedded systems. This is a free software and is opened for education, -/ research and commercial developments under license policy of following trems. -/ -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * The Petit FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/----------------------------------------------------------------------------*/ - -#ifndef _PFATFS -#define _PFATFS 4004 /* Revision ID */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "integer.h" -#include "pffconf.h" - -#if _PFATFS != _PFFCONF -#error Wrong configuration file (pffconf.h). -#endif - -#if _FS_FAT32 -#define CLUST DWORD -#else -#define CLUST WORD -#endif - - -/* File system object structure */ - -typedef struct { - BYTE fs_type; /* FAT sub type */ - BYTE flag; /* File status flags */ - BYTE csize; /* Number of sectors per cluster */ - BYTE pad1; - WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */ - CLUST n_fatent; /* Number of FAT entries (= number of clusters + 2) */ - DWORD fatbase; /* FAT start sector */ - DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */ - DWORD database; /* Data start sector */ - DWORD fptr; /* File R/W pointer */ - DWORD fsize; /* File size */ - CLUST org_clust; /* File start cluster */ - CLUST curr_clust; /* File current cluster */ - DWORD dsect; /* File current data sector */ -} FATFS; - - - -/* Directory object structure */ - -typedef struct { - WORD index; /* Current read/write index number */ - BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ - CLUST sclust; /* Table start cluster (0:Static table) */ - CLUST clust; /* Current cluster */ - DWORD sect; /* Current sector */ -} DIR; - - - -/* File status structure */ - -typedef struct { - DWORD fsize; /* File size */ - WORD fdate; /* Last modified date */ - WORD ftime; /* Last modified time */ - BYTE fattrib; /* Attribute */ - char fname[13]; /* File name */ -} FILINFO; - - - -/* File function return code (FRESULT) */ - -typedef enum { - FR_OK = 0, /* 0 */ - FR_DISK_ERR, /* 1 */ - FR_NOT_READY, /* 2 */ - FR_NO_FILE, /* 3 */ - FR_NOT_OPENED, /* 4 */ - FR_NOT_ENABLED, /* 5 */ - FR_NO_FILESYSTEM /* 6 */ -} FRESULT; - - - -/*--------------------------------------------------------------*/ -/* Petit FatFs module application interface */ - -FRESULT pf_mount (FATFS* fs); /* Mount/Unmount a logical drive */ -FRESULT pf_open (const char* path); /* Open a file */ -FRESULT pf_read (void* buff, UINT btr, UINT* br); /* Read data from the open file */ -FRESULT pf_write (const void* buff, UINT btw, UINT* bw); /* Write data to the open file */ -FRESULT pf_lseek (DWORD ofs); /* Move file pointer of the open file */ -FRESULT pf_opendir (DIR* dj, const char* path); /* Open a directory */ -FRESULT pf_readdir (DIR* dj, FILINFO* fno); /* Read a directory item from the open directory */ - - - -/*--------------------------------------------------------------*/ -/* Flags and offset address */ - -/* File status flag (FATFS.flag) */ - -#define FA_OPENED 0x01 -#define FA_WPRT 0x02 -#define FA__WIP 0x40 - - -/* FAT sub type (FATFS.fs_type) */ - -#define FS_FAT12 1 -#define FS_FAT16 2 -#define FS_FAT32 3 - - -/* File attribute bits for directory entry */ - -#define AM_RDO 0x01 /* Read only */ -#define AM_HID 0x02 /* Hidden */ -#define AM_SYS 0x04 /* System */ -#define AM_VOL 0x08 /* Volume label */ -#define AM_LFN 0x0F /* LFN entry */ -#define AM_DIR 0x10 /* Directory */ -#define AM_ARC 0x20 /* Archive */ -#define AM_MASK 0x3F /* Mask of defined bits */ - - -/*--------------------------------*/ -/* Multi-byte word access macros */ - -#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val) -#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val) -#else /* Use byte-by-byte access to the FAT structure */ -#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr)) -#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr)) -#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8) -#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24) -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* _PFATFS */ diff --git a/attic/original-pff/pffconf.h b/attic/original-pff/pffconf.h deleted file mode 100644 index c09c9fd..0000000 --- a/attic/original-pff/pffconf.h +++ /dev/null @@ -1,89 +0,0 @@ -/*---------------------------------------------------------------------------/ -/ Petit FatFs - Configuration file R0.03 (C)ChaN, 2014 -/---------------------------------------------------------------------------*/ - -#ifndef _PFFCONF -#define _PFFCONF 4004 /* Revision ID */ - -/*---------------------------------------------------------------------------/ -/ Function Configurations -/---------------------------------------------------------------------------*/ - -#define _USE_READ 1 /* Enable pf_read() function */ -#define _USE_DIR 0 /* Enable pf_opendir() and pf_readdir() function */ -#define _USE_LSEEK 0 /* Enable pf_lseek() function */ -#define _USE_WRITE 0 /* Enable pf_write() function */ - -#define _FS_FAT12 0 /* Enable FAT12 */ -#define _FS_FAT16 1 /* Enable FAT16 */ -#define _FS_FAT32 0 /* Enable FAT32 */ - - -/*---------------------------------------------------------------------------/ -/ Locale and Namespace Configurations -/---------------------------------------------------------------------------*/ - -#define _USE_LCC 0 /* Allow lower case characters for path name */ - -#define _CODE_PAGE 437 -/* The _CODE_PAGE specifies the code page to be used on the target system. -/ SBCS code pages with _USE_LCC == 1 requiers a 128 byte of case conversion -/ table. This might occupy RAM on some platforms, e.g. avr-gcc. -/ When _USE_LCC == 0, _CODE_PAGE has no effect. -/ -/ 932 - Japanese Shift_JIS (DBCS, OEM, Windows) -/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows) -/ 949 - Korean (DBCS, OEM, Windows) -/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows) -/ 1250 - Central Europe (Windows) -/ 1251 - Cyrillic (Windows) -/ 1252 - Latin 1 (Windows) -/ 1253 - Greek (Windows) -/ 1254 - Turkish (Windows) -/ 1255 - Hebrew (Windows) -/ 1256 - Arabic (Windows) -/ 1257 - Baltic (Windows) -/ 1258 - Vietnam (OEM, Windows) -/ 437 - U.S. (OEM) -/ 720 - Arabic (OEM) -/ 737 - Greek (OEM) -/ 775 - Baltic (OEM) -/ 850 - Multilingual Latin 1 (OEM) -/ 858 - Multilingual Latin 1 + Euro (OEM) -/ 852 - Latin 2 (OEM) -/ 855 - Cyrillic (OEM) -/ 866 - Russian (OEM) -/ 857 - Turkish (OEM) -/ 862 - Hebrew (OEM) -/ 874 - Thai (OEM, Windows) -*/ - - -/*---------------------------------------------------------------------------/ -/ System Configurations -/---------------------------------------------------------------------------*/ - -#define _WORD_ACCESS 0 -/* The _WORD_ACCESS option is an only platform dependent option. It defines -/ which access method is used to the word data on the FAT volume. -/ -/ 0: Byte-by-byte access. Always compatible with all platforms. -/ 1: Word access. Do not choose this unless under both the following conditions. -/ -/ * Address misaligned memory access is always allowed for ALL instructions. -/ * Byte order on the memory is little-endian. -/ -/ If it is the case, _WORD_ACCESS can also be set to 1 to improve performance and -/ reduce code size. Following table shows an example of some processor types. -/ -/ ARM7TDMI 0 ColdFire 0 V850E 0 -/ Cortex-M3 0 Z80 0/1 V850ES 0/1 -/ Cortex-M0 0 RX600(LE) 0/1 TLCS-870 0/1 -/ AVR 0/1 RX600(BE) 0 TLCS-900 0/1 -/ AVR32 0 RL78 0 R32C 0 -/ PIC18 0/1 SH-2 0 M16C 0/1 -/ PIC24 0 H8S 0 MSP430 0 -/ PIC32 0 H8/300H 0 x86 0/1 -*/ - -#endif /* _PFFCONF */ diff --git a/attic/original-pff/pic24_mmcp.c b/attic/original-pff/pic24_mmcp.c deleted file mode 100644 index e6170d9..0000000 --- a/attic/original-pff/pic24_mmcp.c +++ /dev/null @@ -1,290 +0,0 @@ -/*-------------------------------------------------------------------------*/ -/* PFF - Low level disk control module for PIC (C)ChaN, 2014 */ -/*-------------------------------------------------------------------------*/ - -#include "pff.h" -#include "diskio.h" -#include "uart.h" - -/*-------------------------------------------------------------------------*/ -/* Platform dependent macros and functions needed to be modified */ -/*-------------------------------------------------------------------------*/ - -#include /* Device include file */ -#include "pic24f.h" -#include "uart.h" - -#define SELECT() _LATB15 = 0 /* CS = L */ -#define DESELECT() _LATB15 = 1 /* CS = H */ -#define MMC_SEL !_LATB15 /* CS status (true:CS == L) */ -#define FORWARD(d) uart_put(d) /* Data forwarding function (Console out in this example) */ - -static -void init_spi (void) /* Initialize SPI port */ -{ - SPI1CON1 = 0x013B; - SPI1CON2 = 0x0000; - _SPIEN = 1; -} - -void dly_100us (void) /* Delay 100 microseconds */ -{ - UINT n = FCY / 100000; - do { - LATA; LATA; LATA; LATA; LATA; LATA; - } while (--n); -} - -static -void xmit_spi (BYTE d) /* Send a byte to the SDC/MMC */ -{ - SPI1BUF = d; - while (!_SPIRBF) ; - SPI1BUF; -} - -static -BYTE rcv_spi (void) /* Send a 0xFF to the SDC/MMC and get the received byte */ -{ - SPI1BUF = 0xFF; - while (!_SPIRBF) ; - return (BYTE)SPI1BUF; -} - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - -/* Definitions for MMC/SDC command */ -#define CMD0 (0x40+0) /* GO_IDLE_STATE */ -#define CMD1 (0x40+1) /* SEND_OP_COND (MMC) */ -#define ACMD41 (0xC0+41) /* SEND_OP_COND (SDC) */ -#define CMD8 (0x40+8) /* SEND_IF_COND */ -#define CMD16 (0x40+16) /* SET_BLOCKLEN */ -#define CMD17 (0x40+17) /* READ_SINGLE_BLOCK */ -#define CMD24 (0x40+24) /* WRITE_BLOCK */ -#define CMD55 (0x40+55) /* APP_CMD */ -#define CMD58 (0x40+58) /* READ_OCR */ - - -/* Card type flags (CardType) */ -#define CT_MMC 0x01 /* MMC ver 3 */ -#define CT_SD1 0x02 /* SD ver 1 */ -#define CT_SD2 0x04 /* SD ver 2 */ -#define CT_BLOCK 0x08 /* Block addressing */ - - -static -BYTE CardType; - - -/*-----------------------------------------------------------------------*/ -/* Send a command packet to the SDC/MMC */ -/*-----------------------------------------------------------------------*/ - -static -BYTE send_cmd ( - BYTE cmd, /* 1st byte (Start + Index) */ - DWORD arg /* Argument (32 bits) */ -) -{ - BYTE n, res; - - - if (cmd & 0x80) { /* ACMD is the command sequense of CMD55-CMD */ - cmd &= 0x7F; - res = send_cmd(CMD55, 0); - if (res > 1) return res; - } - - /* Select the card */ - DESELECT(); - rcv_spi(); - SELECT(); - rcv_spi(); - - /* Send a command packet */ - xmit_spi(cmd); /* Start + Command index */ - xmit_spi((BYTE)(arg >> 24)); /* Argument[31..24] */ - xmit_spi((BYTE)(arg >> 16)); /* Argument[23..16] */ - xmit_spi((BYTE)(arg >> 8)); /* Argument[15..8] */ - xmit_spi((BYTE)arg); /* Argument[7..0] */ - n = 0x01; /* Dummy CRC + Stop */ - if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */ - if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */ - xmit_spi(n); - - /* Receive a command response */ - n = 10; /* Wait for a valid response in timeout of 10 attempts */ - do { - res = rcv_spi(); - } while ((res & 0x80) && --n); - - return res; /* Return with the response value */ -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ----------------------------------------------------------------------------*/ - -/*-----------------------------------------------------------------------*/ -/* Initialize Disk Drive */ -/*-----------------------------------------------------------------------*/ - -DSTATUS disk_initialize (void) -{ - BYTE n, cmd, ty, ocr[4]; - UINT tmr; - -#if _USE_WRITE - if (CardType && MMC_SEL) disk_writep(0, 0); /* Finalize write process if it is in progress */ -#endif - init_spi(); /* Initialize ports to control SDC/MMC */ - DESELECT(); - for (n = 10; n; n--) rcv_spi(); /* 80 Dummy clocks with CS=H */ - - ty = 0; - if (send_cmd(CMD0, 0) == 1) { /* Enter Idle state */ - if (send_cmd(CMD8, 0x1AA) == 1) { /* SDv2 */ - for (n = 0; n < 4; n++) ocr[n] = rcv_spi(); /* Get trailing return value of R7 resp */ - if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* The card can work at vdd range of 2.7-3.6V */ - for (tmr = 10000; tmr && send_cmd(ACMD41, 1UL << 30); tmr--) dly_100us(); /* Wait for leaving idle state (ACMD41 with HCS bit) */ - if (tmr && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */ - for (n = 0; n < 4; n++) ocr[n] = rcv_spi(); - ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* SDv2 (HC or SC) */ - } - } - } else { /* SDv1 or MMCv3 */ - if (send_cmd(ACMD41, 0) <= 1) { - ty = CT_SD1; cmd = ACMD41; /* SDv1 */ - } else { - ty = CT_MMC; cmd = CMD1; /* MMCv3 */ - } - for (tmr = 10000; tmr && send_cmd(cmd, 0); tmr--) dly_100us(); /* Wait for leaving idle state */ - if (!tmr || send_cmd(CMD16, 512) != 0) /* Set R/W block length to 512 */ - ty = 0; - } - } - CardType = ty; - DESELECT(); - rcv_spi(); - - return ty ? 0 : STA_NOINIT; -} - - - -/*-----------------------------------------------------------------------*/ -/* Read partial sector */ -/*-----------------------------------------------------------------------*/ - -DRESULT disk_readp ( - BYTE *buff, /* Pointer to the read buffer (NULL:Read bytes are forwarded to the stream) */ - DWORD sector, /* Sector number (LBA) */ - UINT offset, /* Byte offset to read from (0..511) */ - UINT count /* Number of bytes to read (ofs + cnt mus be <= 512) */ -) -{ - DRESULT res; - BYTE rc; - UINT bc; - - - if (!(CardType & CT_BLOCK)) sector *= 512; /* Convert to byte address if needed */ - - res = RES_ERROR; - if (send_cmd(CMD17, sector) == 0) { /* READ_SINGLE_BLOCK */ - - bc = 40000; - do { /* Wait for data packet */ - rc = rcv_spi(); - } while (rc == 0xFF && --bc); - - if (rc == 0xFE) { /* A data packet arrived */ - bc = 514 - offset - count; - - /* Skip leading bytes */ - if (offset) { - do rcv_spi(); while (--offset); - } - - /* Receive a part of the sector */ - if (buff) { /* Store data to the memory */ - do { - *buff++ = rcv_spi(); - } while (--count); - } else { /* Forward data to the outgoing stream (depends on the project) */ - do { - FORWARD(rcv_spi()); - } while (--count); - } - - /* Skip remaining bytes and CRC */ - do rcv_spi(); while (--bc); - - res = RES_OK; - } - } - - DESELECT(); - rcv_spi(); - - return res; -} - - - -/*-----------------------------------------------------------------------*/ -/* Write partial sector */ -/*-----------------------------------------------------------------------*/ - -#if _USE_WRITE -DRESULT disk_writep ( - const BYTE *buff, /* Pointer to the bytes to be written (NULL:Initiate/Finalize sector write) */ - DWORD sc /* Number of bytes to send, Sector number (LBA) or zero */ -) -{ - DRESULT res; - UINT bc; - static WORD wc; - - res = RES_ERROR; - - if (buff) { /* Send data bytes */ - bc = (WORD)sc; - while (bc && wc) { /* Send data bytes to the card */ - xmit_spi(*buff++); - wc--; bc--; - } - res = RES_OK; - } else { - if (sc) { /* Initiate sector write process */ - if (!(CardType & CT_BLOCK)) sc *= 512; /* Convert to byte address if needed */ - if (send_cmd(CMD24, sc) == 0) { /* WRITE_SINGLE_BLOCK */ - xmit_spi(0xFF); xmit_spi(0xFE); /* Data block header */ - wc = 512; /* Set byte counter */ - res = RES_OK; - } - } else { /* Finalize sector write process */ - bc = wc + 2; - while (bc--) xmit_spi(0); /* Fill left bytes and CRC with zeros */ - if ((rcv_spi() & 0x1F) == 0x05) { /* Receive data resp and wait for end of write process in timeout of 500ms */ - for (bc = 5000; rcv_spi() != 0xFF && bc; bc--) dly_100us(); /* Wait ready */ - if (bc) res = RES_OK; - } - DESELECT(); - rcv_spi(); - } - } - - return res; -} -#endif