kinve 10 éve
szülő
commit
12eefe0e70
100 módosított fájl, 8464 hozzáadás és 0 törlés
  1. 191 0
      .gitattributes
  2. 25 0
      app/Astyle.bat
  3. 213 0
      app/DHT11.c
  4. 32 0
      app/DHT11.h
  5. 492 0
      app/DMA/SPI_DMA.c
  6. 115 0
      app/DMA/SPI_DMA.h
  7. 83 0
      app/DMA/UART_DMA.C
  8. 21 0
      app/DMA/UART_DMA.h
  9. 134 0
      app/DMA/UART_DMA_1.C
  10. 666 0
      app/DMA/common.c
  11. 60 0
      app/DMA/common.h
  12. 312 0
      app/DMA/flash.c
  13. 65 0
      app/DMA/flash.h
  14. 96 0
      app/Delay.c
  15. 35 0
      app/Delay.h
  16. 114 0
      app/FatFS/doc/00index_e.html
  17. 113 0
      app/FatFS/doc/00index_j.html
  18. 59 0
      app/FatFS/doc/css_e.css
  19. 62 0
      app/FatFS/doc/css_j.css
  20. 250 0
      app/FatFS/doc/en/appnote.html
  21. 81 0
      app/FatFS/doc/en/chdir.html
  22. 60 0
      app/FatFS/doc/en/chdrive.html
  23. 89 0
      app/FatFS/doc/en/chmod.html
  24. 65 0
      app/FatFS/doc/en/close.html
  25. 46 0
      app/FatFS/doc/en/dinit.html
  26. 69 0
      app/FatFS/doc/en/dioctl.html
  27. 59 0
      app/FatFS/doc/en/dread.html
  28. 48 0
      app/FatFS/doc/en/dstat.html
  29. 67 0
      app/FatFS/doc/en/dwrite.html
  30. 62 0
      app/FatFS/doc/en/eof.html
  31. 62 0
      app/FatFS/doc/en/error.html
  32. 51 0
      app/FatFS/doc/en/fattime.html
  33. 97 0
      app/FatFS/doc/en/fdisk.html
  34. 74 0
      app/FatFS/doc/en/filename.html
  35. 139 0
      app/FatFS/doc/en/forward.html
  36. 70 0
      app/FatFS/doc/en/getcwd.html
  37. 96 0
      app/FatFS/doc/en/getfree.html
  38. 65 0
      app/FatFS/doc/en/gets.html
  39. 128 0
      app/FatFS/doc/en/lseek.html
  40. 80 0
      app/FatFS/doc/en/mkdir.html
  41. 73 0
      app/FatFS/doc/en/mkfs.html
  42. 64 0
      app/FatFS/doc/en/mount.html
  43. 139 0
      app/FatFS/doc/en/open.html
  44. 73 0
      app/FatFS/doc/en/opendir.html
  45. 90 0
      app/FatFS/doc/en/printf.html
  46. 62 0
      app/FatFS/doc/en/putc.html
  47. 62 0
      app/FatFS/doc/en/puts.html
  48. 86 0
      app/FatFS/doc/en/rc.html
  49. 74 0
      app/FatFS/doc/en/read.html
  50. 119 0
      app/FatFS/doc/en/readdir.html
  51. 84 0
      app/FatFS/doc/en/rename.html
  52. 37 0
      app/FatFS/doc/en/sdir.html
  53. 54 0
      app/FatFS/doc/en/sfatfs.html
  54. 49 0
      app/FatFS/doc/en/sfile.html
  55. 70 0
      app/FatFS/doc/en/sfileinfo.html
  56. 62 0
      app/FatFS/doc/en/size.html
  57. 68 0
      app/FatFS/doc/en/stat.html
  58. 65 0
      app/FatFS/doc/en/sync.html
  59. 62 0
      app/FatFS/doc/en/tell.html
  60. 66 0
      app/FatFS/doc/en/truncate.html
  61. 76 0
      app/FatFS/doc/en/unlink.html
  62. 99 0
      app/FatFS/doc/en/utime.html
  63. 74 0
      app/FatFS/doc/en/write.html
  64. BIN
      app/FatFS/doc/img/Thumbs.db
  65. BIN
      app/FatFS/doc/img/f1.png
  66. BIN
      app/FatFS/doc/img/f2.png
  67. BIN
      app/FatFS/doc/img/f3.png
  68. BIN
      app/FatFS/doc/img/f4.png
  69. BIN
      app/FatFS/doc/img/f5.png
  70. BIN
      app/FatFS/doc/img/f6.png
  71. BIN
      app/FatFS/doc/img/layers.png
  72. BIN
      app/FatFS/doc/img/layers3.png
  73. BIN
      app/FatFS/doc/img/rwtest.png
  74. BIN
      app/FatFS/doc/img/rwtest2.png
  75. BIN
      app/FatFS/doc/img/rwtest3.png
  76. 255 0
      app/FatFS/doc/ja/appnote.html
  77. 81 0
      app/FatFS/doc/ja/chdir.html
  78. 61 0
      app/FatFS/doc/ja/chdrive.html
  79. 89 0
      app/FatFS/doc/ja/chmod.html
  80. 65 0
      app/FatFS/doc/ja/close.html
  81. 46 0
      app/FatFS/doc/ja/dinit.html
  82. 68 0
      app/FatFS/doc/ja/dioctl.html
  83. 59 0
      app/FatFS/doc/ja/dread.html
  84. 48 0
      app/FatFS/doc/ja/dstat.html
  85. 67 0
      app/FatFS/doc/ja/dwrite.html
  86. 62 0
      app/FatFS/doc/ja/eof.html
  87. 62 0
      app/FatFS/doc/ja/error.html
  88. 51 0
      app/FatFS/doc/ja/fattime.html
  89. 97 0
      app/FatFS/doc/ja/fdisk.html
  90. 71 0
      app/FatFS/doc/ja/filename.html
  91. 140 0
      app/FatFS/doc/ja/forward.html
  92. 70 0
      app/FatFS/doc/ja/getcwd.html
  93. 96 0
      app/FatFS/doc/ja/getfree.html
  94. 65 0
      app/FatFS/doc/ja/gets.html
  95. 130 0
      app/FatFS/doc/ja/lseek.html
  96. 80 0
      app/FatFS/doc/ja/mkdir.html
  97. 73 0
      app/FatFS/doc/ja/mkfs.html
  98. 64 0
      app/FatFS/doc/ja/mount.html
  99. 137 0
      app/FatFS/doc/ja/open.html
  100. 73 0
      app/FatFS/doc/ja/opendir.html

+ 191 - 0
.gitattributes

@@ -1 +1,192 @@
 * text=auto !eol
+app/Astyle.bat -text
+app/DHT11.c -text
+app/DHT11.h -text
+app/DMA/SPI_DMA.c -text
+app/DMA/SPI_DMA.h -text
+app/DMA/UART_DMA.C -text
+app/DMA/UART_DMA.h -text
+app/DMA/UART_DMA_1.C -text
+app/DMA/common.c -text
+app/DMA/common.h -text
+app/DMA/flash.c -text
+app/DMA/flash.h -text
+app/Delay.c -text
+app/Delay.h -text
+app/FatFS/doc/00index_e.html -text
+app/FatFS/doc/00index_j.html -text
+app/FatFS/doc/css_e.css -text
+app/FatFS/doc/css_j.css -text
+app/FatFS/doc/en/appnote.html -text
+app/FatFS/doc/en/chdir.html -text
+app/FatFS/doc/en/chdrive.html -text
+app/FatFS/doc/en/chmod.html -text
+app/FatFS/doc/en/close.html -text
+app/FatFS/doc/en/dinit.html -text
+app/FatFS/doc/en/dioctl.html -text
+app/FatFS/doc/en/dread.html -text
+app/FatFS/doc/en/dstat.html -text
+app/FatFS/doc/en/dwrite.html -text
+app/FatFS/doc/en/eof.html -text
+app/FatFS/doc/en/error.html -text
+app/FatFS/doc/en/fattime.html -text
+app/FatFS/doc/en/fdisk.html -text
+app/FatFS/doc/en/filename.html -text
+app/FatFS/doc/en/forward.html -text
+app/FatFS/doc/en/getcwd.html -text
+app/FatFS/doc/en/getfree.html -text
+app/FatFS/doc/en/gets.html -text
+app/FatFS/doc/en/lseek.html -text
+app/FatFS/doc/en/mkdir.html -text
+app/FatFS/doc/en/mkfs.html -text
+app/FatFS/doc/en/mount.html -text
+app/FatFS/doc/en/open.html -text
+app/FatFS/doc/en/opendir.html -text
+app/FatFS/doc/en/printf.html -text
+app/FatFS/doc/en/putc.html -text
+app/FatFS/doc/en/puts.html -text
+app/FatFS/doc/en/rc.html -text
+app/FatFS/doc/en/read.html -text
+app/FatFS/doc/en/readdir.html -text
+app/FatFS/doc/en/rename.html -text
+app/FatFS/doc/en/sdir.html -text
+app/FatFS/doc/en/sfatfs.html -text
+app/FatFS/doc/en/sfile.html -text
+app/FatFS/doc/en/sfileinfo.html -text
+app/FatFS/doc/en/size.html -text
+app/FatFS/doc/en/stat.html -text
+app/FatFS/doc/en/sync.html -text
+app/FatFS/doc/en/tell.html -text
+app/FatFS/doc/en/truncate.html -text
+app/FatFS/doc/en/unlink.html -text
+app/FatFS/doc/en/utime.html -text
+app/FatFS/doc/en/write.html -text
+app/FatFS/doc/img/Thumbs.db -text
+app/FatFS/doc/img/f1.png -text
+app/FatFS/doc/img/f2.png -text
+app/FatFS/doc/img/f3.png -text
+app/FatFS/doc/img/f4.png -text
+app/FatFS/doc/img/f5.png -text
+app/FatFS/doc/img/f6.png -text
+app/FatFS/doc/img/layers.png -text
+app/FatFS/doc/img/layers3.png -text
+app/FatFS/doc/img/rwtest.png -text
+app/FatFS/doc/img/rwtest2.png -text
+app/FatFS/doc/img/rwtest3.png -text
+app/FatFS/doc/ja/appnote.html -text
+app/FatFS/doc/ja/chdir.html -text
+app/FatFS/doc/ja/chdrive.html -text
+app/FatFS/doc/ja/chmod.html -text
+app/FatFS/doc/ja/close.html -text
+app/FatFS/doc/ja/dinit.html -text
+app/FatFS/doc/ja/dioctl.html -text
+app/FatFS/doc/ja/dread.html -text
+app/FatFS/doc/ja/dstat.html -text
+app/FatFS/doc/ja/dwrite.html -text
+app/FatFS/doc/ja/eof.html -text
+app/FatFS/doc/ja/error.html -text
+app/FatFS/doc/ja/fattime.html -text
+app/FatFS/doc/ja/fdisk.html -text
+app/FatFS/doc/ja/filename.html -text
+app/FatFS/doc/ja/forward.html -text
+app/FatFS/doc/ja/getcwd.html -text
+app/FatFS/doc/ja/getfree.html -text
+app/FatFS/doc/ja/gets.html -text
+app/FatFS/doc/ja/lseek.html -text
+app/FatFS/doc/ja/mkdir.html -text
+app/FatFS/doc/ja/mkfs.html -text
+app/FatFS/doc/ja/mount.html -text
+app/FatFS/doc/ja/open.html -text
+app/FatFS/doc/ja/opendir.html -text
+app/FatFS/doc/ja/printf.html -text
+app/FatFS/doc/ja/putc.html -text
+app/FatFS/doc/ja/puts.html -text
+app/FatFS/doc/ja/rc.html -text
+app/FatFS/doc/ja/read.html -text
+app/FatFS/doc/ja/readdir.html -text
+app/FatFS/doc/ja/rename.html -text
+app/FatFS/doc/ja/sdir.html -text
+app/FatFS/doc/ja/sfatfs.html -text
+app/FatFS/doc/ja/sfile.html -text
+app/FatFS/doc/ja/sfileinfo.html -text
+app/FatFS/doc/ja/size.html -text
+app/FatFS/doc/ja/stat.html -text
+app/FatFS/doc/ja/sync.html -text
+app/FatFS/doc/ja/tell.html -text
+app/FatFS/doc/ja/truncate.html -text
+app/FatFS/doc/ja/unlink.html -text
+app/FatFS/doc/ja/utime.html -text
+app/FatFS/doc/ja/write.html -text
+app/FatFS/doc/updates.txt -text
+app/FatFS/src/00readme.txt -text
+app/FatFS/src/diskio.c -text
+app/FatFS/src/diskio.h -text
+app/FatFS/src/ff.c -text
+app/FatFS/src/ff.h -text
+app/FatFS/src/ffconf.h -text
+app/FatFS/src/integer.h -text
+app/FatFS/src/option/cc932.c -text
+app/FatFS/src/option/cc936.c -text
+app/FatFS/src/option/cc949.c -text
+app/FatFS/src/option/cc950.c -text
+app/FatFS/src/option/ccsbcs.c -text
+app/FatFS/src/option/syscall.c -text
+app/Key.c -text
+app/Key.h -text
+app/SPI-SD/Fatfs/diskio.c -text
+app/SPI-SD/Fatfs/diskio.h -text
+app/SPI-SD/Fatfs/ff.c -text
+app/SPI-SD/Fatfs/ff.h -text
+app/SPI-SD/Fatfs/integer.h -text
+app/SPI-SD/Lcd/107_32_Driver_IO16.c -text
+app/SPI-SD/Lcd/107_32_Driver_IO16.h -text
+app/SPI-SD/Lcd/Bitmap.h -text
+app/SPI-SD/Lcd/Font16_16.h -text
+app/SPI-SD/Lcd/Font6_8.h -text
+app/SPI-SD/Lcd/Font8_16.h -text
+app/SPI-SD/Lcd/Icon10_8.h -text
+app/SPI-SD/Lcd/alt_types.h -text
+app/SPI-SD/Lcd/font.h -text
+app/SPI-SD/Lcd/lcd_5110_solution.c -text
+app/SPI-SD/Lcd/lcd_5110_solution.h -text
+app/SPI-SD/SD/sddriver.c -text
+app/SPI-SD/SD/sddriver.h -text
+app/SPI-SD/SD卡字库文件/sys/HZK16.bin -text
+app/TEA5767_i2c.c -text
+app/TEA5767_main.c -text
+app/TEA5767_main.h -text
+app/TIM5_Delay.c -text
+app/TIM5_Delay.h -text
+app/Uart1.c -text
+app/Uart1.h -text
+app/YX5200/YX5200_Log.c -text
+app/YX5200/YX5200_MSG.h -text
+app/YX5200/YX5200_main.c -text
+app/YX5200/YX5200_main.c~RF2aa021d.TMP -text
+app/YX5200/YX5200_main.h -text
+app/YX5200/YX5200_uart.c -text
+app/YX5200/YX5200_uart.h -text
+app/bmp_pixel.h -text
+app/ds1302.c -text
+app/ds1302.h -text
+app/ds1302_config.h -text
+app/english_6x8_pixel.h -text
+app/led.c -text
+app/led.h -text
+app/main.c -text
+app/main.h -text
+app/nokia_5110.c -text
+app/nokia_5110.h -text
+app/stm32f10x_conf.h -text
+app/stm32f10x_it.c -text
+app/stm32f10x_it.h -text
+app/sys.c -text
+app/sys.h -text
+app/tim.c -text
+app/tim.h -text
+app/tim3.c -text
+app/wifi9113.c -text
+app/wifi9113.h -text
+app/wifi_gpio_conf.c -text
+app/wifi_gpio_conf.h -text
+app/write_chinese_string_pixel.h -text

+ 25 - 0
app/Astyle.bat

@@ -0,0 +1,25 @@
+@echo [email protected]
+
+@echo 批量将本目录中的所有C++文件用Astyle进行代码美化操作
+
+@echo 2009-01-05
+
+@echo 设置Astyle命令位置和参数
+
+@echo off
+
+set astyle="D:\Program Files\Source Insight 3\AStyle\bin\astyle.exe"
+
+
+
+@echo 循环遍历目录
+
+for /r . %%a in (*.cpp;*.c) do %astyle% --style=ansi  -f  -p -P -U -v -n -N "%%a"
+
+for /r . %%a in (*.hpp;*.h) do %astyle% --style=ansi  -f  -p -P -U -v -n -N "%%a"
+
+REM 删除所有的astyle生成文件
+
+for /r . %%a in (*.orig) do del "%%a"
+
+pause

+ 213 - 0
app/DHT11.c

@@ -0,0 +1,213 @@
+#include "stm32f10x.h"
+#include "Delay.h"
+#include "DHT11.h"
+#include "sys.h"
+//unsigned char  humidity, temperature, check_sum ;
+
+
+//全局变量定义区
+//***************************************************************************/
+//      //uchar       i;
+//      uchar    U8FLAG,k;
+//      uchar    U8count,U8temp;
+//      uchar    U8T_data_H,U8T_data_L,U8RH_data_H,U8RH_data_L,U8checkdata;
+//      uchar    U8T_data_H_temp,U8T_data_L_temp,U8RH_data_H_temp,U8RH_data_L_temp,U8checkdata_temp;
+//      uchar    U8comdata;
+//      uint   ReceiveHighByte;
+//      uint   ReceiveLowByte;
+//***************Global defination for DHT11 end****//
+void DHT11_PortIN ( void )
+{
+    GPIO_InitTypeDef  GPIO_InitStructure;
+
+    RCC_APB2PeriphClockCmd ( DHT11_IORCC, ENABLE );
+
+    //切换为输入口
+    GPIO_InitStructure.GPIO_Pin = DHT11_DATA_PIN;
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
+    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+    GPIO_Init ( DHT11_PORT, &GPIO_InitStructure );
+
+}
+void DHT11_PortOUT ( void )
+{
+    GPIO_InitTypeDef  GPIO_InitStructure;
+
+    RCC_APB2PeriphClockCmd ( DHT11_IORCC, ENABLE );
+
+    GPIO_InitStructure.GPIO_Pin = ( DHT11_DATA_PIN );
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;	  //推挽输出
+    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+    GPIO_Init ( DHT11_PORT, &GPIO_InitStructure );
+}
+
+static u8 _us = 0;
+unsigned char StartDHT11 ( void )
+{
+
+    //主机开始信号
+    /*
+    	低18ms->高30us->等待dht响应(拉低)
+    */
+    DHT11_PortOUT();
+    DHT11_Out = 0;
+    delay_ms ( 18 );  	//触发开始,总线拉低要大于18ms
+    DHT11_Out = 1;	//释放总线
+    //delay_us(30);	//拉低 20-40uS 等待DHT11的低电平响应信号
+
+    //dht响应
+    /*
+    	正确,拉低(80us) ->拉高(80us)->传送数据
+    */
+    DHT11_PortIN(); //改为输入
+
+    //实际6
+    _us = 0;
+
+    while ( DHT11_In ) //低电平的响应信号,20-40uS
+    {
+        if ( ++_us > 40 )
+        {
+            return 0;
+        }
+
+        delay_us ( 1 );
+    }
+
+    //实际53
+    _us = 0;
+
+    while ( !DHT11_In ) //低电平的响应信号,80us
+    {
+        if ( ++_us > 80 )
+        {
+            return 0;
+        }
+
+        delay_us ( 1 );
+    }
+
+    //实际54
+    _us = 0;
+
+    while ( DHT11_In ) //紧接着是80us的高电平数据准备信号
+    {
+        if ( ++_us > 80 )
+        {
+            return 0;
+        }
+
+        delay_us ( 1 );
+    }
+
+    //拉低后DHT11会拉高总线80us,接着会开始传数据
+
+    return 1;
+
+}
+
+
+/*
+	传输数据:
+	1.一次8bit
+	2.
+		开始(50us 低)->
+		0:	26-28us 高+ (50us 低) = 80us
+		1:	70us 高+ (50us 低) = 120us
+
+	3.判断0/1,
+		1. 26-28us < n <  26-28us+50us
+		2. 0us < n < 70us
+	即,
+	延时35-40us,
+	高 = 1,是70us的,需要延时40us
+	低 = 0,是26-28us的
+
+*/
+static uint8_t Read_Byte ( void )
+{
+    u8 i, temp = 0xff;
+
+    //开始必须是为低的50us 开始信号
+    if ( !DHT11_In )
+    {
+        for ( i = 0; i < 8; i++ )
+        {
+            //等待高电平,消耗50us
+            _us = 0;
+
+            while ( !DHT11_In )
+            {
+                if ( ++_us > 50 )
+                {
+                    return temp;
+                }
+
+                delay_us ( 1 );
+            }
+
+            //等待低电平,真实数据的结束
+            _us = 0;
+
+            while ( DHT11_In )
+            {
+                if ( ++_us > 80 )
+                {
+                    return temp;
+                }
+
+                delay_us ( 1 );
+            }
+
+            if ( _us >  37 ) //35-40us后仍为高电平表示数据“1”
+            {
+                temp |= ( uint8_t ) ( 0x01 << ( 7 - i ) ); //把第7-i位置1
+            }
+            else	 //40us后为低电平表示数据“0”
+            {
+                temp &= ( uint8_t ) ~ ( 0x01 << ( 7 - i ) ); //把第7-i位置0
+            }
+        }
+    }
+
+    return temp;
+}
+
+
+
+uint8_t Read_DHT11 ( DHT11_Data_TypeDef *DHT11_Data )
+{
+    uint8_t  res;
+    uint8_t  check_sum;
+
+    if ( StartDHT11() )	//判断是否已经响应
+    {
+        /*开始接收数据*/
+        DHT11_Data->humi_int = Read_Byte();
+        DHT11_Data->humi_deci = Read_Byte();
+        DHT11_Data->temp_int = Read_Byte();
+        DHT11_Data->temp_deci = Read_Byte();
+        DHT11_Data->check_sum = Read_Byte();
+
+        check_sum = DHT11_Data->humi_int + DHT11_Data->humi_deci + DHT11_Data->temp_int + DHT11_Data->temp_deci;
+
+        /*检查读取的数据是否正确*/
+        if ( DHT11_Data->check_sum == check_sum )
+        {
+            res = SUCCESS;
+        }
+        else
+        {
+            res = ERROR;
+        }
+    }
+    else
+    {
+        res = ERROR;
+    }
+
+    return res;
+}
+
+
+

+ 32 - 0
app/DHT11.h

@@ -0,0 +1,32 @@
+#ifndef _DHT11__H_
+#define _DHT11__H_
+
+#include "main.h"
+
+extern bool DHT11ReadIO ( void );
+
+//对应IO口配置
+
+typedef struct
+{
+    uint8_t  humi_int;		//湿度的整数部分
+    uint8_t  humi_deci;	 	//湿度的小数部分
+    uint8_t  temp_int;	 	//温度的整数部分
+    uint8_t  temp_deci;	 	//温度的小数部分
+    uint8_t  check_sum;	 	//校验和
+
+} DHT11_Data_TypeDef;
+
+unsigned char StartDHT11 ( void );
+void DHT11_PortIN ( void );
+void DHT11_PortOUT ( void );
+uint8_t Read_DHT11 ( DHT11_Data_TypeDef *DHT11_Data );
+//**********************************
+
+//**********************************
+
+extern unsigned char tdata[4];
+//extern unsigned char sbuf;
+//extern unsigned char check;
+
+#endif

+ 492 - 0
app/DMA/SPI_DMA.c

@@ -0,0 +1,492 @@
+#include "SPI_DMA.h"
+
+u8 RxCounterSpi1;
+u8 TxCounterSpi1;
+u8 RxCounterSpi2;
+u8 TxCounterSpi2;
+
+u8 SPI1_TX_Buff[BufferSize] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+                               0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10,
+                               0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
+                               0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20
+                              };
+u8 SPI1_RX_Buff[BufferSize+4];
+u8 SPI2_TX_Buff[BufferSize] = {0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+                               0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60,
+                               0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+                               0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70
+                              };
+u8 SPI2_RX_Buff[BufferSize+4];
+
+bool SPI1_data_come = false;
+bool SPI2_data_come = false;
+
+/******************************SPI1 配置************************************/
+void SPI1_GPIO_Configuration ( void )
+{
+#if SPI1_DMA_SD_def
+    GPIO_InitTypeDef GPIO_InitStructure;
+    SPI_InitTypeDef  SPI_InitStructure;
+
+    //启动GPIO/AFIO
+    SPI1_RCC_GPIO_CONFIG();
+    //启动SPI1
+    SPI1_RCC_CONFIG();
+
+    /* Configure SPI1 pins: SCK, MISO and MOSI */
+    GPIO_InitStructure.GPIO_Pin = SPI1_PIN_AF_CONFIG;
+    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
+    GPIO_Init ( SPI1_PORT_CONFIG, &GPIO_InitStructure );
+    /* Configure I/O for EEPROM Chip select */
+    GPIO_InitStructure.GPIO_Pin = SPI1_PIN_CS_CONFIG;
+    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
+    GPIO_Init ( SPI1_PORT_CONFIG, &GPIO_InitStructure );
+    SPI_EEPROM_CS_HIGH();
+
+	/* SPI1 configuration */ 
+	SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //SPI1设置为两线全双工
+	SPI_InitStructure.SPI_Mode = SPI1_Mode_CONFIG;					   //设置SPI1为主模式
+	SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;				   //SPI发送接收8位帧结构
+	SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; 					   //串行时钟在不操作时,时钟为1电平
+	SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;					   //第2个时钟沿开始采样数据
+	SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;						   //NSS信号由软件(使用SSI位)管理
+	SPI_InitStructure.SPI_BaudRatePrescaler = SPI1_Baud_CONFIG; //定义波特率预分频的值:波特率预分频值为8
+	SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;				   //数据传输从MSB位开始
+	SPI_InitStructure.SPI_CRCPolynomial = 7;						   //CRC值计算的多项式
+	SPI_Init(SPI1_CONFIG, &SPI_InitStructure);
+
+	/* SPI CRC */
+	SPI_CalculateCRC(SPI1_CONFIG, ENABLE);
+
+	//SPI中断
+	//SPI_I2S_ITConfig ( SPI1_CONFIG, SPI_I2S_IT_RXNE, ENABLE );
+	//SPI_I2S_ITConfig(SPI1_CONFIG, SPI_I2S_IT_IDLE,ENABLE);
+
+	/* Enable SPI1 */
+	SPI_Cmd(SPI1_CONFIG, ENABLE);
+
+#endif
+}
+
+
+void SPI1_NVIC_Configuration ( void )
+{
+#if SPI1_DMA_SD_def
+    NVIC_InitTypeDef NVIC_InitStructure;
+
+    /* 1 bit for pre-emption priority, 3 bits for subpriority */
+    NVIC_PriorityGroupConfig ( SPI1_NVIC_Group );
+
+    /* Configure and enable SPI1 interrupt -------------------------------------*/
+    NVIC_InitStructure.NVIC_IRQChannel = SPI1_NVIC_Interrupt;
+    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = SPI1_NVIC_Pre;
+    NVIC_InitStructure.NVIC_IRQChannelSubPriority = SPI1_NVIC_Sub;
+    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
+    NVIC_Init ( &NVIC_InitStructure );
+#endif
+}
+
+/*******************************************************************************
+* Function Name  : SPI1_DMA_Configuration
+* Description    : 配置SPI1_RX的DMA通道2,SPI1_TX的DMA通道3
+* Input          : None
+* Output         : None
+* Return         : None
+* Attention             :
+*******************************************************************************/
+void DMA1_SPI1_Configuration ( void )
+{
+#if SPI1_DMA_SD_def
+    DMA_InitTypeDef DMA_InitStructure;
+
+    //启动DMA时钟
+    RCC_AHBPeriphClockCmd ( DMA_SPI1_RCC_CONFIG, ENABLE );
+
+    /* DMA1 Channel2 (triggered by SPI1 Rx event) Config */
+    DMA_DeInit ( DMA_SPI1_Rx_CHANNLE_CONFIG );
+    DMA_InitStructure.DMA_PeripheralBaseAddr = DMA_SPI1_DR_Addr;                          //设置 SPI1 发送外设(0x4001300C) 地址(目的地址)
+    DMA_InitStructure.DMA_MemoryBaseAddr = ( uint32_t ) DMA_SPI1_Rx_ADDR_CONFIG;                 //设置 SRAM 存储地址(目的地址)
+    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;                                //传输方向 外设-内存
+    DMA_InitStructure.DMA_BufferSize = BufferSize+1;                         //设置 SPI1 发送长度
+    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
+    DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
+    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
+    DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
+    DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;//DMA_Mode_Normal
+    DMA_InitStructure.DMA_Priority = DMA_Priority_High;
+    DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
+    DMA_Init ( DMA_SPI1_Rx_CHANNLE_CONFIG, &DMA_InitStructure );
+
+    /* DMA1 Channel3 (triggered by SPI1 Tx event) Config */
+    DMA_DeInit ( DMA_SPI1_Tx_CHANNLE_CONFIG );
+    DMA_InitStructure.DMA_PeripheralBaseAddr = DMA_SPI1_DR_Addr;                          //设置  接收外设(0x4001300C) 地址(源地址)
+    DMA_InitStructure.DMA_MemoryBaseAddr = ( uint32_t ) DMA_SPI1_Tx_ADDR_CONFIG;                 //设置 SRAM 存储地址(源地址)
+    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;                                //传输方向 内存-外设
+    DMA_InitStructure.DMA_BufferSize = BufferSize;                           //设置 SPI1 接收长度
+    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
+    DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
+    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
+    DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
+    DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
+	DMA_InitStructure.DMA_Priority = DMA_Priority_Low;
+    DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
+	DMA_Init ( DMA_SPI1_Tx_CHANNLE_CONFIG, &DMA_InitStructure );
+
+	/* 中断标志*/
+	DMA_ITConfig(DMA_SPI1_Rx_CHANNLE_CONFIG, DMA_IT_TC, ENABLE);
+	DMA_ITConfig(DMA_SPI1_Rx_CHANNLE_CONFIG, DMA_IT_TE, ENABLE);
+	DMA_ITConfig(DMA_SPI1_Tx_CHANNLE_CONFIG, DMA_IT_TC, ENABLE);
+	DMA_ITConfig(DMA_SPI1_Tx_CHANNLE_CONFIG, DMA_IT_TE, ENABLE);
+
+	/* Enable SPI1 DMA Tx/Rx request */
+	SPI_I2S_DMACmd(SPI1_CONFIG, SPI_I2S_DMAReq_Tx, ENABLE);
+	SPI_I2S_DMACmd(SPI1_CONFIG, SPI_I2S_DMAReq_Rx, ENABLE);
+
+	/* Enable channe2 and channel3 */
+	DMA_Cmd(DMA_SPI1_Rx_CHANNLE_CONFIG, ENABLE);	//开接收
+	DMA_Cmd(DMA_SPI1_Tx_CHANNLE_CONFIG, DISABLE);	//关发送
+
+#endif
+}
+
+void DMA1_SPI1_NVIC_Configuration ( void )
+{
+#if SPI1_DMA_SD_def
+    NVIC_InitTypeDef NVIC_InitStructure;
+
+    /* 1 bit for pre-emption priority, 3 bits for subpriority */
+    NVIC_PriorityGroupConfig ( DMA_SPI1_NVIC_Group );
+
+    /* Configure and enable DMA1 interrupt -------------------------------------*/
+    NVIC_InitStructure.NVIC_IRQChannel = DMA_SPI1_NVIC_Rx_Interrupt;
+    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = DMA_SPI1_NVIC_Rx_Pre;
+    NVIC_InitStructure.NVIC_IRQChannelSubPriority = DMA_SPI1_NVIC_Rx_Sub;
+    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
+    NVIC_Init ( &NVIC_InitStructure );
+
+	/* Configure and enable DMA1 interrupt -------------------------------------*/
+	 NVIC_InitStructure.NVIC_IRQChannel = DMA_SPI1_NVIC_Tx_Interrupt;
+	 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = DMA_SPI1_NVIC_Tx_Pre;
+	 NVIC_InitStructure.NVIC_IRQChannelSubPriority = DMA_SPI1_NVIC_Tx_Sub;
+	 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
+	 NVIC_Init ( &NVIC_InitStructure );
+	
+#endif
+}
+
+//SPIx 读写一个字节
+//返回值:读取到的字节
+u8 SPIx_ReadWriteByte(u8 byte)
+{		
+  /* Loop while DR register in not emplty */
+  while(SPI_I2S_GetFlagStatus(SPI1_CONFIG, SPI_I2S_FLAG_TXE) == RESET);
+
+  /* Send byte through the SPI2 peripheral */
+  SPI_I2S_SendData(SPI1_CONFIG, byte);
+
+  /* Wait to receive a byte */
+  while(SPI_I2S_GetFlagStatus(SPI1_CONFIG, SPI_I2S_FLAG_RXNE) == RESET);
+
+  /* Return the byte read from the SPI bus */
+  return SPI_I2S_ReceiveData(SPI1_CONFIG);				    
+}
+
+/*******************************************************************************
+* Function Name  : SPI1_Send
+* Description    : SPI1的DMA方式发送
+* Input          : SPI1_TX_Buff[SPI1_SendBufferSize]
+* Output         : None
+* Return         : None
+* Attention             : 关闭DMA通道3之前必须等待TXE为1,等待忙标志为0
+*******************************************************************************/
+void SPI1_Send ( u8 *buff, u32 len )
+{
+    DMA_SPI1_Tx_CHANNLE_CONFIG->CPAR = DMA_SPI1_DR_Addr; //外设地址
+    DMA_SPI1_Tx_CHANNLE_CONFIG->CMAR = ( u32 ) buff; //mem地址
+    DMA_SPI1_Tx_CHANNLE_CONFIG->CNDTR = len ; //传输长度
+    DMA_SPI1_Tx_CHANNLE_CONFIG->CCR = ( 0 << 14 ) | // 非存储器到存储器模式
+                         ( 2 << 12 ) | // 通道优先级高
+                         ( 0 << 11 ) | // 存储器数据宽度8bit
+                         ( 0 << 10 ) | // 存储器数据宽度8bit
+                         ( 0 <<  9 ) | // 外设数据宽度8bit
+                         ( 0 <<  8 ) | // 外设数据宽度8bit
+                         ( 1 <<  7 ) | // 存储器地址增量模式
+                         ( 0 <<  6 ) | // 外设地址增量模式(不增)
+                         ( 0 <<  5 ) | // 非循环模式
+                         ( 1 <<  4 ) | // 从存储器读
+                         ( 1 <<  3 ) | // 允许传输错误中断
+                         ( 0 <<  2 ) | // 允许半传输中断
+                         ( 1 <<  1 ) | // 允许传输完成中断
+                         ( 1 );      // 通道开启
+}
+
+/*******************************************************************************
+* Function Name  : SPI1_Recive
+* Description    : SPI1的DMA方式接收
+* Input          : None
+* Output         : SPI1_RX_Buff[SPI1_ReciveBufferSize]
+* Return         : None
+* Attention             : 必须要先关闭通道2,然后再配置通道2的参数
+*******************************************************************************/
+void SPI1_Recive ( u8 *buff, u32 len )
+{
+    DMA_SPI1_Rx_CHANNLE_CONFIG->CCR &= ~ ( 1 << 0 );         //关闭DMA通道2
+
+    DMA_SPI1_Rx_CHANNLE_CONFIG->CPAR = DMA_SPI1_DR_Addr; //外设地址
+    DMA_SPI1_Rx_CHANNLE_CONFIG->CMAR = ( uint32_t ) buff; //mem地址
+    DMA_SPI1_Rx_CHANNLE_CONFIG->CNDTR = len ; //传输长度
+    DMA_SPI1_Rx_CHANNLE_CONFIG->CCR = ( 0 << 14 ) | // 非存储器到存储器模式
+                         ( 2 << 12 ) | // 通道优先级高
+                         ( 0 << 11 ) | // 存储器数据宽度8bit
+                         ( 0 << 10 ) | // 存储器数据宽度8bit
+                         ( 0 <<  9 ) | // 外设数据宽度8bit
+                         ( 0 <<  8 ) | // 外设数据宽度8bit
+                         ( 1 <<  7 ) | // 存储器地址增量模式
+                         ( 0 <<  6 ) | // 外设地址增量模式(不增)
+                         ( 0 <<  5 ) | // 非循环模式
+                         ( 0 <<  4 ) | // 传输方向 外设-内存
+                         ( 0 <<  3 ) | // 允许传输错误中断
+                         ( 0 <<  2 ) | // 允许半传输中断
+                         ( 1 <<  1 ) | // 允许传输完成中断
+                         ( 1 );      // 通道开启
+}
+
+
+/******************************SPI2 配置************************************/
+void SPI2_GPIO_Configuration ( void )
+{
+#if SPI2_DMA_SD_def
+    GPIO_InitTypeDef GPIO_InitStructure;
+    SPI_InitTypeDef  SPI_InitStructure;
+
+    //启动GPIO/AFIO
+    SPI2_RCC_GPIO_CONFIG();
+    //启动SPI2
+    SPI2_RCC_CONFIG();
+
+    /* Configure SPI1 pins: SCK, MISO and MOSI */
+    GPIO_InitStructure.GPIO_Pin = SPI2_PIN_AF_CONFIG;
+    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
+    GPIO_Init ( SPI2_PORT_CONFIG, &GPIO_InitStructure );
+#if 1	//副的接收cs	
+    /* Configure I/O for EEPROM Chip select */
+    GPIO_InitStructure.GPIO_Pin = SPI2_PIN_CS_CONFIG;
+    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
+    GPIO_Init ( SPI2_PORT_CONFIG, &GPIO_InitStructure );
+    //SPI_EEPROM_CS_HIGH();
+#endif
+
+	/* SPI2 configuration */ 
+	SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //SPI1设置为两线全双工
+	SPI_InitStructure.SPI_Mode = SPI2_Mode_CONFIG;					   //设置SPI1为主模式
+	SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;				   //SPI发送接收8位帧结构
+	SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; 					   //串行时钟在不操作时,时钟为1电平
+	SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;					   //第2个时钟沿开始采样数据
+	SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;						   //NSS信号由软件(使用SSI位)管理
+	SPI_InitStructure.SPI_BaudRatePrescaler = SPI2_Baud_CONFIG; //定义波特率预分频的值:波特率预分频值为8
+	SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;				   //数据传输从MSB位开始
+	SPI_InitStructure.SPI_CRCPolynomial = 7;						   //CRC值计算的多项式
+	SPI_Init(SPI2_CONFIG, &SPI_InitStructure);
+
+	/* SPI CRC */
+	SPI_CalculateCRC(SPI2_CONFIG, ENABLE);
+
+	//SPI中断
+	//SPI_I2S_ITConfig ( SPI2_CONFIG, SPI_I2S_IT_RXNE, ENABLE );
+//	SPI_I2S_ITConfig(SPI1_CONFIG, SPI_I2S_IT_IDLE,ENABLE);
+
+	/* Enable SPI1 */
+	SPI_Cmd(SPI2_CONFIG, ENABLE);
+
+#endif
+}
+
+
+void SPI2_NVIC_Configuration ( void )
+{
+#if SPI1_DMA_SD_def
+    NVIC_InitTypeDef NVIC_InitStructure;
+
+    /* 1 bit for pre-emption priority, 3 bits for subpriority */
+    NVIC_PriorityGroupConfig ( SPI2_NVIC_Group );
+
+    /* Configure and enable SPI1 interrupt -------------------------------------*/
+    NVIC_InitStructure.NVIC_IRQChannel = SPI2_NVIC_Interrupt;
+    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = SPI2_NVIC_Pre;
+    NVIC_InitStructure.NVIC_IRQChannelSubPriority = SPI2_NVIC_Sub;
+    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
+    NVIC_Init ( &NVIC_InitStructure );
+#endif
+}
+
+/*******************************************************************************
+* Function Name  : SPI1_DMA_Configuration
+* Description    : 配置SPI1_RX的DMA通道2,SPI1_TX的DMA通道3
+* Input          : None
+* Output         : None
+* Return         : None
+* Attention             :
+*******************************************************************************/
+void DMA1_SPI2_Configuration ( void )
+{
+#if SPI2_DMA_SD_def
+    DMA_InitTypeDef DMA_InitStructure;
+
+    //启动DMA时钟
+    RCC_AHBPeriphClockCmd ( DMA_SPI2_RCC_CONFIG, ENABLE );
+
+    /* DMA1 Channel2 (triggered by SPI1 Rx event) Config */
+    DMA_DeInit ( DMA_SPI2_Rx_CHANNLE_CONFIG );
+    DMA_InitStructure.DMA_PeripheralBaseAddr = DMA_SPI2_DR_Addr;                          //设置 SPI1 发送外设(0x4001300C) 地址(目的地址)
+    DMA_InitStructure.DMA_MemoryBaseAddr = ( uint32_t ) DMA_SPI2_Rx_ADDR_CONFIG;                 //设置 SRAM 存储地址(目的地址)
+    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;                                //传输方向 外设-内存
+    DMA_InitStructure.DMA_BufferSize = BufferSize+1;                         //设置 SPI1 发送长度
+    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
+    DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
+    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
+    DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
+    DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;//DMA_Mode_Normal
+    DMA_InitStructure.DMA_Priority = DMA_Priority_High;
+    DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
+    DMA_Init ( DMA_SPI2_Rx_CHANNLE_CONFIG, &DMA_InitStructure );
+
+    /* DMA1 Channel3 (triggered by SPI1 Tx event) Config */
+    DMA_DeInit ( DMA_SPI2_Tx_CHANNLE_CONFIG );
+    DMA_InitStructure.DMA_PeripheralBaseAddr = DMA_SPI2_DR_Addr;                          //设置  接收外设(0x4001300C) 地址(源地址)
+    DMA_InitStructure.DMA_MemoryBaseAddr = ( uint32_t ) DMA_SPI2_Tx_ADDR_CONFIG;                 //设置 SRAM 存储地址(源地址)
+    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;                                //传输方向 内存-外设
+    DMA_InitStructure.DMA_BufferSize = BufferSize;                           //设置 SPI1 接收长度
+    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
+    DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
+    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
+    DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
+    DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
+	DMA_InitStructure.DMA_Priority = DMA_Priority_Low;
+    DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
+	DMA_Init ( DMA_SPI2_Tx_CHANNLE_CONFIG, &DMA_InitStructure );
+
+	/* 中断标志*/
+	DMA_ITConfig(DMA_SPI2_Rx_CHANNLE_CONFIG, DMA_IT_TC, ENABLE);
+	DMA_ITConfig(DMA_SPI2_Rx_CHANNLE_CONFIG, DMA_IT_TE, ENABLE);
+	DMA_ITConfig(DMA_SPI2_Tx_CHANNLE_CONFIG, DMA_IT_TC, ENABLE);
+	DMA_ITConfig(DMA_SPI2_Tx_CHANNLE_CONFIG, DMA_IT_TE, ENABLE);
+
+	/* Enable SPI1 DMA Tx/Rx request */
+	SPI_I2S_DMACmd(SPI2_CONFIG, SPI_I2S_DMAReq_Tx, ENABLE);
+	SPI_I2S_DMACmd(SPI2_CONFIG, SPI_I2S_DMAReq_Rx, ENABLE);
+
+	/* Enable channe2 and channel3 */
+	DMA_Cmd(DMA_SPI2_Rx_CHANNLE_CONFIG, ENABLE);	//开接收
+	DMA_Cmd(DMA_SPI2_Tx_CHANNLE_CONFIG, DISABLE);	//关发送
+
+#endif
+}
+
+void DMA1_SPI2_NVIC_Configuration ( void )
+{
+#if SPI2_DMA_SD_def
+    NVIC_InitTypeDef NVIC_InitStructure;
+
+    /* 1 bit for pre-emption priority, 3 bits for subpriority */
+    NVIC_PriorityGroupConfig ( DMA_SPI2_NVIC_Group );
+
+    /* Configure and enable DMA1 interrupt -------------------------------------*/
+    NVIC_InitStructure.NVIC_IRQChannel = DMA_SPI2_NVIC_Rx_Interrupt;
+    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = DMA_SPI2_NVIC_Rx_Pre;
+    NVIC_InitStructure.NVIC_IRQChannelSubPriority = DMA_SPI2_NVIC_Rx_Sub;
+    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
+    NVIC_Init ( &NVIC_InitStructure );
+
+	/* Configure and enable DMA1 interrupt -------------------------------------*/
+	 NVIC_InitStructure.NVIC_IRQChannel = DMA_SPI2_NVIC_Tx_Interrupt;
+	 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = DMA_SPI1_NVIC_Tx_Pre;
+	 NVIC_InitStructure.NVIC_IRQChannelSubPriority = DMA_SPI2_NVIC_Tx_Sub;
+	 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
+	 NVIC_Init ( &NVIC_InitStructure );
+	
+#endif
+}
+
+//SPIx 读写一个字节
+//返回值:读取到的字节
+u8 SPI2_ReadWriteByte(u8 byte)
+{		
+  /* Loop while DR register in not emplty */
+  while(SPI_I2S_GetFlagStatus(SPI2_CONFIG, SPI_I2S_FLAG_TXE) == RESET);
+
+  /* Send byte through the SPI2 peripheral */
+  SPI_I2S_SendData(SPI2_CONFIG, byte);
+
+  /* Wait to receive a byte */
+  while(SPI_I2S_GetFlagStatus(SPI2_CONFIG, SPI_I2S_FLAG_RXNE) == RESET);
+
+  /* Return the byte read from the SPI bus */
+  return SPI_I2S_ReceiveData(SPI2_CONFIG);				    
+}
+
+/*******************************************************************************
+* Function Name  : SPI1_Send
+* Description    : SPI1的DMA方式发送
+* Input          : SPI1_TX_Buff[SPI1_SendBufferSize]
+* Output         : None
+* Return         : None
+* Attention             : 关闭DMA通道3之前必须等待TXE为1,等待忙标志为0
+*******************************************************************************/
+void SPI2_Send ( u8 *buff, u32 len )
+{
+    DMA_SPI2_Tx_CHANNLE_CONFIG->CPAR = DMA_SPI2_DR_Addr; //外设地址
+    DMA_SPI2_Tx_CHANNLE_CONFIG->CMAR = ( u32 ) buff; //mem地址
+    DMA_SPI2_Tx_CHANNLE_CONFIG->CNDTR = len ; //传输长度
+    DMA_SPI2_Tx_CHANNLE_CONFIG->CCR = ( 0 << 14 ) | // 非存储器到存储器模式
+                         ( 2 << 12 ) | // 通道优先级高
+                         ( 0 << 11 ) | // 存储器数据宽度8bit
+                         ( 0 << 10 ) | // 存储器数据宽度8bit
+                         ( 0 <<  9 ) | // 外设数据宽度8bit
+                         ( 0 <<  8 ) | // 外设数据宽度8bit
+                         ( 1 <<  7 ) | // 存储器地址增量模式
+                         ( 0 <<  6 ) | // 外设地址增量模式(不增)
+                         ( 0 <<  5 ) | // 非循环模式
+                         ( 1 <<  4 ) | // 从存储器读
+                         ( 1 <<  3 ) | // 允许传输错误中断
+                         ( 0 <<  2 ) | // 允许半传输中断
+                         ( 1 <<  1 ) | // 允许传输完成中断
+                         ( 1 );      // 通道开启
+}
+
+/*******************************************************************************
+* Function Name  : SPI1_Recive
+* Description    : SPI1的DMA方式接收
+* Input          : None
+* Output         : SPI1_RX_Buff[SPI1_ReciveBufferSize]
+* Return         : None
+* Attention             : 必须要先关闭通道2,然后再配置通道2的参数
+*******************************************************************************/
+void SPI2_Recive ( u8 *buff, u32 len )
+{
+    DMA_SPI2_Rx_CHANNLE_CONFIG->CCR &= ~ ( 1 << 0 );         //关闭DMA通道2
+
+    DMA_SPI2_Rx_CHANNLE_CONFIG->CPAR = DMA_SPI2_DR_Addr; //外设地址
+    DMA_SPI2_Rx_CHANNLE_CONFIG->CMAR = ( uint32_t ) buff; //mem地址
+    DMA_SPI2_Rx_CHANNLE_CONFIG->CNDTR = len ; //传输长度
+    DMA_SPI2_Rx_CHANNLE_CONFIG->CCR = ( 0 << 14 ) | // 非存储器到存储器模式
+                         ( 2 << 12 ) | // 通道优先级高
+                         ( 0 << 11 ) | // 存储器数据宽度8bit
+                         ( 0 << 10 ) | // 存储器数据宽度8bit
+                         ( 0 <<  9 ) | // 外设数据宽度8bit
+                         ( 0 <<  8 ) | // 外设数据宽度8bit
+                         ( 1 <<  7 ) | // 存储器地址增量模式
+                         ( 0 <<  6 ) | // 外设地址增量模式(不增)
+                         ( 0 <<  5 ) | // 非循环模式
+                         ( 0 <<  4 ) | // 传输方向 外设-内存
+                         ( 0 <<  3 ) | // 允许传输错误中断
+                         ( 0 <<  2 ) | // 允许半传输中断
+                         ( 1 <<  1 ) | // 允许传输完成中断
+                         ( 1 );      // 通道开启
+}
+
+
+

+ 115 - 0
app/DMA/SPI_DMA.h

@@ -0,0 +1,115 @@
+#ifndef __SPI_DMA_H_
+#define __SPI_DMA_H_
+
+#include "main.h"
+
+/********************************SPI1*****************************/
+/****** GPIO 配置******/
+//SPI1 GPIO
+#define SPI1_RCC_GPIO_CONFIG()	(RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE))
+#define SPI1_RCC_CONFIG()		(RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1,ENABLE))
+#define SPI1_PORT_CONFIG		(GPIOA)
+#define SPI1_PIN_AF_CONFIG		(GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7)
+#define SPI1_PIN_CS_CONFIG		(GPIO_Pin_4)
+#define SPI_EEPROM_CS_LOW()     (GPIO_ResetBits(SPI1_PORT_CONFIG, SPI1_PIN_CS_CONFIG))
+#define SPI_EEPROM_CS_HIGH()    (GPIO_SetBits(SPI1_PORT_CONFIG, SPI1_PIN_CS_CONFIG))
+//通讯参数
+#define SPI1_Mode_CONFIG		(SPI_Mode_Master)
+#define SPI1_Baud_CONFIG		(SPI_BaudRatePrescaler_256)
+//SPI1 号
+#define SPI1_CONFIG				(SPI1)
+/****** SPI1优先级******/
+#define SPI1_NVIC_Group			(NVIC_PriorityGroup_0)
+#define SPI1_NVIC_Interrupt		(SPI1_IRQn)				//uart1中断号
+#define SPI1_NVIC_Pre			(0)
+#define SPI1_NVIC_Sub			(3)
+
+/********DMA配置********/
+#define DMA_SPI1_DR_Addr    			((u32)&SPI1->DR)//0x4001300C
+
+#define DMA_SPI1_RCC_CONFIG				(RCC_AHBPeriph_DMA1)
+#define DMA_SPI1_Rx_CHANNLE_CONFIG		(DMA1_Channel2)
+#define DMA_SPI1_Rx_ADDR_CONFIG			(SPI1_RX_Buff)
+#define DMA_SPI1_Tx_CHANNLE_CONFIG		(DMA1_Channel3)
+#define DMA_SPI1_Tx_ADDR_CONFIG			(SPI1_TX_Buff)
+
+/****** DMA优先级******/
+#define DMA_SPI1_NVIC_Group				(NVIC_PriorityGroup_0)
+#define DMA_SPI1_NVIC_Rx_Interrupt		(DMA1_Channel2_IRQn)				//uart1中断号
+#define DMA_SPI1_NVIC_Rx_Pre			(0)
+#define DMA_SPI1_NVIC_Rx_Sub			(4)
+#define DMA_SPI1_NVIC_Tx_Interrupt		(DMA1_Channel3_IRQn)				//uart1中断号
+#define DMA_SPI1_NVIC_Tx_Pre			(0)
+#define DMA_SPI1_NVIC_Tx_Sub			(5)
+
+/********************************SPI2*****************************/
+/****** GPIO 配置******/
+//SPI2 GPIO
+#define SPI2_RCC_GPIO_CONFIG()	(RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO,ENABLE))
+#define SPI2_RCC_CONFIG()		(RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2,ENABLE))
+#define SPI2_PORT_CONFIG		(GPIOB)
+#define SPI2_PIN_AF_CONFIG		(GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15)
+#define SPI2_PIN_CS_CONFIG		(GPIO_Pin_12)
+#define SPI2_EEPROM_CS_VAL     	(PBin(12))
+//通讯参数
+#define SPI2_Mode_CONFIG		(SPI_Mode_Slave)
+#define SPI2_Baud_CONFIG		(SPI_BaudRatePrescaler_16)
+//SPI1 号
+#define SPI2_CONFIG				(SPI2)
+/****** SPI1优先级******/
+#define SPI2_NVIC_Group			(NVIC_PriorityGroup_0)
+#define SPI2_NVIC_Interrupt		(SPI2_IRQn)				//uart1中断号
+#define SPI2_NVIC_Pre			(0)
+#define SPI2_NVIC_Sub			(6)
+
+/********DMA配置********/
+#define DMA_SPI2_DR_Addr    			((u32)&SPI2->DR)//0x4001300C
+
+#define DMA_SPI2_RCC_CONFIG				(RCC_AHBPeriph_DMA1)
+#define DMA_SPI2_Rx_CHANNLE_CONFIG		(DMA1_Channel4)
+#define DMA_SPI2_Rx_ADDR_CONFIG			(SPI2_RX_Buff)
+#define DMA_SPI2_Tx_CHANNLE_CONFIG		(DMA1_Channel5)
+#define DMA_SPI2_Tx_ADDR_CONFIG			(SPI2_TX_Buff)
+
+/****** DMA优先级******/
+#define DMA_SPI2_NVIC_Group				(NVIC_PriorityGroup_0)
+#define DMA_SPI2_NVIC_Rx_Interrupt		(DMA1_Channel4_IRQn)				//uart1中断号
+#define DMA_SPI2_NVIC_Rx_Pre			(0)
+#define DMA_SPI2_NVIC_Rx_Sub			(7)
+#define DMA_SPI2_NVIC_Tx_Interrupt		(DMA1_Channel5_IRQn)				//uart1中断号
+#define DMA_SPI2_NVIC_Tx_Pre			(0)
+#define DMA_SPI2_NVIC_Tx_Sub			(8)
+
+
+#define BufferSize     					(32)
+
+extern void SPI1_GPIO_Configuration ( void );
+extern void SPI1_NVIC_Configuration ( void );
+extern void DMA1_SPI1_Configuration ( void );
+extern void DMA1_SPI1_NVIC_Configuration ( void );
+extern u8 SPIx_ReadWriteByte(u8 byte);
+extern void SPI1_Send ( u8 *buff, u32 len );
+extern void SPI1_Recive ( u8 *buff, u32 len );
+
+extern void SPI2_GPIO_Configuration ( void );
+extern void SPI2_NVIC_Configuration ( void );
+extern void DMA1_SPI2_Configuration ( void );
+extern void DMA1_SPI2_NVIC_Configuration ( void );
+extern u8 SPI2_ReadWriteByte(u8 byte);
+extern void SPI2_Send ( u8 *buff, u32 len );
+extern void SPI2_Recive ( u8 *buff, u32 len );
+
+
+extern u8 SPI1_TX_Buff[];
+extern u8 SPI1_RX_Buff[];
+extern u8 SPI2_TX_Buff[];
+extern u8 SPI2_RX_Buff[];
+
+extern u8 RxCounterSpi1;
+extern u8 TxCounterSpi1;
+extern u8 RxCounterSpi2;
+extern u8 TxCounterSpi2;
+extern bool SPI1_data_come;
+extern bool SPI2_data_come;
+
+#endif

+ 83 - 0
app/DMA/UART_DMA.C

@@ -0,0 +1,83 @@
+#include "UART_DMA.h"
+
+uint8_t TxBufferUart[256] = { 0 };
+uint8_t RxBufferUart[256] = { 0 };
+__IO uint8_t TxCounterUart = 0x00;
+__IO uint8_t RxCounterUart = 0x00;
+uint8_t UartSendCount = 0;
+
+/*******************************************************************************
+* Function Name  : USART_Configuration
+* Description    : Configure USART1
+* Input          : None
+* Output         : None
+* Return         : None
+* Attention		 : None
+*******************************************************************************/
+void ConfigurationUsart1 ( void )
+{
+#if UART1_SD_def
+    GPIO_InitTypeDef GPIO_InitStructure;
+    USART_InitTypeDef USART_InitStructure;
+
+    //使能USART1/GPIO 时钟可配置
+    Wifi_RCC_GPIO_CONFIG();
+    Wifi_RCC_UART_CONFIG();
+    /*
+    *  USART1_TX -> PA9 , USART1_RX ->	PA10
+    */
+    GPIO_InitStructure.GPIO_Pin = Wifi_Tx;
+    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
+    GPIO_Init ( Wifi_GPIO, &GPIO_InitStructure );
+
+    GPIO_InitStructure.GPIO_Pin = Wifi_Rx;
+    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
+    GPIO_Init ( Wifi_GPIO, &GPIO_InitStructure );
+
+    USART_InitStructure.USART_BaudRate = Wifi_UART_BAUD;
+    USART_InitStructure.USART_WordLength = USART_WordLength_8b;
+    USART_InitStructure.USART_StopBits = USART_StopBits_1;
+    USART_InitStructure.USART_Parity = USART_Parity_No;
+    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
+    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
+
+    USART_Init ( Wifi_UART, &USART_InitStructure );
+
+    //USART_ITConfig ( Wifi_UART, USART_IT_RXNE, ENABLE );
+    //USART_ITConfig ( Wifi_UART, USART_IT_TXE, DISABLE );
+
+    USART_Cmd ( Wifi_UART, ENABLE );
+#endif
+}
+//系统中断管理
+void NVIC_ConfigurationUSART1 ( void )
+{
+    NVIC_InitTypeDef NVIC_InitStructure;
+    /* Configure the NVIC Preemption Priority Bits */
+    NVIC_PriorityGroupConfig ( Wifi_NVIC_Group );
+
+    /* Enable the USARTy Interrupt */
+    NVIC_InitStructure.NVIC_IRQChannel = Wifi_NVIC_Interrupt;
+    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = Wifi_NVIC_Pre;
+    NVIC_InitStructure.NVIC_IRQChannelSubPriority = Wifi_NVIC_Sub;
+    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
+    NVIC_Init ( &NVIC_InitStructure );
+}
+
+void UartSend ( char *buffer, int nBytes )
+{
+    // Wait for previous xmt to complete
+    while ( TxCounterUart < UartSendCount );
+
+    // Setup next XMT
+    memcpy ( TxBufferUart, buffer, nBytes );
+    TxCounterUart = 0;
+    UartSendCount = nBytes;
+
+    USART_ITConfig ( USART1, USART_IT_TXE, ENABLE );
+}
+
+
+

+ 21 - 0
app/DMA/UART_DMA.h

@@ -0,0 +1,21 @@
+#ifndef __UART_DMA_H
+#define __UART_DMA_H
+
+#include "main.h"
+
+
+
+
+
+extern uint8_t TxBufferUart[];
+extern uint8_t RxBufferUart[];
+
+
+extern void ConfigurationUsart1 ( void );
+extern void NVIC_ConfigurationUSART1 ( void );
+extern void UartSend ( char *buffer, int nBytes );
+
+
+
+#endif
+

+ 134 - 0
app/DMA/UART_DMA_1.C

@@ -0,0 +1,134 @@
+#define UART_RX_LEN     128
+static char Uart_Rx[UART_RX_LEN];//GPS接收数据
+
+ 
+void GPS_Init(void)
+{
+   RCC_Configuration();//时钟打开
+   GPIO_Configuration();//GPIO配置   
+   DMA_Configuration();//DMA配置
+   UART_Configuration();//UART配置
+   NVIC_Configuration();//中断优先级配置
+}
+
+ 
+void RCC_Configuration(void)
+{
+   //打开串口对应的外设时钟   
+    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE);     
+    //启动DMA时钟 
+    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); 
+}
+
+void GPIO_Configuration(void)
+{
+  GPIO_InitTypeDef GPIO_InitStructure;
+
+ 
+  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
+  GPIO_Init(GPIOA, &GPIO_InitStructure);
+ 
+ 
+  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
+  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
+  GPIO_Init(GPIOA, &GPIO_InitStructure);
+}
+
+void DMA_Configuration(void)
+{
+    DMA_InitTypeDef DMA_InitStructure;
+ //DMA1通道5配置 
+    DMA_DeInit(DMA1_Channel5); 
+    //外设地址 
+    DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(&USART1->DR); 
+    //内存地址 
+    DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)Uart_Rx; 
+    //dma传输方向单向 
+    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; 
+    //设置DMA在传输时缓冲区的长度 
+    DMA_InitStructure.DMA_BufferSize = UART_RX_LEN; 
+    //设置DMA的外设递增模式,一个外设 
+    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; 
+    //设置DMA的内存递增模式 
+    DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; 
+    //外设数据字长 
+    DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; 
+    //内存数据字长 
+    DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; 
+    //设置DMA的传输模式 
+    DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; 
+    //设置DMA的优先级别 
+    DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; 
+    //设置DMA的2个memory中的变量互相访问 
+    DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; 
+    DMA_Init(DMA1_Channel5,&DMA_InitStructure); 
+ 
+    //使能通道5 
+    DMA_Cmd(DMA1_Channel5,ENABLE);
+}
+
+void UART_Configuration(void)
+{
+    USART_InitTypeDef USART_InitStructure;
+ //初始化参数      
+    USART_InitStructure.USART_WordLength = USART_WordLength_8b;   
+    USART_InitStructure.USART_StopBits = USART_StopBits_1;   
+    USART_InitStructure.USART_Parity = USART_Parity_No;   
+    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;   
+    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;     
+    USART_InitStructure.USART_BaudRate = 9600;  
+    //初始化串口  
+    USART_Init(USART1,&USART_InitStructure);   
+     
+    //中断配置 
+    USART_ITConfig(USART1,USART_IT_TC,DISABLE); 
+    USART_ITConfig(USART1,USART_IT_RXNE,DISABLE); 
+    USART_ITConfig(USART1,USART_IT_IDLE,ENABLE);
+ //采用DMA方式接收 
+    USART_DMACmd(USART1,USART_DMAReq_Rx,ENABLE);
+}
+
+
+void NVIC_Configuration(void)
+{
+    NVIC_InitTypeDef NVIC_InitStructure;
+ //配置UART1中断   
+    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_3); 
+    NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;               //通道设置为串口1中断   
+    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;       //中断占先等级0   
+    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;              //中断响应优先级0   
+    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;                 //打开中断   
+    NVIC_Init(&NVIC_InitStructure); 
+}
+
+ 
+void USART1_IRQHandler(void)                                
+{    
+    uint32_t Length = 0;//数据长度    
+    if(USART_GetITStatus(USART1, USART_IT_IDLE) != RESET) 
+    { 
+        DMA_Cmd(DMA1_Channel5,DISABLE);
+        Length = USART1->SR; 
+        Length = USART1->DR; //清USART_IT_IDLE标志 
+        Length = UART_RX_LEN - DMA_GetCurrDataCounter(DMA1_Channel5); 
+//设置传输数据长度 
+        DMA1_Channel5->CNDTR = UART_RX_LEN;//重装填,并让接收地址偏址从0开始
+        DMA_Cmd(DMA1_Channel5, ENABLE);//处理完,重开DMA  
+    }  
+    __nop();  
+}
+
+void GPS_Cmd(FunctionalState NewState)
+{
+ USART_Cmd(USART1, NewState);
+}
+
+ 
+以下是调用函数,一般在main函数中
+
+GPS_Init();    
+GPS_Cmd(ENABLE);
+
+

+ 666 - 0
app/DMA/common.c

@@ -0,0 +1,666 @@
+#include "common.h"
+#include "flash.h"
+#include "stdio.h"
+#include "stdlib.h"
+#include "ff.h"
+#include "integer.h"
+#include "diskio.h"
+//#include "stm32_eval.h"
+#include "string.h"
+
+void edit_file(void)
+{
+	FATFS fs;
+	FIL	file;
+	FRESULT res; 
+	DIR dirs;
+	FILINFO finfo;
+	char key = 0;
+	char path[20];
+
+	uint32_t index = 0x00;
+	uint32_t reindex = 0x00;
+	uint8_t file_buff[512] = {0};
+
+	uint32_t files_num = 0;
+	uint8_t length = 0;
+	res = f_mount(0,&fs);
+	if (res != FR_OK)
+	{
+		printf("\r\n挂载文件系统失败,错误代码: %u",res);
+		return;
+	}
+	res = f_opendir(&dirs,"/");
+	printf("\r\n------------文件列表------------");
+	if (res == FR_OK) 
+	{
+		while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.fname[0]) 
+		{
+			if (finfo.fattrib & AM_DIR)//如果是文件夹 
+			{ 
+				continue;
+			} 
+			else 
+			{   
+				files_num++;
+				//显示文件名,显示文件实际大小 ,文件实际大小采用四舍五入法
+				printf("\r\n/%12s%7ld KB ",  &finfo.fname[0],(finfo.fsize+512)/1024);
+			}
+		}
+		if( files_num == 0 )//无文件
+		{
+			printf("\r\n无文件!");    
+		}
+	}
+	else
+	{
+		printf("\r\n打开根目录失败!");
+		printf("\r\n错误代码: %u",res);
+	}
+	printf("\r\n输入要编辑文件全名,以回车结束...");
+	get_file_name((uint8_t *)path,length,FI);
+	res = f_open(&file,path,FA_READ | FA_WRITE);
+	if (res == FR_OK)
+	{	
+		printf("\r\n打开文件 %s 成功",path);
+		printf("\r\n现在是文件编辑状态,请输入要写入的数据!");		
+		printf("\r\n按ESC或者Ctrl+C结束编辑!\r\n");
+		
+		while(1)
+		{
+			key = GetKey();
+			if ((key == 0x1B) && (index == 0x00))//key ESC
+			{
+				printf("\r\n数据还没有输入,现在处于编辑模式...");								
+				continue;
+			}
+			else if ((key == 0x1B))	//key ESC
+			{
+				printf("\r\n保存数据...");
+				res = f_write(&file,file_buff,index,&reindex);
+				if ((res == FR_OK) && (reindex == index))
+				{
+					printf("\r\n保存数据成功!");
+					f_close(&file);
+					index = 0x00;
+					reindex = 0x00;									
+				}
+				else
+				{
+					printf("\r\n保存数据失败!");
+					printf("\r\n错误代码: %u",res);									
+				}
+				break;
+			}
+			else if (key == 0x03) //key Ctrl+C
+			{
+				printf("\r\n结束文件编辑!");
+				printf("\r\n保存数据...");
+				res = f_write(&file,file_buff,index,&reindex);
+				if ((res == FR_OK) && (reindex == index))
+				{
+					printf("\r\n保存数据成功!");
+					f_close(&file);
+					index = 0x00;
+					reindex = 0x00;									
+				}
+				else
+				{
+					printf("\r\n保存数据失败!");
+					printf("\r\n错误代码: %u",res);									
+				}
+				break;
+			}
+			else if ((key < 0x21) || (key > 0x80))
+			{
+				continue;
+			}
+			else
+			{
+				file_buff[index++] = key;
+				printf("%c",key);
+				if (index > 512)
+				{
+					index = 0x00;
+				}
+			}
+		}
+	}
+	else
+	{
+		printf("\r\n打开文件失败,错误代码: %u",res);
+	}
+}
+void read_file(void)
+{
+
+	FATFS fs;
+	FIL	file;
+	FRESULT res; 
+	DIR dirs;
+	FILINFO finfo;
+	char path[20];
+	char buffer[512] = {0};
+	uint32_t i;
+	uint8_t length=0;
+	uint32_t re,files_num = 0;
+	res = f_mount(0,&fs);
+	if (res != FR_OK)
+	{
+		printf("\r\n挂载文件系统失败,错误代码: %u",res);
+		return;
+	}
+	res = f_opendir(&dirs,"/");
+	if (res == FR_OK) 
+	{
+		//i = strlen(path);
+		printf("\r\n-----------文件列表-------");
+		while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.fname[0]) 
+		{
+			if (finfo.fattrib & AM_DIR)//如果是文件夹 
+			{ 
+				continue;
+			} 
+			else 
+			{   
+				files_num++;
+				//显示文件名,显示文件实际大小 ,文件实际大小采用四舍五入法
+				printf("\r\n/%12s%7ld KB ",  &finfo.fname[0],(finfo.fsize+512)/1024);
+ 			}
+		}
+		if( files_num == 0 )//无文件
+		{
+			printf("\r\n无文件,请返回先创建文件!");
+			return;
+		}
+	}
+	else
+	{
+		printf("\r\n打开根目录失败!");
+		printf("\r\n错误代码: %u",res);
+	}
+	printf("\r\n输入文件全名,以回车结束...");
+	get_file_name((uint8_t *)path,length,FI);
+	res = f_open(&file,path,FA_READ);
+	printf("\r\n正在打开文件,以下是文件数据:\r\n");
+
+	if (res == FR_OK)
+	{
+		while (1)
+		{
+			for(i = 0;i < 512;i++)
+			{
+				buffer[i] = 0x00;
+			}
+			res = f_read(&file,buffer,512,&re);
+			printf("%s",buffer);
+
+			if (res || re == 0)
+			{
+				printf("\r\n文件读取结束,关闭文件!");
+				f_close(&file);
+				break;  
+			}	
+		}
+	}
+	f_mount(0,NULL);
+}
+
+void creat_dir(void)
+{
+	FATFS fs;        
+	FRESULT res;     
+	char path[20];
+	uint8_t length=0;
+	res = f_mount(0,&fs);
+	if (res != FR_OK)
+	{
+		printf("\r\n挂载文件系统失败,错误代码: %u",res);
+		return;
+	}	
+	printf("\r\n请输入文件夹名,回车确认...格式 8 + 3...");
+	get_file_name((uint8_t *)path,length,DI);
+	res = f_mkdir(path);
+	if (res == FR_OK)
+	{
+		printf("\r\n创建文件目录成功!");
+	}
+	else
+	{
+		printf("\r\n创建目录失败...");
+		printf("\r\n错误代码: %u",res);
+	}
+	f_mount(0,NULL);
+}
+
+
+void get_file_name(uint8_t *file_name,uint8_t length,uint8_t type)
+{
+	uint8_t key;
+	uint8_t name_leng = 0;
+	printf("\r\n");
+	
+	while (1)
+	{
+		key = GetKey();
+		if ((key == 13) && (name_leng == 0))
+		{
+			printf("\r\n");
+			continue;
+		}
+		else if ((key == 0x2F) || (key == 0x5C))
+		{
+			printf("%c",key);
+			continue;
+		}
+		else if ((key == 13) && (name_leng > 0))
+		{
+			printf("\r\n");
+			if (type == FI)
+			{
+				if (check_file_name(file_name,name_leng) == 0)
+				{
+					break;
+				}
+			}
+			else
+			{
+				break;
+			}			
+			
+		}
+		else
+		{
+			printf("%c",key);
+			file_name[name_leng] = key;
+			name_leng++;
+			if (name_leng > 12)
+			{
+				printf("\r\n文件名格式: 8 + 3,只支持8个字符,3个扩展名!");
+				printf("\r\n请重新输入...");
+				name_leng = 0;
+				continue;
+			}
+		}
+	}
+}
+void format_disk(void)
+{
+	FATFS fs;
+	uint8_t res;
+	res = f_mount(0,&fs);
+	if (res != FR_OK)
+	{
+		printf("\r\n挂载文件系统失败,错误代码: %u",res);
+		return;
+	}	
+	printf("\r\n正在格式化磁盘,请稍候...");
+
+	res = f_mkfs(0,1,4096);
+	if (res == FR_OK)
+	{
+		printf("\r\n格式化成功...");
+	}
+	else
+	{
+		printf("\r\n格式化失败...");
+		printf("\r\n错误代码: %u\r\n",res);
+	}
+	f_mount(0,NULL);
+}
+void creat_file(void)
+{
+	FIL file;
+	FIL *pf = &file;
+	FATFS fs;
+	uint8_t res;
+	uint8_t name[16] = {0};
+	uint8_t length = 0;
+	printf("\r\n请输入文件名,回车确认...格式 8 + 3...");
+	printf("\r\n例:123.dat\r\n");
+	get_file_name(name,length,FI);	
+	res = f_mount(0,&fs);		                           /* Mount a Logical Drive 0 */
+	if (res != FR_OK)
+	{
+		printf("\r\n挂载文件系统失败,错误代码: %u",res);
+		return;
+	}	
+	res = f_open(pf,(TCHAR *)name,FA_READ | FA_WRITE | FA_CREATE_NEW);
+	if (res == FR_OK)
+	{
+		printf("\r\n创建文件成功!");
+		res = f_close(pf);
+		if (res != FR_OK)
+		{
+			printf("\r\n创建文件成功,但关闭文件时,失败!");
+			printf("\r\n错误代码: %u",res);				
+		}				
+	}
+	else
+	{
+		printf("\r\n创建文件失败!");
+		printf("\r\n错误代码: %u",res);	
+	}
+	f_mount(0,NULL);
+}
+void delete_file(void)
+{
+	FATFS fs;
+	FRESULT res;
+	DIR dirs;
+	FILINFO finfo;
+	uint8_t name[16] = {0};
+	uint8_t length = 0;
+	uint32_t files_num = 0;
+
+	res = f_mount(0,&fs);		      /* Mount a Logical Drive 0*/	 
+	if (res != FR_OK)
+	{
+		printf("\r\n挂载文件系统失败,错误代码: %u",res);
+		return;
+	}
+
+	res = f_opendir(&dirs,"/");		 /* Create a Directroy Object */
+	if (res == FR_OK) 
+	{
+		printf("\r\n-----------文件列表-------");
+		while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.fname[0]) 
+		{
+			if (finfo.fattrib & AM_DIR)//如果是文件夹 
+			{ 
+				continue;
+			} 
+			else 
+			{   
+				files_num++;
+				//显示文件名,显示文件实际大小 ,文件实际大小采用四舍五入法
+				printf("\r\n/%12s%7ld KB ",  &finfo.fname[0],(finfo.fsize+512)/1024);
+ 			}
+		}
+		if( files_num == 0 )//无文件
+		{
+			printf("\r\n无文件,请返回先创建文件!");
+			return;
+		}
+	}
+
+	get_file_name(name,length,FI);    /* Get file name */
+	
+	res = f_unlink((TCHAR *)name);	  /* Delete a File or Directory */
+
+	if (res == FR_OK)
+	{
+		printf("\r\n删除文件成功!");
+	}
+	else if (res == FR_NO_FILE)
+	{
+		printf("\r\n找不到文件或目录!");
+	}
+	else if (res == FR_NO_PATH)
+	{
+		printf("\r\n找不到路径!");
+	}
+	else
+	{
+		printf("\r\n错误代码: %u",res);
+	}
+	f_mount(0,NULL);
+}
+void list_file(void)
+{
+	FATFS fs;
+	FILINFO finfo;
+	FRESULT res;
+	DIR dirs;
+	int i;
+	int files_num=0;
+	res = f_mount(0,&fs);
+	if (res != FR_OK)
+	{
+		printf("\r\n挂载文件系统失败,错误代码: %u",res);
+		return;
+	}	
+	res = f_opendir(&dirs,"/");							/* Create a Directroy Object */
+	printf("\r\n------------文件列表------------");
+	if (res == FR_OK)
+	{
+		while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.fname[0]) 	 /* Read Directory Entry in Sequense*/
+		{
+			i = strlen(finfo.fname);
+			if (finfo.fattrib & AM_DIR)//如果是文件夹 
+			{
+				files_num++;
+				printf("\r\n/%s", &finfo.fname[0]);
+				switch(i)//作用:输出文件名左对齐
+				{
+				case 1:printf(" ");
+				case 2:printf(" ");
+				case 3:printf(" ");
+				case 4:printf(" ");
+				case 5:printf(" ");
+				case 6:printf(" ");
+				case 7:printf(" ");
+				case 8:printf("%15s"," ");
+				}	
+			} 
+			else 
+			{
+				continue;
+			}	
+		}
+	}
+	else
+	{
+		printf("\r\n打开根目录失败!");
+		printf("\r\n错误代码: %u",res);
+	}
+	res = f_opendir(&dirs, "/");
+	if (res == FR_OK) 
+	{
+		while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.fname[0]) 
+		{
+			if (finfo.fattrib & AM_DIR) 
+			{ 
+				continue;
+			} 
+			else 
+			{   
+				files_num++;				
+				printf("\r\n/.%12s%7ld KB ",  &finfo.fname[0],(finfo.fsize+512)/1024);				
+			}
+		}
+		if( files_num==0 )//无文件
+		{
+			printf("\r\n无文件!");    
+		}
+	}
+	else
+	{
+		printf("\r\n打开根目录失败!");
+		printf("\r\n错误代码: %u",res);
+	}
+	f_mount(0,NULL);
+
+}
+void get_disk_info(void)
+{
+	FATFS fs;
+	FATFS *fls = &fs;
+	FRESULT res;
+	DWORD fre_clust;	
+	
+	res = f_mount(0,&fs);						 /* Mount a Logical Drive 0 */
+	if (res != FR_OK)
+	{
+		printf("\r\n挂载文件系统失败,错误代码: %u",res);
+		return;
+	}	
+
+	res = f_getfree("/",&fre_clust,&fls);		 /* Get Number of Free Clusters */
+	if (res == FR_OK) 
+	{
+	                                             /* Print free space in unit of MB (assuming 4096 bytes/sector) */
+        printf("\r\n%d KB Total Drive Space.\r\n"
+               "%d KB Available Space.\r\n",
+               ((fls->n_fatent-2)*fls->csize)*4,(fre_clust*fls->csize)*4);
+	}
+	else
+	{
+		printf("\r\n获得磁盘信息失败!");
+		printf("\r\n错误代码: %u",res);
+	}																									   
+	f_mount(0,NULL);						     /*Unmount a Logical Drive 0 */ 
+}
+uint8_t check_file_name(uint8_t *file_name,uint8_t length)
+{
+	uint8_t res;
+	if (length > 13)
+	{
+		res = 1;
+	}
+	else
+	{
+		if (file_name[length - 4] == '.')
+		{
+			res = 0;
+		}
+		else
+		{
+			res = 2;
+		}
+	}
+	return res;
+
+}
+
+void SerialPutChar(uint8_t c)
+{
+	USART_SendData(USART1, c);
+	while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
+}
+
+void Serial_PutString(uint8_t *s)
+{
+	while (*s != '\0')
+	{
+		SerialPutChar(*s);
+		s ++;
+	}
+}
+
+/**
+  * @brief  Test to see if a key has been pressed on the HyperTerminal
+  * @param  key: The key pressed
+  * @retval 1: Correct
+  *         0: Error
+  */
+uint32_t SerialKeyPressed(uint8_t *key)
+{
+
+  if ( USART_GetFlagStatus(USART1, USART_FLAG_RXNE) != RESET)
+  {
+    *key = (uint8_t)USART1->DR;
+    return 1;
+  }
+  else
+  {
+    return 0;
+  }
+}
+/**
+  * @brief  Get a key from the HyperTerminal
+  * @param  None
+  * @retval The Key Pressed
+  */
+uint8_t GetKey(void)
+{
+  uint8_t key = 0;
+
+  /* Waiting for user input */
+  while (1)
+  {
+    if (SerialKeyPressed((uint8_t*)&key)) break;
+  }
+  return key;
+
+}
+void Sys_Soft_Reset(void)
+{   
+	SCB->AIRCR =0X05FA0000|(u32)0x04;	  
+}
+
+#if 0
+void GPIO_KEY_Config(void)
+{
+  GPIO_InitTypeDef GPIO_InitStructure;
+
+  /* Configure KEY1 Button */
+  RCC_APB2PeriphClockCmd(RCC_KEY1, ENABLE);
+
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
+  GPIO_InitStructure.GPIO_Pin = GPIO_KEY1;
+  GPIO_Init(GPIO_KEY1_PORT, &GPIO_InitStructure);
+
+  /* Configure KEY2 Button */
+  RCC_APB2PeriphClockCmd(RCC_KEY2, ENABLE);
+
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
+  GPIO_InitStructure.GPIO_Pin = GPIO_KEY2;
+  GPIO_Init(GPIO_KEY2_PORT, &GPIO_InitStructure);
+
+  /* Configure KEY3 Button */
+  RCC_APB2PeriphClockCmd(RCC_KEY3, ENABLE);
+
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
+  GPIO_InitStructure.GPIO_Pin = GPIO_KEY3;
+  GPIO_Init(GPIO_KEY3_PORT, &GPIO_InitStructure);  
+
+  /* Configure KEY4 Button */
+  RCC_APB2PeriphClockCmd(RCC_KEY4, ENABLE);
+
+  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
+  GPIO_InitStructure.GPIO_Pin = GPIO_KEY4;
+  GPIO_Init(GPIO_KEY4_PORT, &GPIO_InitStructure);
+
+}
+
+void USART1_Init(void)
+{
+  USART_InitTypeDef USART_InitStructure;
+  /* USARTx configured as follow:
+        - BaudRate = 115200 baud  
+        - Word Length = 8 Bits
+        - One Stop Bit
+        - No parity
+        - Hardware flow control disabled (RTS and CTS signals)
+        - Receive and transmit enabled
+  */
+  USART_InitStructure.USART_BaudRate = 115200;
+  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
+  USART_InitStructure.USART_StopBits = USART_StopBits_1;
+  USART_InitStructure.USART_Parity = USART_Parity_No;
+  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
+  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
+
+  STM_EVAL_COMInit(COM1, &USART_InitStructure);
+
+}
+#endif
+
+int fputc(int ch, FILE *f)
+{
+   USART_SendData(USART1, (u8) ch);
+   while(!(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == SET))
+   {
+   }
+   return ch;
+}
+
+int fgetc(FILE *f)
+{
+   while(!(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == SET))
+   {
+   }
+   return (USART_ReceiveData(USART1));
+}
+

+ 60 - 0
app/DMA/common.h

@@ -0,0 +1,60 @@
+#ifndef _COMMON_H_
+#define _COMMON_H_  1
+
+#include "stm32f10x.h"
+
+#define FI 1
+#define DI 2
+
+/* Values magic to the Board keys */
+#define  NOKEY  0
+#define  KEY1   1
+#define  KEY2   2
+#define  KEY3   3
+#define  KEY4   4
+
+#define RCC_KEY1                                    RCC_APB2Periph_GPIOD
+#define GPIO_KEY1_PORT                              GPIOD    
+#define GPIO_KEY1                                   GPIO_Pin_3
+
+#define RCC_KEY2                                    RCC_APB2Periph_GPIOA
+#define GPIO_KEY2_PORT                              GPIOA  
+#define GPIO_KEY2                                   GPIO_Pin_8
+
+#define RCC_KEY3                                    RCC_APB2Periph_GPIOC
+#define GPIO_KEY3_PORT                              GPIOC    
+#define GPIO_KEY3                                   GPIO_Pin_13 
+
+#define RCC_KEY4                                    RCC_APB2Periph_GPIOA
+#define GPIO_KEY4_PORT                              GPIOA    
+#define GPIO_KEY4                                   GPIO_Pin_0 
+
+#define GPIO_KEY_ANTI_TAMP                          GPIO_KEY3
+#define GPIO_KEY_WEAK_UP                            GPIO_KEY4
+
+
+
+
+
+void fat_menu_init(void);
+void GPIO_KEY_Config(void);
+void USART1_Init(void);
+
+uint32_t SerialKeyPressed(uint8_t *key);
+void Serial_PutString(uint8_t *s);
+uint8_t GetKey(void);
+void Sys_Soft_Reset(void);
+void get_file_name(uint8_t *file_name,uint8_t length,uint8_t type);
+uint8_t check_file_name(uint8_t *file_name,uint8_t length);
+
+void format_disk(void);
+void creat_file(void);
+void delete_file(void);
+void list_file(void);
+void get_disk_info(void);
+void creat_dir(void);
+void edit_file(void);
+void read_file(void);
+
+#endif
+

+ 312 - 0
app/DMA/flash.c

@@ -0,0 +1,312 @@
+#include "flash.h" 
+//#include "spi.h"
+#include "SPI_DMA.h"
+#include "delay.h"   
+
+
+//4Kbytes为一个Sector
+//16个扇区为1个Block
+//W25X16
+//容量为2M字节,共有32个Block,512个Sector 
+
+//初始化SPI FLASH的IO口
+uint8_t SPI_Flash_Init(void)
+{
+	//SPIx_Init();		   //初始化SPI
+	return 0;
+}  
+
+//读取SPI_FLASH的状态寄存器
+//BIT7  6   5   4   3   2   1   0
+//SPR   RV  TB BP2 BP1 BP0 WEL BUSY
+//SPR:默认0,状态寄存器保护位,配合WP使用
+//TB,BP2,BP1,BP0:FLASH区域写保护设置
+//WEL:写使能锁定
+//BUSY:忙标记位(1,忙;0,空闲)
+//默认:0x00
+u8 SPI_Flash_ReadSR(void)   
+{  
+	u8 byte=0;   
+	SPI_FLASH_CS=0;                            //使能器件   
+	SPIx_ReadWriteByte(W25X_ReadStatusReg);    //发送读取状态寄存器命令    
+	byte=SPIx_ReadWriteByte(0Xff);             //读取一个字节  
+	SPI_FLASH_CS=1;                            //取消片选     
+	return byte;   
+} 
+//写SPI_FLASH状态寄存器
+//只有SPR,TB,BP2,BP1,BP0(bit 7,5,4,3,2)可以写!!!
+void SPI_FLASH_Write_SR(u8 sr)   
+{   
+	SPI_FLASH_CS=0;                            //使能器件   
+	SPIx_ReadWriteByte(W25X_WriteStatusReg);   //发送写取状态寄存器命令    
+	SPIx_ReadWriteByte(sr);               //写入一个字节  
+	SPI_FLASH_CS=1;                            //取消片选     	      
+}   
+//SPI_FLASH写使能	
+//将WEL置位   
+void SPI_FLASH_Write_Enable(void)   
+{
+	SPI_FLASH_CS=0;                            //使能器件   
+    SPIx_ReadWriteByte(W25X_WriteEnable);      //发送写使能  
+	SPI_FLASH_CS=1;                            //取消片选     	      
+} 
+//SPI_FLASH写禁止	
+//将WEL清零  
+void SPI_FLASH_Write_Disable(void)   
+{  
+	SPI_FLASH_CS=0;                            //使能器件   
+    SPIx_ReadWriteByte(W25X_WriteDisable);     //发送写禁止指令    
+	SPI_FLASH_CS=1;                            //取消片选     	      
+} 			    
+//读取芯片ID W25X16的ID:0XEF14
+u16 SPI_Flash_ReadID(void)
+{
+	u16 Temp = 0;	  
+	SPI_FLASH_CS=0;				    
+	SPIx_ReadWriteByte(0x90);//发送读取ID命令	    
+	SPIx_ReadWriteByte(0x00); 	    
+	SPIx_ReadWriteByte(0x00); 	    
+	SPIx_ReadWriteByte(0x00); 	 			   
+	Temp|=SPIx_ReadWriteByte(0xFF)<<8;  
+	Temp|=SPIx_ReadWriteByte(0xFF);	 
+	SPI_FLASH_CS=1;				    
+	return Temp;
+}   		    
+//读取SPI FLASH  
+//在指定地址开始读取指定长度的数据
+//pBuffer:数据存储区
+//ReadAddr:开始读取的地址(24bit)
+//NumByteToRead:要读取的字节数(最大65535)
+void SPI_Flash_Read(u8* pBuffer,u32 ReadAddr,u16 NumByteToRead)   
+{ 
+ 	u16 i;    												    
+	SPI_FLASH_CS=0;                            //使能器件   
+    SPIx_ReadWriteByte(W25X_ReadData);         //发送读取命令   
+    SPIx_ReadWriteByte((u8)((ReadAddr)>>16));  //发送24bit地址    
+    SPIx_ReadWriteByte((u8)((ReadAddr)>>8));   
+    SPIx_ReadWriteByte((u8)ReadAddr);   
+    for(i=0;i<NumByteToRead;i++)
+	{ 
+        pBuffer[i]=SPIx_ReadWriteByte(0XFF);   //循环读数  
+    }
+	SPI_FLASH_CS=1;                            //取消片选     	      
+}  
+//SPI在一页(0~65535)内写入少于256个字节的数据
+//在指定地址开始写入最大256字节的数据
+//pBuffer:数据存储区
+//WriteAddr:开始写入的地址(24bit)
+//NumByteToWrite:要写入的字节数(最大256),该数不应该超过该页的剩余字节数!!!	 
+void SPI_Flash_Write_Page(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite)
+{
+ 	u16 i;  
+    SPI_FLASH_Write_Enable();                  //SET WEL 
+	SPI_FLASH_CS=0;                            //使能器件   
+    SPIx_ReadWriteByte(W25X_PageProgram);      //发送写页命令   
+    SPIx_ReadWriteByte((u8)((WriteAddr)>>16)); //发送24bit地址    
+    SPIx_ReadWriteByte((u8)((WriteAddr)>>8));   
+    SPIx_ReadWriteByte((u8)WriteAddr);   
+    for(i=0;i<NumByteToWrite;i++)SPIx_ReadWriteByte(pBuffer[i]);//循环写数  
+	SPI_FLASH_CS=1;                            //取消片选 
+	SPI_Flash_Wait_Busy();					   //等待写入结束
+} 
+//无检验写SPI FLASH 
+//必须确保所写的地址范围内的数据全部为0XFF,否则在非0XFF处写入的数据将失败!
+//具有自动换页功能 
+//在指定地址开始写入指定长度的数据,但是要确保地址不越界!
+//pBuffer:数据存储区
+//WriteAddr:开始写入的地址(24bit)
+//NumByteToWrite:要写入的字节数(最大65535)
+//CHECK OK
+void SPI_Flash_Write_NoCheck(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite)   
+{ 			 		 
+	u16 pageremain;	   
+	pageremain=256-WriteAddr%256; //单页剩余的字节数		 	    
+	if(NumByteToWrite<=pageremain)pageremain=NumByteToWrite;//不大于256个字节
+	while(1)
+	{	   
+		SPI_Flash_Write_Page(pBuffer,WriteAddr,pageremain);
+		if(NumByteToWrite==pageremain)break;//写入结束了
+	 	else //NumByteToWrite>pageremain
+		{
+			pBuffer+=pageremain;
+			WriteAddr+=pageremain;	
+
+			NumByteToWrite-=pageremain;			  //减去已经写入了的字节数
+			if(NumByteToWrite>256)pageremain=256; //一次可以写入256个字节
+			else pageremain=NumByteToWrite; 	  //不够256个字节了
+		}
+	};	    
+} 
+//写SPI FLASH  
+//在指定地址开始写入指定长度的数据
+//该函数带擦除操作!
+//pBuffer:数据存储区
+//WriteAddr:开始写入的地址(24bit)
+//NumByteToWrite:要写入的字节数(最大65535)  		   
+u8 SPI_FLASH_BUF[4096];
+void SPI_Flash_Write(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite)   
+{ 
+	u32 secpos;
+	u16 secoff;
+	u16 secremain;	   
+ 	u16 i;  
+	secpos=WriteAddr/4096;//扇区地址 0~511 for w25x16
+	secoff=WriteAddr%4096;//在扇区内的偏移
+	secremain=4096-secoff;//扇区剩余空间大小   
+	if(NumByteToWrite<=secremain)secremain=NumByteToWrite;//不大于4096个字节
+	while(1) 
+	{	
+		SPI_Flash_Read(SPI_FLASH_BUF,secpos*4096,4096);//读出整个扇区的内容
+		for(i=0;i<secremain;i++)//校验数据
+		{
+			if(SPI_FLASH_BUF[secoff+i]!=0XFF)break;//需要擦除  	  
+		}
+		if(i<secremain)//需要擦除
+		{
+			SPI_Flash_Erase_Sector(secpos);//擦除这个扇区
+			for(i=0;i<secremain;i++)	   //复制
+			{
+				SPI_FLASH_BUF[i+secoff]=pBuffer[i];	  
+			}
+			SPI_Flash_Write_NoCheck(SPI_FLASH_BUF,secpos*4096,4096);//写入整个扇区  
+
+		}else SPI_Flash_Write_NoCheck(pBuffer,WriteAddr,secremain);//写已经擦除了的,直接写入扇区剩余区间. 				   
+		if(NumByteToWrite==secremain)break;//写入结束了
+		else//写入未结束
+		{
+			secpos++;//扇区地址增1
+			secoff=0;//偏移位置为0 	 
+
+		   	pBuffer+=secremain;  //指针偏移
+			WriteAddr+=secremain;//写地址偏移	   
+		   	NumByteToWrite-=secremain;				//字节数递减
+			if(NumByteToWrite>4096)secremain=4096;	//下一个扇区还是写不完
+			else secremain=NumByteToWrite;			//下一个扇区可以写完了
+		}	 
+	};	 	 
+}
+
+//擦除整个芯片
+//整片擦除时间:
+//W25X16:25s 
+//W25X32:40s 
+//W25X64:40s 
+//等待时间超长...
+void SPI_Flash_Erase_Chip(void)   
+{                                             
+    SPI_FLASH_Write_Enable();                  //SET WEL 
+    SPI_Flash_Wait_Busy();   
+  	SPI_FLASH_CS=0;                            //使能器件   
+    SPIx_ReadWriteByte(W25X_ChipErase);        //发送片擦除命令  
+	SPI_FLASH_CS=1;                            //取消片选     	      
+	SPI_Flash_Wait_Busy();   				   //等待芯片擦除结束
+}   
+//擦除一个扇区
+//Dst_Addr:扇区地址 0~511 for w25x16
+//擦除一个山区的最少时间:150ms
+void SPI_Flash_Erase_Sector(u32 Dst_Addr)   
+{   
+	Dst_Addr*=FLASH_SECTOR_SIZE;
+    SPI_FLASH_Write_Enable();                  //SET WEL 	 
+    SPI_Flash_Wait_Busy();   
+  	SPI_FLASH_CS=0;                            //使能器件   
+    SPIx_ReadWriteByte(W25X_SectorErase);      //发送扇区擦除指令 
+    SPIx_ReadWriteByte((u8)((Dst_Addr)>>16));  //发送24bit地址    
+    SPIx_ReadWriteByte((u8)((Dst_Addr)>>8));   
+    SPIx_ReadWriteByte((u8)Dst_Addr);  
+	SPI_FLASH_CS=1;                            //取消片选     	      
+    SPI_Flash_Wait_Busy();   				   //等待擦除完成
+}  
+//等待空闲
+void SPI_Flash_Wait_Busy(void)   
+{   
+	while ((SPI_Flash_ReadSR()&0x01)==0x01);   // 等待BUSY位清空
+}  
+//进入掉电模式
+void SPI_Flash_PowerDown(void)   
+{ 
+  	SPI_FLASH_CS=0;                            //使能器件   
+    SPIx_ReadWriteByte(W25X_PowerDown);        //发送掉电命令  
+	SPI_FLASH_CS=1;                            //取消片选     	      
+    delay_us(3);                               //等待TPD  
+}   
+//唤醒
+void SPI_Flash_WAKEUP(void)   
+{  
+  	SPI_FLASH_CS=0;                            //使能器件   
+    SPIx_ReadWriteByte(W25X_ReleasePowerDown);   //  send W25X_PowerDown command 0xAB    
+	SPI_FLASH_CS=1;                            //取消片选     	      
+    delay_us(3);                               //等待TRES1
+}   
+//Sector Read
+ void W25X_Read_Sector(uint32_t nSector, u8* pBuffer)
+{	
+    uint16_t i;
+	//扇区号转为地址
+	nSector *= FLASH_SECTOR_SIZE;
+
+	SPI_FLASH_CS=0;
+	SPIx_ReadWriteByte(W25X_ReadData);
+	SPIx_ReadWriteByte(((nSector & 0xFFFFFF) >> 16));
+	SPIx_ReadWriteByte(((nSector & 0xFFFF) >> 8));
+	SPIx_ReadWriteByte(nSector & 0xFF);
+	
+	for(i=0;i<FLASH_SECTOR_SIZE;i++)
+	{	
+	  pBuffer[i] = SPIx_ReadWriteByte(0xFF);
+	}
+	SPI_FLASH_CS=1;
+	SPI_Flash_Wait_Busy();
+}
+
+//Sector Write
+void W25X_Write_Sector(uint32_t nSector, u8* pBuffer)
+{	
+	int i,j;
+	//扇区号转为地址
+	nSector *= FLASH_SECTOR_SIZE;
+
+	//一个扇区需要几个页
+	for(j=0;j<FLASH_PAGES_PER_SECTOR;j++)
+	{
+		SPI_FLASH_Write_Enable();                  //SET WEL
+		 
+		SPI_FLASH_CS=0;	 
+		SPIx_ReadWriteByte(W25X_PageProgram);
+	    SPIx_ReadWriteByte(((nSector & 0xFFFFFF) >> 16));
+	    SPIx_ReadWriteByte(((nSector & 0xFFFF) >> 8));
+	    SPIx_ReadWriteByte(nSector & 0xFF);
+		
+		for(i=0;i<FLASH_PAGE_SIZE;i++)								
+		SPIx_ReadWriteByte(pBuffer[i]);
+				
+		pBuffer += FLASH_PAGE_SIZE;
+		nSector += FLASH_PAGE_SIZE;
+
+		SPI_FLASH_CS=1;
+		SPI_Flash_Wait_Busy();
+	}
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 65 - 0
app/DMA/flash.h

@@ -0,0 +1,65 @@
+#ifndef __FLASH_H
+#define __FLASH_H			    
+#include <stm32f10x.h>
+
+#define FLASH_PAGE_SIZE		256
+#define FLASH_SECTOR_SIZE	4096
+#define FLASH_SECTOR_COUNT	512
+#define FLASH_BLOCK_SIZE	65536
+#define FLASH_PAGES_PER_SECTOR	FLASH_SECTOR_SIZE/FLASH_PAGE_SIZE
+
+#define	SPI_FLASH_CS PCout(4)  //选中FLASH					 
+////////////////////////////////////////////////////////////////////////////
+//W25X16读写
+#define FLASH_ID 0XEF14
+//指令表
+#define W25X_WriteEnable		0x06 
+#define W25X_WriteDisable		0x04 
+#define W25X_ReadStatusReg		0x05 
+#define W25X_WriteStatusReg		0x01 
+#define W25X_ReadData			0x03 
+#define W25X_FastReadData		0x0B 
+#define W25X_FastReadDual		0x3B 
+#define W25X_PageProgram		0x02 
+#define W25X_BlockErase			0xD8 
+#define W25X_SectorErase		0x20 
+#define W25X_ChipErase			0xC7 
+#define W25X_PowerDown			0xB9 
+#define W25X_ReleasePowerDown	0xAB 
+#define W25X_DeviceID			0xAB 
+#define W25X_ManufactDeviceID	0x90 
+#define W25X_JedecDeviceID		0x9F 
+
+uint8_t SPI_Flash_Init(void);
+u16  SPI_Flash_ReadID(void);  	    //读取FLASH ID
+u8	 SPI_Flash_ReadSR(void);        //读取状态寄存器 
+void SPI_FLASH_Write_SR(u8 sr);  	//写状态寄存器
+void SPI_FLASH_Write_Enable(void);  //写使能 
+void SPI_FLASH_Write_Disable(void);	//写保护
+void SPI_Flash_Read(u8* pBuffer,u32 ReadAddr,u16 NumByteToRead);   //读取flash
+void SPI_Flash_Write(u8* pBuffer,u32 WriteAddr,u16 NumByteToWrite);//写入flash
+void SPI_Flash_Erase_Chip(void);    	  //整片擦除
+void SPI_Flash_Erase_Sector(u32 Dst_Addr);//扇区擦除
+void SPI_Flash_Wait_Busy(void);           //等待空闲
+void SPI_Flash_PowerDown(void);           //进入掉电模式
+void SPI_Flash_WAKEUP(void);			  //唤醒
+
+void W25X_Read_Sector(uint32_t nSector, u8* pBuffer);
+void W25X_Write_Sector(uint32_t nSector, u8* pBuffer);
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 96 - 0
app/Delay.c

@@ -0,0 +1,96 @@
+#include <stm32f10x.h>
+#include "delay.h"
+
+//使用SysTick的普通计数模式对延迟进行管理
+
+
+//2010/5/27
+
+#if 0 
+static u8  fac_us=0;//us延时倍乘数
+static u16 fac_ms=0;//ms延时倍乘数
+//初始化延迟函数
+//SYSTICK的时钟固定为HCLK时钟的1/8
+//SYSCLK:系统时钟
+void delay_init(u8 SYSCLK)
+{
+	SysTick->CTRL&=0xfffffffb;//bit2清空,选择外部时钟  HCLK/8
+	fac_us=SYSCLK/8;		    
+	fac_ms=(u16)fac_us*1000;
+}								    
+//延时nms
+//注意nms的范围
+//SysTick->LOAD为24位寄存器,所以,最大延时为:
+//nms<=0xffffff*8*1000/SYSCLK
+//SYSCLK单位为Hz,nms单位为ms
+//对72M条件下,nms<=1864 
+void delay_ms(u16 nms)
+{	 		  	  
+	u32 temp;		   
+	SysTick->LOAD=(u32)nms*fac_ms;//时间加载(SysTick->LOAD为24bit)
+	SysTick->VAL =0x00;           //清空计数器
+	SysTick->CTRL=0x01 ;          //开始倒数  
+	do
+	{
+		temp=SysTick->CTRL;
+	}
+	while(temp&0x01&&!(temp&(1<<16)));//等待时间到达   
+	SysTick->CTRL=0x00;       //关闭计数器
+	SysTick->VAL =0X00;       //清空计数器	  	    
+}   
+//延时nus
+//nus为要延时的us数.		    								   
+void delay_us(u32 nus)
+{		
+	u32 temp;	    	 
+	SysTick->LOAD=nus*fac_us; //时间加载	  		 
+	SysTick->VAL=0x00;        //清空计数器
+	SysTick->CTRL=0x01 ;      //开始倒数 	 
+	do
+	{
+		temp=SysTick->CTRL;
+	}
+	while(temp&0x01&&!(temp&(1<<16)));//等待时间到达   
+	SysTick->CTRL=0x00;       //关闭计数器
+	SysTick->VAL =0X00;       //清空计数器	 
+}
+#if 1
+void Delay(vu32 nCount)
+{
+  for(; nCount != 0; nCount--);
+}
+#endif
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 35 - 0
app/Delay.h

@@ -0,0 +1,35 @@
+#ifndef __DELAY_H_
+#define __DELAY_H_
+
+#include <stm32f10x.h>
+
+#if 1
+void Dly1us(unsigned int DelayVal);
+void Dly10us(unsigned int DelayVal);
+void Dly100us(unsigned int DelayVal);
+
+extern unsigned int SystemClockFreq;
+#define DLY_PARA_COMST	(SystemClockFreq/8500000)	//延时参数
+#define DLY_CALL_COMST	(6)							//调用耗时,自定义
+
+#define delayUs(x) { unsigned int _dcnt; \
+      _dcnt=(x*DLY_PARA_COMST-DLY_CALL_COMST); \
+      while(_dcnt-- > 0) \
+      { continue; }\
+     }
+
+#define  delay_us(us)   delayUs(us)
+#define  delay_ms(ms)   delay_us(ms*1000)
+#else
+
+void delay_init(u8 SYSCLK);
+void delay_ms(u16 nms);
+void delay_us(u32 nus);
+void Delay(vu32 nCount);
+
+#endif
+
+
+
+#endif
+

+ 114 - 0
app/FatFS/doc/00index_e.html

@@ -0,0 +1,114 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<meta name="description" content="Open souece FAT file system module for embedded projects">
+<link rel="start" title="Site Top" href="../../">
+<link rel="up" title="Freewares" href="../../fsw_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese version" href="00index_j.html">
+<link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>ELM - FatFs Generic FAT File System Module</title>
+</head>
+
+<body>
+<h1>FatFs Generic FAT File System Module</h1>
+<hr>
+
+<div class="abst">
+<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
+<p>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. It can be incorporated into low cost microcontrollers, such as AVR, 8051, PIC, ARM, Z80, 68k and etc..., without any change. Petit FatFs module is also available <a href="http://elm-chan.org/fsw/ff/00index_p.html">here</a>.</p>
+
+<h4>Features</h4>
+<ul>
+ <li>Windows compatible FAT file system.</li>
+ <li>Platform independent. Easy to port.</li>
+ <li>Very small footprint for code and work area.</li>
+ <li>Various configuration options:
+  <ul>
+   <li>Multiple volumes (physical drives and partitions).</li>
+   <li>Multiple ANSI/OEM code pages including DBCS.</li>
+   <li>Long file name support in ANSI/OEM or Unicode.</li>
+   <li>RTOS support.</li>
+   <li>Multiple sector size support.</li>
+   <li>Read-only, minimized API, I/O buffer and etc...</li>
+  </ul>
+ </li>
+</ul>
+</div>
+
+
+<div class="para">
+<h3>Application Interface</h3>
+<p>FatFs module provides following functions to the applications. In other words, this list describes what FatFs can do to access the FAT volumes.</p>
+<ul>
+<li><a href="en/mount.html">f_mount</a> - Register/Unregister a work area</li>
+<li><a href="en/open.html">f_open</a> - Open/Create a file</li>
+<li><a href="en/close.html">f_close</a> - Close a file</li>
+<li><a href="en/read.html">f_read</a> - Read file</li>
+<li><a href="en/write.html">f_write</a> - Write file</li>
+<li><a href="en/lseek.html">f_lseek</a> - Move read/write pointer, Expand file size</li>
+<li><a href="en/truncate.html">f_truncate</a> - Truncate file size</li>
+<li><a href="en/sync.html">f_sync</a> - Flush cached data</li>
+<li><a href="en/opendir.html">f_opendir</a> - Open a directory</li>
+<li><a href="en/readdir.html">f_readdir</a> - Read a directory item</li>
+<li><a href="en/getfree.html">f_getfree</a> - Get free clusters</li>
+<li><a href="en/stat.html">f_stat</a> - Get file status</li>
+<li><a href="en/mkdir.html">f_mkdir</a> - Create a directory</li>
+<li><a href="en/unlink.html">f_unlink</a> - Remove a file or directory</li>
+<li><a href="en/chmod.html">f_chmod</a> - Change attribute</li>
+<li><a href="en/utime.html">f_utime</a> - Change timestamp</li>
+<li><a href="en/rename.html">f_rename</a> - Rename/Move a file or directory</li>
+<li><a href="en/chdir.html">f_chdir</a> - Change current directory</li>
+<li><a href="en/chdrive.html">f_chdrive</a> - Change current drive</li>
+<li><a href="en/getcwd.html">f_getcwd</a> - Retrieve the current directory</li>
+<li><a href="en/forward.html">f_forward</a> - Forward file data to the stream directly</li>
+<li><a href="en/mkfs.html">f_mkfs</a> - Create a file system on the drive</li>
+<li><a href="en/fdisk.html">f_fdisk</a> - Divide a physical drive</li>
+<li><a href="en/gets.html">f_gets</a> - Read a string</li>
+<li><a href="en/putc.html">f_putc</a> - Write a character</li>
+<li><a href="en/puts.html">f_puts</a> - Write a string</li>
+<li><a href="en/printf.html">f_printf</a> - Write a formatted string</li>
+<li><a href="en/tell.html">f_tell</a> - Get the current read/write pointer</li>
+<li><a href="en/eof.html">f_eof</a> - Test for end-of-file on a file</li>
+<li><a href="en/size.html">f_size</a> - Get size of a file</li>
+<li><a href="en/error.html">f_error</a> - Test for an error on a file</li>
+</ul>
+</div>
+
+
+<div class="para">
+<h3>Disk I/O Interface</h3>
+<p>Since the FatFs module is completely separated from disk I/O layer, it requires following functions at least to access the physical media. When O/S related feature is enabled, it will require process/memory functions in addition. However the low level disk I/O module is not a part of FatFs module so that it must be provided by user. The sample drivers are also available in the resources.</p>
+<ul>
+<li><a href="en/dinit.html">disk_initialize</a> - Initialize disk drive</li>
+<li><a href="en/dstat.html">disk_status</a> - Get disk status</li>
+<li><a href="en/dread.html">disk_read</a> - Read sector(s)</li>
+<li><a href="en/dwrite.html">disk_write</a> - Write sector(s)</li>
+<li><a href="en/dioctl.html">disk_ioctl</a> - Control device dependent features</li>
+<li><a href="en/fattime.html">get_fattime</a> - Get current time</li>
+</ul>
+</div>
+
+
+<div class="para">
+<h3>Resources</h3>
+<p>The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects or commercial products without any restriction under your responsibility. For further information, refer to the application note.</p>
+<ul>
+<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFs User Forum</em></a></li>
+<li>Read first: <a href="en/appnote.html">FatFs module application note</a> <span class="mfd">September 6, 2011</span></li>
+<li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
+<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li>
+<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a> (The reference document on FAT file system)</li>
+<li><a href="http://elm-chan.org/docs/mmc/mmc_e.html">How to Use MMC/SDC</a></li>
+<li><a href="img/rwtest.png">Benchmark 1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li>
+<li><a href="img/rwtest2.png">Benchmark 2</a> (LPC2368/72MHz with MMC via MCI)</li>
+<li><a href="http://members.jcom.home.ne.jp/felm/fd.mp4">Demo movie of an application</a> (this project is in ffsample.zip/lpc23xx)</li>
+</ul>
+</div>
+
+
+<hr>
+<p class="foot"><a href="../../fsw_e.html">Return</a></p>
+</body>
+</html>

+ 113 - 0
app/FatFS/doc/00index_j.html

@@ -0,0 +1,113 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<meta name="description" content="組み込みシステム向けFATファイル・システム">
+<link rel="start" title="Site Top" href="../../index_j.html">
+<link rel="up" title="Freewares" href="../../fsw.html">
+<link rel="alternate" hreflang="en" title="英文" href="00index_e.html">
+<link rel="stylesheet" href="css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>ELM - FatFs 汎用FATファイルシステム・モジュール</title>
+</head>
+
+<body>
+<h1>FatFs 汎用FATファイルシステム・モジュール</h1>
+<hr>
+
+<div class="abst">
+<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
+<p>FatFsは小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、8051, PIC, AVR, SH, Z80, 68k, H8, ARMなど安価なマイコンでも使用可能です。FatFsをシュリンクした<a href="http://elm-chan.org/fsw/ff/00index_p.html">ぷちFatFs</a>もあります。</p>
+<h4>FatFsモジュールの特徴</h4>
+<ul>
+ <li>Windows互換 FATファイル・システム</li>
+ <li>プラットフォーム非依存</li>
+ <li>コンパクトなコードとRAM使用量</li>
+ <li>多くの構成オプション:
+  <ul>
+   <li>複数のボリューム(物理ドライブ・区画)</li>
+   <li>DBCSを含む複数のANSI/OEMコード・ページ</li>
+   <li>長いファイル名(LFN) (Unicode APIも選択可)</li>
+   <li>マルチタスク関連</li>
+   <li>マルチ・セクタ・サイズ</li>
+   <li>リード・オンリー構成、一部APIの削除、バッファ構成、その他…</li>
+  </ul>
+ </li>
+</ul>
+</div>
+
+
+<div class="para">
+<h3>上位レイヤ・インターフェース</h3>
+<p>FatFsモジュールは、次のファイル操作関数(API)を提供します。つまり、このリストはFatFsにできることをシンプルに示しています。</p>
+<ul>
+<li><a href="ja/mount.html">f_mount</a> - ワークエリアの登録・削除</li>
+<li><a href="ja/open.html">f_open</a> - ファイルのオープン・作成</li>
+<li><a href="ja/close.html">f_close</a> - ファイルのクローズ</li>
+<li><a href="ja/read.html">f_read</a> - ファイルの読み出し</li>
+<li><a href="ja/write.html">f_write</a> - ファイルの書き込み</li>
+<li><a href="ja/lseek.html">f_lseek</a> - リード/ライト・ポインタの移動, ファイルの拡張</li>
+<li><a href="ja/truncate.html">f_truncate</a> - ファイル・サイズの切り詰め</li>
+<li><a href="ja/sync.html">f_sync</a> - キャッシュされたデータのフラッシュ</li>
+<li><a href="ja/opendir.html">f_opendir</a> - ディレクトリのオープン</li>
+<li><a href="ja/readdir.html">f_readdir</a> - ディレクトリの読み出し</li>
+<li><a href="ja/getfree.html">f_getfree</a> - ボリューム空き領域の取得</li>
+<li><a href="ja/stat.html">f_stat</a> - ファイル・ステータスの取得</li>
+<li><a href="ja/mkdir.html">f_mkdir</a> - ディレクトリの作成</li>
+<li><a href="ja/unlink.html">f_unlink</a> - ファイル/ディレクトリの削除</li>
+<li><a href="ja/chmod.html">f_chmod</a> - ファイル/ディレクトリの属性の変更</li>
+<li><a href="ja/utime.html">f_utime</a> - ファイル/ディレクトリのタイムスタンプの変更</li>
+<li><a href="ja/rename.html">f_rename</a> - ファイル/ディレクトリの名前変更・移動</li>
+<li><a href="ja/chdir.html">f_chdir</a> - カレント・ディレクトリの変更</li>
+<li><a href="ja/chdrive.html">f_chdrive</a> - カレント・ドライブの変更</li>
+<li><a href="ja/getcwd.html">f_getcwd</a> - カレント・ディレクトリの取得</li>
+<li><a href="ja/forward.html">f_forward</a> - ファイル・データをストリーム関数に転送</li>
+<li><a href="ja/mkfs.html">f_mkfs</a> - 論理ドライブのフォーマット</li>
+<li><a href="ja/fdisk.html">f_fdisk</a> - 物理ドライブの分割</li>
+<li><a href="ja/gets.html">f_gets</a> - 文字列の読み出し</li>
+<li><a href="ja/putc.html">f_putc</a> - 文字の書き込み</li>
+<li><a href="ja/puts.html">f_puts</a> - 文字列の書き込み</li>
+<li><a href="ja/printf.html">f_printf</a> - 書式化文字列の書き込み</li>
+<li><a href="ja/tell.html">f_tell</a> - 現在のリード/ライト・ポインタの取得</li>
+<li><a href="ja/eof.html">f_eof</a> - ファイル終端の有無の取得</li>
+<li><a href="ja/size.html">f_size</a> - ファイル・サイズの取得</li>
+<li><a href="ja/error.html">f_error</a> - ファイルのエラーの有無の取得</li>
+</ul>
+</div>
+
+
+<div class="para">
+<h3>下位レイヤ・インターフェース</h3>
+<p>FatFsモジュールは、物理ドライブ等へのアクセスのため、下位レイヤに少なくとも次のインターフェースを要求します。使用する記録メディアに対応したディスクI/Oモジュールは、ユーザによって用意される必要があります。OS関連機能を有効にしたときは、加えてプロセス・メモリ関連関数も必要になります。資料にドライバを含むサンプル・プロジェクトあり。</p>
+<ul>
+<li><a href="ja/dinit.html">disk_initialize</a> - ドライブの初期化</li>
+<li><a href="ja/dstat.html">disk_status</a> - ドライブの状態取得</li>
+<li><a href="ja/dread.html">disk_read</a> - データの読み出し</li>
+<li><a href="ja/dwrite.html">disk_write</a> - データの書き込み</li>
+<li><a href="ja/dioctl.html">disk_ioctl</a> - その他のドライブ制御</li>
+<li><a href="ja/fattime.html">get_fattime</a> - 日付・時刻の取得</li>
+</ul>
+</div>
+
+
+<div class="para">
+<h3>資料</h3>
+<p>FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人利用から商用まで)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ノートを参照してください。</p>
+<ul>
+<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFsユーザ・フォーラム</em></a></li>
+<li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ノート</a> <span class="mfd">2011. 9. 6</span></li>
+<li><a href="http://nemuisan.blog.bai.ne.jp/">ねむいさんのぶろぐ</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
+<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li>
+<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイル・システム仕様書 by Microsoft</a> (FATの理解・実装に必要な唯一のリファレンス)</li>
+<li><a href="http://elm-chan.org/docs/fat.html">FATファイル・システム概要</a> (↑を読むためのガイド)</li>
+<li><a href="http://elm-chan.org/docs/mmc/mmc.html">MMCの使いかた</a></li>
+<li><a href="img/rwtest.png">パフォーマンス・テスト1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li>
+<li><a href="img/rwtest2.png">パフォーマンス・テスト2</a> (LPC2368/72MHz with MMC via MCI)</li>
+</ul>
+</div>
+
+
+<hr>
+<p class="foot"><a href="../../fsw.html">戻る</a></p>
+</body>
+</html>

+ 59 - 0
app/FatFS/doc/css_e.css

@@ -0,0 +1,59 @@
+* {margin: 0; padding: 0; border-width: 0;}
+body {margin: 8px; background-color: #e0ffff; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;}
+a:link {color: blue;}
+a:visited {color: darkmagenta;}
+a:hover {background-color: #a0ffff;}
+a:active {color: darkmagenta; position: relative; top: 1px; left: 1px;}
+abbr {border-width: 1px;}
+
+p {margin: 0 0 0.3em 1em;}
+em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
+pre em {font-style: italic; font-weight: normal;}
+strong {}
+pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-family: monospace; background-color: white;}
+pre span.c {color: green;}
+pre span.k {color: blue;}
+tt {margin: 0 0.2em; font-family: monospace; }
+ol {margin: 0 2.5em;}
+ul {margin: 0 2em;}
+dl {margin: 0 1em;}
+dt {font-family: monospace;}
+dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; }
+dl.ret dt {margin: 0.5em 0 0 0 ; font-weight: bold;}
+dd {margin: 0 2em;}
+hr {border-width: 1px; margin: 1em;}
+div.abst {font-family: sans-serif;}
+div.para {clear: both; font-family: serif;}
+div.ret a {font-family: monospace; }
+.equ {text-indent: 0; margin: 1em 2em 1em;}
+.indent {margin-left: 2em;}
+.rset {float: right; margin: 0 0 0.5em 0.5em;}
+.lset {float: left; margin: 0 0.5em 0.5em 0.5em;}
+ul.flat li {list-style-type: none; margin: 0;}
+a.imglnk img {border: 1px solid;}
+.iequ {white-space: nowrap; font-weight: bold;}
+.clr {clear: both;}
+.it {font-style: italic;}
+.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap}
+
+h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
+p.hdd {float: right; text-align: right; margin-top: 0.5em;}
+hr.hds {clear: both; margin-bottom: 1em;}
+
+h2 {font-size: 1.6em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.2em 0.5em; margin: 0 0 0.5em;}
+h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;}
+h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;}
+h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;}
+small {font-size: 80%;}
+.indent {margin-left: 2em;}
+
+/* Tables */
+table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; }
+th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top; white-space: nowrap;}
+td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;}
+table.lst td:first-child {font-family: monospace;}
+table.lst2 td {font-family: monospace;}
+table caption {font-family: sans-serif; font-weight: bold;}
+tr.lst3 td { border-width: 2px 1px 1px; }
+
+p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}

+ 62 - 0
app/FatFS/doc/css_j.css

@@ -0,0 +1,62 @@
+@charset "Shift_JIS";
+/* Common style sheet for Tech Notes */
+
+* {margin: 0; padding: 0; border-width: 0;}
+body {margin: 8px; background-color: #e0ffff; font-color: black; font-family:"MS P明朝", serif; line-height: 150%; letter-spacing: 1px; max-width: 1024px;}
+a:link {color: blue;}
+a:visited {color: darkmagenta;}
+a:hover {background-color: #a0ffff;}
+a:active {color: darkmagenta; position: relative; top: 1px; left: 1px;}
+abbr {border-width: 1px;}
+
+p {text-indent: 1em; margin: 0 0 0.3em 0.5em;}
+em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
+pre em {font-style: italic; font-weight: normal;}
+strong {}
+pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-family: monospace; background-color: white;}
+pre span.c {color: green;}
+pre span.k {color: blue;}
+tt {margin: 0 0.2em; letter-spacing: 0; font-family: monospace; }
+ol {margin: 0 2.5em;}
+ul {margin: 0 2em;}
+dl {margin: 0 1em;}
+dt {font-family: monospace;}
+dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; letter-spacing: 0;}
+dl.ret dt {margin: 0.5em 0 0 0 ; font-family: monospace; letter-spacing: 0; font-weight: bold;}
+dd {margin: 0 2em;}
+hr {border-width: 1px; margin: 1em;}
+div.abst {font-family: "MS Pゴシック",sans-serif;}
+div.para {clear: both; font-family: "MS P明朝",serif;}
+div.ret a {font-family: monospace; }
+.equ {text-indent: 0; margin: 1em 2em 1em;}
+.indent {margin-left: 2em;}
+.rset {float: right; margin: 0 0 0.5em 0.5em;}
+.lset {float: left; margin: 0 0.5em 0.5em 0.5em;}
+ul.flat li {list-style-type: none; margin: 0;}
+a.imglnk img {border: 1px solid;}
+.iequ {white-space: nowrap; font-weight: bold;}
+.clr {clear: both;}
+.it {font-style: italic;}
+.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap}
+
+h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
+p.hdd {float: right; text-align: right; margin-top: 0.5em;}
+hr.hds {clear: both; margin-bottom: 1em;}
+
+h2 {font-size: 1.6em; font-family: "MS Pゴシック",sans-serif; background-color: #d8d8FF; padding: 0.2em 0.5em; margin: 0 0 0.5em;}
+h3 {font-size: 1.5em; font-family: "MS Pゴシック",sans-serif; margin: 1.5em 0 0.5em;}
+h4 {font-size: 1.2em; font-family: "MS Pゴシック",sans-serif; margin: 1em 0 0.2em;}
+h5 {font-size: 1em; font-family: "MS Pゴシック",sans-serif; margin: 0.5em 0 0em;}
+small {font-size: 80%;}
+.indent {margin-left: 2em;}
+
+/* Tables */
+table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; letter-spacing: 0;}
+th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top;}
+td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;}
+table.lst td:first-child {font-family: monospace; white-space: nowrap;}
+table.lst2 td {font-family: monospace; white-space: nowrap;}
+table caption {font-family: sans-serif; font-weight: bold;}
+tr.lst3 td { border-width: 2px 1px 1px; }
+
+p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}

+ 250 - 0
app/FatFS/doc/en/appnote.html

@@ -0,0 +1,250 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/appnote.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs Module Application Note</title>
+</head>
+
+<body>
+<h1>FatFs Module Application Note</h1>
+<ol class="toc">
+<li><a href="#port">How to Port</a></li>
+<li><a href="#limits">Limits</a></li>
+<li><a href="#memory">Memory Usage</a></li>
+<li><a href="#reduce">Module Size Reduction</a></li>
+<li><a href="#lfn">Long File Name</a></li>
+<li><a href="#unicode">Unicode API</a></li>
+<li><a href="#reentrant">Re-entrancy</a></li>
+<li><a href="#dup">Duplicated File Access</a></li>
+<li><a href="#fs1">Performance Effective File Access</a></li>
+<li><a href="#fs2">Considerations on Flash Memory Media</a></li>
+<li><a href="#critical">Critical Section</a></li>
+<li><a href="#license">About FatFs License</a></li>
+</ol>
+<hr>
+
+<div class="para" id="port">
+<h3>How to Port</h3>
+
+<h4>Basic considerations</h4>
+<p>The FatFs module is assuming following conditions on portability.</p>
+<ul>
+<li>ANSI C<br>
+The FatFs module is a middleware which is written in ANSI C (C89). There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li>
+<li>Size of integer types<br>
+The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.</li>
+</ul>
+
+<h4>Which function is required?</h4>
+<p>You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. All defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.</p>
+<table class="lst2">
+<tr><th>Function</th><th>Required when:</th><th>Note</th></tr>
+<tr><td>disk_initialize<br>disk_status<br>disk_read</td><td>Always</td><td rowspan="5">Disk I/O functions.<br>Samples available in ffsample.zip.<br>There are many implementations on the web.</td></tr>
+<tr><td>disk_write<br>get_fattime<br>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr>
+<tr><td>disk_ioctl (GET_SECTOR_COUNT)<br>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
+<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS &gt; 512</td></tr>
+<tr><td>disk_ioctl (CTRL_ERASE_SECTOR)</td><td>_USE_ERASE == 1</td></tr>
+<tr><td>ff_convert<br>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td><td>Unicode support functions.<br>Available in option/cc*.c.</td></tr>
+<tr><td>ff_cre_syncobj<br>ff_del_syncobj<br>ff_req_grant<br>ff_rel_grant</td><td>_FS_REENTRANT == 1</td><td rowspan="2">O/S dependent functions.<br>Samples available in option/syscall.c.</td></tr>
+<tr><td>ff_mem_alloc<br>ff_mem_free</td><td>_USE_LFN == 3</td></tr>
+</table>
+</div>
+
+<div class="para" id="limits">
+<h3>Limits</h3>
+<ul>
+<li>FAT sub-types: FAT12, FAT16 and FAT32.</li>
+<li>Number of open files: Unlimited, depends on available memory.</li>
+<li>Number of volumes: Upto 10.</li>
+<li>File size: Depends on FAT specs. (upto 4G-1 bytes)</li>
+<li>Volume size: Depends on FAT specs. (upto 2T bytes on 512 bytes/sector)</li>
+<li>Cluster size: Depends on FAT specs. (upto 64K bytes on 512 bytes/sector)</li>
+<li>Sector size: Depends on FAT specs. (upto 4K bytes)</li>
+</ul>
+</div>
+
+<div class="para" id="memory">
+<h3>Memory Usage (R0.09)</h3>
+<table class="lst2">
+<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>Cortex-M3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX62N</th><th>IA-32</th></tr>
+<tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr>
+<tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
+<tr class="lst3"><td>text (Full, R/W)</td><td>10459</td><td>7201</td><td>6623</td><td>12646</td><td>10686</td><td>11466</td><td>12967</td><td>7732</td><td>8752</td><td>5747</td><td>7545</td></tr>
+<tr><td>text (Min, R/W)</td><td>6503</td><td>4745</td><td>4297</td><td>8306</td><td>6986</td><td>7440</td><td>8745</td><td>4938</td><td>5576</td><td>3746</td><td>4923</td></tr>
+<tr><td>text (Full, R/O)</td><td>4535</td><td>3181</td><td>2869</td><td>5960</td><td>4876</td><td>5286</td><td>6060</td><td>3554</td><td>3804</td><td>2659</td><td>3450</td></tr>
+<tr><td>text (Min, R/O)</td><td>3303</td><td>2493</td><td>2171</td><td>4366</td><td>3770</td><td>3984</td><td>4604</td><td>2684</td><td>2940</td><td>2025</td><td>2664</td></tr>
+<tr><td>bss</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
+<tr><td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr>
+<tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr>
+</table>
+<p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, <em>V</em> means number of mounted volumes and <em>F</em> means number of open files. All samples are optimezed in code size.</p>
+<pre>
+_FS_READONLY     0 (R/W), 1 (R/O)
+_FS_MINIMIZE     0 (Full function), 3 (Minimized function)
+_USE_STRFUNC     0 (Disable string functions)
+_USE_MKFS        0 (Disable f_mkfs function)
+_USE_FORWARD     0 (Disable f_forward function)
+_USE_FASTSEEK    0 (Disable fast seek feature)
+_CODE_PAGE       932 (Japanese Shift-JIS)
+_USE_LFN         0 (Disable LFN)
+_MAX_SS          512 (Fixed sector size)
+_FS_RPATH        0 (Disable relative path)
+_VOLUMES         D (Number of logical drives to be used)
+_MULTI_PARTITION 0 (Single partition per drive)
+_FS_REENTRANT    0 (Disable reentrancy)
+_FS_SHARE        0 (Disable shareing control)
+</pre>
+</div>
+
+<div class="para" id="reduce">
+<h3>Module Size Reduction</h3>
+<p>Follwing table shows which API function is removed by configuration options for the module size reduction.</p>
+<table class="lst2">
+<tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr>
+<tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0&nbsp;&nbsp;</td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0/1</td><td>2</td></tr>
+<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr>
+<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
+<tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+</table>
+</div>
+
+<div class="para" id="lfn">
+<h3>Long File Name</h3>
+<p>The FatFs module has started to support long file name (LFN) at revision 0.07. The two different file names, SFN and LFN, of a file is transparent in the file functions except for f_readdir function. To enable LFN feature, set <tt>_USE_LFN</tt> to 1, 2 or 3, and add a Unicode code conversion function <tt>ff_convert()</tt> and <tt>ff_wtoupper()</tt> to the project. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by <tt>_MAX_LFN</tt> corresponding to the available memory size. The size of long file name will reach up to 255 characters so that the <tt>_MAX_LFN</tt> should be set to 255 for full featured LFN operation. If the size of working buffer is insufficient for the given file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant feature, <tt>_USE_LFN</tt> must be set to 2 or 3. In this case, the file function allocates the working buffer on the stack or heap. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes.</p>
+<table class="lst2 rset">
+<caption>LFN cfg on ARM7</caption>
+<tr><th>Code page</th><th>Program size</th></tr>
+<tr><td>SBCS</td><td>+3.7K</td></tr>
+<tr><td>932(Shift-JIS)</td><td>+62K</td></tr>
+<tr><td>936(GBK)</td><td>+177K</td></tr>
+<tr><td>949(Korean)</td><td>+139K</td></tr>
+<tr><td>950(Big5)</td><td>+111K</td></tr>
+</table>
+<p>When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows how many bytes increased when LFN feature is enabled with some code pages. We are the East-Asians have tens of thousands of characters. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN feature with DBCS will not able to be implemented to most 8-bit microcontrollers. <small>This is the reason why I had not been interested in implementing the LFN feature for a long time :-)</small></p>
+<p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers include the LFN feature. FatFs can swich the LFN feature by configuration option. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.</p>
+</div>
+
+<div class="para" id="unicode">
+<h3>Unicode API</h3>
+<p>FatFs supports ANSI/OEM code set on the API in default but FatFs can also switch the code set to Unicode. For more information, refer to the description in the <a href="filename.html">file name</a>.</p>
+</div>
+
+<div class="para" id="reentrant">
+<h3>Re-entrancy</h3>
+<p>The file operations to the different volume is always re-entrant and can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj, ff_del_syncobj, ff_req_grant and ff_rel_grant must be added to the project.</p>
+<p>When a file function is called while the volume is in use by any other task, the file function is suspended until that task leaves file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported on some RTOS.</p>
+<p>There is an exception on f_mount and f_mkfs function. These functions are not re-entrant to the same volume. When use these functions, all other task must close the corresponding file on the volume and avoid to access the volume.</p>
+<p>Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer must be re-entrant.</p>
+</div>
+
+<div class="para" id="dup">
+<h3>Duplicated File Access</h3>
+<p>FatFs module does not support the shareing controls of duplicated file access in default. It is permitted when open method to a file is only read mode. The duplicated open in write mode to a file is always prohibited and open file must not be renamed, deleted, or the FAT structure on the volume can be collapted.</p>
+<p>The file shareing control can also be available when <tt>_FS_SHARE</tt> is set to 1 or grater. The value specifies the number of files to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with <tt>FR_LOCKED</tt>. If number of open files gets larger than <tt>_FS_SHARE</tt>, the f_open function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p>
+</div>
+
+<div class="para" id="fs1">
+<h3>Performance Effective File Access</h3>
+<p>For good performance on reading/writing files on the small embedded system, application programmer should consider what process is done in the FatFs module. The file data on the disk is transferred in following sequence by f_read function.</p>
+<p>Figure 1. Sector miss-aligned read (short)<br>
+<img src="../img/f1.png" width="490" height="110" alt="">
+</p>
+<p>Figure 2. Sector miss-aligned read (long)<br>
+<img src="../img/f2.png" width="490" height="140" alt="">
+</p>
+<p>Figure 3. Sector aligned read<br>
+<img src="../img/f3.png" width="490" height="119" alt="">
+</p>
+<p>The file I/O buffer means a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer on the file system object. The buffer configuration option <tt>_FS_TINY</tt> determins which sector buffer is used for the file data transfer. When tiny buffer (1) is selected, data memory consumption is reduced 512 bytes each file object. In this case, FatFs module uses only a sector buffer on the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.</p>
+<p>Figure 1 shows that partial sector data is transferred via the file I/O buffer. On long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with disk_read function at a time but the multi sector transfer never across the cluster boundary even if it is contiguous.</p>
+<p>Therefore taking effort to sector aligned read/write accesss avoids buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer on the tiny configuration so that it can achieve same performance as non-tiny configuration with small memory footprint.</p>
+</div>
+
+<div class="para" id="fs2">
+<h3>Considerations on Flash Memory Media</h3>
+<p>To maximize the write performance of flash memory media, such as SDC and CFC, it must be controlled in consideration of its characteristitcs.</p>
+<h4>Using Mutiple-Sector Write</h4>
+<div class="rset">
+Figure 6. Comparison between Multiple/Single Sector Write<br>
+<img src="../img/f6.png" width="630" height="148" alt="fig.6">
+</div>
+<p>The write throughput of the flash memory media becomes the worst at single sector write and it increases proportional to the number of sectors per a write transaction. This effect more appers at more fast bus clock and its ratio often becomes grater than ten. The number of write transaction also affects the life time of the media. Therefore the application program should write the data in large block as possible. The ideal block size is cluster size or power of 2 bytes and the byte offset should be aligned to the block. Of course all layers between the application and the media must support multiple sector write feature, however most of open-source disk drivers lack it. Do not split a multiple sector write request into single sector writes or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write.</p>
+<h4>Forcing Memory Erase</h4>
+<p>When remove a file via f_remove function, the data clusters occupied by the file are marked 'free' on the FAT. But the data sectors containing the file data are not that applied any process so that the file data left occupies a part of the media as live blocks. If the file data is forced erased on removing the file, the number of free blocks on the media will be increased. This may skip internal block erase operation to the data block on next write. As the result the write performance might be improved. To enable this feature, set <tt>_USE_ERASE</tt> to 1. Note that this is a feature with expectation of internal process of the flash memory media. It may not always effective and f_remove function will take a time on removing a large file.</p>
+</div>
+
+<div class="para" id="critical">
+<h3>Critical Section</h3>
+<p>If a write operation to the FAT file system is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure can be collapted. Following images shows the critical section on the FatFs application.</p>
+<div class="lset">
+Figure 4. Long critical section<br>
+<img src="../img/f4.png" width="320" height="436" alt="fig.4">
+</div>
+<div class="lset">
+Figure 5. Minimized critical section<br>
+<img src="../img/f5.png" width="320" height="436" alt="fig.5">
+</div>
+<br class="clr">
+<p>An interruption in the red section can cause a cross link; as a result, the object being changed may be lost. There is one or more possibility listed below when an interruption in the yellow section is occured.</p>
+<ul>
+<li>File data being rewrited is collapted.</li>
+<li>A file being appended returns initial state.</li>
+<li>A file created as new is gone.</li>
+<li>A file created as new or in overwritten remains with no content.</li>
+<li>Efficiency of disk use gets worse due to lost clusters.</li>
+</ul>
+<p>Each case does not affect the files that not in write mode open. To minimize risk of data loss, the critical section can be minimized like shown in Figure 5 by minimizing the time that file is opened in write mode or using f_sync function properly.</p>
+</div>
+
+<div class="para" id="license">
+<h3>About FatFs License</h3>
+<p>This is a copy of the FatFs license document that included in the source codes.</p>
+<pre>/*----------------------------------------------------------------------------/
+/  FatFs - FAT file system module  R0.09                     (C)ChaN, 2011
+/-----------------------------------------------------------------------------/
+/ 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) 2011, ChaN, all right reserved.
+/
+/ * The 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.
+/
+/-----------------------------------------------------------------------------/</pre>
+<p>Therefore FatFs license is one of the BSD-style license but there is a big difference. Because FatFs is for embedded projects, the conditions for redistributions in binary form, such as embedded code, hex file and binary library, are not specified to increase its usability. The documentation of the distributions need not include about FatFs and its license document, and it may also. Of course FatFs is compatible with the projects under GNU GPL. When redistribute it with any modification, the license can also be changed to GNU GPL or BSD-style license.</p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 81 - 0
app/FatFS/doc/en/chdir.html

@@ -0,0 +1,81 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/chdir.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_chdir</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_chdir</h2>
+<p>The f_chdir function changes the current directory of a drive.</p>
+<pre>
+FRESULT f_chdir (
+  const TCHAR* <em>Path</em> <span class="c">/* Pointer to the path name */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Path</dt>
+<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">directory</a> to go.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_chdir function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the drive.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_RPATH >= 1</tt>.</p>
+</div>
+
+
+<div class="para use">
+<h4>Example</h4>
+<pre>
+    <span class="c">/* Change current direcoty of the current drive (dir1 under root dir) */</span>
+    f_chdir("/dir1");
+
+    <span class="c">/* Change current direcoty of drive 2 (parent dir) */</span>
+    f_chdir("2:..");
+</pre>
+</div>
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="chdrive.html">f_chdrive</a>, <a href="getcwd.html">f_getcwd</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 60 - 0
app/FatFS/doc/en/chdrive.html

@@ -0,0 +1,60 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/chdrive.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_chdrive</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_chdrive</h2>
+<p>The f_chdrive function changes the current drive.</p>
+<pre>
+FRESULT f_chdrive (
+  BYTE <em>Drive</em> <span class="c">/* Logical drive number */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>Specifies the <a href="filename.html">logical drive number</a> to be set as the current drive.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_chdrive function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions.</p>
+</div>
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_RPATH >= 1</tt>.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="chdir.html">f_chdir</a>, <a href="getcwd.html">f_getcwd</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 89 - 0
app/FatFS/doc/en/chmod.html

@@ -0,0 +1,89 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/chmod.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_chmod</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_chmod</h2>
+<p>The f_chmod function changes the attribute of a file or directory.</p>
+<pre>
+FRESULT f_chmod (
+  const TCHAR* <em>FileName</em>, <span class="c">/* Pointer to the file or directory */</span>
+  BYTE <em>Attribute</em>,        <span class="c">/* Attribute flags */</span>
+  BYTE <em>AttributeMask</em>     <span class="c">/* Attribute masks */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileName</dt>
+<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">file or directory</a> to be changed</dd>
+<dt>Attribute</dt>
+<dd>Attribute flags to be set in one or more combination of the following flags. The specified flags are set and others are cleard.<br>
+<table class="lst">
+<tr><th>Attribute</th><th>Description</th></tr>
+<tr><td>AM_RDO</td><td>Read only</td></tr>
+<tr><td>AM_ARC</td><td>Archive</td></tr>
+<tr><td>AM_SYS</td><td>System</td></tr>
+<tr><td>AM_HID</td><td>Hidden</td></tr>
+</table>
+</dd>
+<dt>AttributeMask</dt>
+<dd>Attribute mask that specifies which attribute is changed. The specified aattributes are set or cleard.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ok">FR_NO_FILE</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_chmod function changes the attribute of a file or directory.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
+</div>
+
+
+<div class="para use">
+<h4>Example</h4>
+<pre>
+    <span class="c">/* Set read-only flag, clear archive flag and others are retained. */</span>
+    f_chmod("file.txt", AR_RDO, AR_RDO | AR_ARC);
+</pre>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 65 - 0
app/FatFS/doc/en/close.html

@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/close.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_close</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_close</h2>
+<p>The f_close function closes an open file.</p>
+<pre>
+FRESULT f_close (
+  FIL* <em>FileObject</em>     <span class="c">/* Pointer to the file object structure */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object structure to be closed.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_close function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the disk. After the function succeeded, the file object is no longer valid and it can be discarded.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Always available.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="write.html">f_write</a>,  <a href="sync.html">f_sync</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 46 - 0
app/FatFS/doc/en/dinit.html

@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dinit.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - disk_initialize</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>disk_initialize</h2>
+<p>The disk_initialize function initializes the disk drive.</p>
+<pre>
+DSTATUS disk_initialize (
+  BYTE <em>Drive</em>           <span class="c">/* Physical drive number */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>Specifies the physical drive number to initialize.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>This function returns a disk status as the result. For details of the disk status, refer to the <a href="dstat.html">disk_status</a> function.</p>
+</div>
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The disk_initialize function initializes a physical drive and put it ready to read/write. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleard.</p>
+<p><em>Application program MUST NOT call this function, or FAT structure on the volume can be corrapted. To re-initialize the file system, use f_mount function.</em>This function is called on volume mount process in the FatFs module to manage the media change.</p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 69 - 0
app/FatFS/doc/en/dioctl.html

@@ -0,0 +1,69 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dioctl.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - disk_ioctl</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>disk_ioctl</h2>
+<p>The disk_ioctl function cntrols device specified features and miscellaneous functions other than disk read/write.</p>
+<pre>
+DRESULT disk_ioctl (
+  BYTE <em>Drive</em>,      <span class="c">/* Drive number */</span>
+  BYTE <em>Command</em>,    <span class="c">/* Control command code */</span>
+  void* <em>Buffer</em>     <span class="c">/* Parameter and data buffer */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>Specifies the drive number (0-9).</dd>
+<dt>Command</dt>
+<dd>Specifies the command code.</dd>
+<dt>Buffer</dt>
+<dd>Pointer to the parameter buffer depends on the command code. When it is not used, specify a NULL pointer.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Value</h4>
+<dl class="ret">
+<dt>RES_OK (0)</dt>
+<dd>The function succeeded.</dd>
+<dt>RES_ERROR</dt>
+<dd>Any error occured.</dd>
+<dt>RES_PARERR</dt>
+<dd>Invalid command code.</dd>
+<dt>RES_NOTRDY</dt>
+<dd>The disk drive has not been initialized.</dd>
+</dl>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The FatFs module uses only device independent commands described below. Any device dependent function is not used.</p>
+<table class="lst">
+<tr><th>Command</th><th>Description</th></tr>
+<tr><td>CTRL_SYNC</td><td>Make sure that the disk drive has finished pending write process. When the disk I/O module has a write back cache, flush the dirty sector immediately. This command is not used in read-only configuration.</td></tr>
+<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the drive into the WORD variable pointed by <tt>Buffer</tt>. This command is not used in fixed sector size configuration, <tt>_MAX_SS</tt> is 512.</td></tr>
+<tr><td>GET_SECTOR_COUNT</td><td>Returns number of available sectors on the drive into the DWORD variable pointed by <tt>Buffer</tt>. This command is used by only f_mkfs function to determine the volume size to be created.</td></tr>
+<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory in unit of sector into the DWORD variable pointed by <tt>Buffer</tt>. The allowable value is 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk devices. This command is used by only f_mkfs function and it attempts to align data area to the erase block boundary.</td></tr>
+<tr><td>CTRL_ERASE_SECTOR</td><td>Erases a part of the flash memory specified by a DWORD array {&lt;start sector&gt;, &lt;end sector&gt;} pointed by <tt>Buffer</tt>. When this feature is not supported or not a flash memory media, this command has no effect. The FatFs does not check the result code and the file function is not affected even if the sectors are not erased well. This command is called on removing a cluster chain when <tt>_USE_ERASE</tt> is 1.</td></tr>
+</table>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 59 - 0
app/FatFS/doc/en/dread.html

@@ -0,0 +1,59 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dread.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - disk_read</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>disk_read</h2>
+<p>The disk_read function reads sector(s) from the disk drive.</p>
+<pre>
+DRESULT disk_read (
+  BYTE <em>Drive</em>,          <span class="c">/* Physical drive number */</span>
+  BYTE* <em>Buffer</em>,        <span class="c">/* Pointer to the read data buffer */</span>
+  DWORD <em>SectorNumber</em>,  <span class="c">/* Start sector number */</span>
+  BYTE <em>SectorCount</em>     <span class="c">/* Number of sectros to read */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>Specifies the physical drive number.</dd>
+<dt>Buffer</dt>
+<dd>Pointer to the <em>byte array</em> to store the read data. The buffer size of number of bytes to be read, sector size * sector count, is required. Note that the specified memory address is not that always aligned to word boundary. If the hardware does not support misaligned data transfer, it must be solved in this function.</dd>
+<dt>SectorNumber</dt>
+<dd>Specifies the start sector number in logical block address (LBA).</dd>
+<dt>SectorCount</dt>
+<dd>Specifies number of sectors to read. The value can be 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you may not get good read performance.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Value</h4>
+<dl class="ret">
+<dt>RES_OK (0)</dt>
+<dd>The function succeeded.</dd>
+<dt>RES_ERROR</dt>
+<dd>Any hard error occured during the read operation and could not recover it.</dd>
+<dt>RES_PARERR</dt>
+<dd>Invalid parameter.</dd>
+<dt>RES_NOTRDY</dt>
+<dd>The disk drive has not been initialized.</dd>
+</dl>
+</div>
+
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 48 - 0
app/FatFS/doc/en/dstat.html

@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dstat.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - disk_status</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>disk_status</h2>
+<p>The disk_status function returns the current disk status.</p>
+<pre>
+DSTATUS disk_status (
+  BYTE <em>Drive</em>     <span class="c">/* Physical drive number */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>Specifies the physical drive number to be confirmed.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>The disk status is returned in combination of following flags. FatFs refers only <tt>STA_NOINIT</tt> and <tt>STA_PROTECTED</tt>.</p>
+<dl class="ret">
+<dt>STA_NOINIT</dt>
+<dd>Indicates that the disk drive has not been initialized. This flag is set on: system reset, disk removal and disk_initialize function failed, and cleared on: disk_initialize function succeeded.</dd>
+<dt>STA_NODISK</dt>
+<dd>Indicates that no medium in the drive. This is always cleared on fixed disk drive.</dd>
+<dt>STA_PROTECTED</dt>
+<dd>Indicates that the medium is write protected. This is always cleared on the drive that does not support write protect notch. Not valid when <tt>STA_NODISK</tt> is set.</dd>
+</dl>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 67 - 0
app/FatFS/doc/en/dwrite.html

@@ -0,0 +1,67 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dwrite.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - disk_write</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>disk_write</h2>
+<p>The disk_write writes sector(s) to the disk.</p>
+<pre>
+DRESULT disk_write (
+  BYTE <em>Drive</em>,          <span class="c">/* Physical drive number */</span>
+  const BYTE* <em>Buffer</em>,  <span class="c">/* Pointer to the write data (may be non aligned) */</span>
+  DWORD <em>SectorNumber</em>,  <span class="c">/* Sector number to write */</span>
+  BYTE <em>SectorCount</em>     <span class="c">/* Number of sectors to write */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>Specifies the physical drive number.</dd>
+<dt>Buffer</dt>
+<dd>Pointer to the <em>byte array</em> to be written. Note that the specified memory address is not that always aligned to word boundary. If the hardware does not support misaligned data transfer, it must be solved in this function.</dd>
+<dt>SectorNumber</dt>
+<dd>Specifies the start sector number in logical block address (LBA).</dd>
+<dt>SectorCount</dt>
+<dd>Specifies the number of sectors to write. The value can be 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you will never get good write performance.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<dl class="ret">
+<dt>RES_OK (0)</dt>
+<dd>The function succeeded.</dd>
+<dt>RES_ERROR</dt>
+<dd>Any hard error occured during the write operation and could not recover it.</dd>
+<dt>RES_WRPRT</dt>
+<dd>The medium is write protected.</dd>
+<dt>RES_PARERR</dt>
+<dd>Invalid parameter.</dd>
+<dt>RES_NOTRDY</dt>
+<dd>The disk drive has not been initialized.</dd>
+</dl>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>This function is not required in read only configuration.</p>
+</div>
+
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 62 - 0
app/FatFS/doc/en/eof.html

@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/eof.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_eof</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_eof</h2>
+<p>The f_eof function tests for end-of-file on a file.</p>
+<pre>
+int f_eof (
+  FIL* <em>FileObject</em>   <span class="c">/* File object */</span>
+);
+</pre>
+</div>
+
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object structure.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>The f_eof function returns a non-zero value if the read/write pointer has reached end of the file; otherwise it returns a zero.</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>In this revision, the f_eof function is implemented as a macro.</p>
+<pre>
+<span class="k">#define</span> f_eof(fp) (((fp)->fptr) == ((fp)->fsize) ? 1 : 0)
+</pre>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Always available.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 62 - 0
app/FatFS/doc/en/error.html

@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/error.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_error</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_error</h2>
+<p>The f_error tests for an error on a file.</p>
+<pre>
+int f_error (
+  FIL* <em>FileObject</em>   <span class="c">/* File object */</span>
+);
+</pre>
+</div>
+
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object structure.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>Returns a non-zero value if an error has occured; otherwise it returns a zero.</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>In this revision, the f_error function is implemented as a macro.</p>
+<pre>
+<span class="k">#define</span> f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
+</pre>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Always available.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 51 - 0
app/FatFS/doc/en/fattime.html

@@ -0,0 +1,51 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/fattime.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - get_fattime</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>get_fattime</h2>
+<p>The get_fattime function gets current time.</p>
+<pre>
+DWORD get_fattime (void);
+</pre>
+</div>
+
+
+<div class="para ret">
+<h4>Return Value</h4>
+<p>Currnet time is returned with packed into a DWORD value. The bit field is as follows:</p>
+<dl class="ret">
+<dt>bit31:25</dt>
+<dd>Year from 1980 (0..127)</dd>
+<dt>bit24:21</dt>
+<dd>Month (1..12)</dd>
+<dt>bit20:16</dt>
+<dd>Day in month(1..31)</dd>
+<dt>bit15:11</dt>
+<dd>Hour (0..23)</dd>
+<dt>bit10:5</dt>
+<dd>Minute (0..59)</dd>
+<dt>bit4:0</dt>
+<dd>Second / 2 (0..29)</dd>
+</dl>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The get_fattime function must return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid time. This fucntion is not required in read only configuration.</p>
+</div>
+
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 97 - 0
app/FatFS/doc/en/fdisk.html

@@ -0,0 +1,97 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/fdisk.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_fdisk</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_fdisk</h2>
+<p>The f_fdisk fucntion divides a physical drive.</p>
+<pre>
+FRESULT f_fdisk (
+  BYTE  <em>Drive</em>,              <span class="c">/* Physical drive number */</span>
+  const DWORD <em>Partitions[]</em>, <span class="c">/* Partition size */</span>
+  void* <em>Work</em>                <span class="c">/* Work area */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>Specifies the <em>physical drive</em> to be divided.</dd>
+<dt>Partitions[]</dt>
+<dd>Partition map table. It must have four items.</dd>
+<dt>Work</dt>
+<dd>Pointer to the function work area. The size must be at least _MAX_SS bytes.</dd>
+</dl>
+</div>
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#ip">FR_INVALID_PARAMETER</a>
+</p>
+</div>
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_fdisk function creates a partition table into the MBR of the physical drive. The partitioning rule is in generic FDISK format so that it can create upto four primary partitions. Extended partition is not supported. The Partitions[] specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it means percentage of the partition in the entire disk space. If it is larger than 100, it means partition size in unit of sector.</p>
+</div>
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READOLNY == 0</tt>, <tt>_USE_MKFS == 1</tt> and <tt>_MULTI_PARTITION == 2</tt>.</p>
+</div>
+
+<div class="para use">
+<h4>Example</h4>
+<pre>
+    <span class="c">/* Volume management table defined by user (required when _MULTI_PARTITION != 0) */</span>
+
+    PARTITION VolToPart[] = {
+        {0, 1},    <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span>
+        {0, 2},    <span class="c">/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span>
+        {1, 0}     <span class="c">/* Logical drive 2 ==> Physical drive 1, auto detection */</span>
+    };
+</pre>
+<pre>
+    <span class="c">/* Initialize a brand-new disk drive mapped to physical drive 0 */</span>
+
+    FATFS Fatfs;
+    DWORD plist[] = {50, 50, 0, 0};  <span class="c">/* Divide drive into two partitions */</span>
+    BYTE work[_MAX_SS];
+
+    f_fdisk(0, plist, work);  <span class="c">/* Divide physical drive 0 */</span>
+
+    f_mount(0, &amp;Fatfs);
+    f_mkfs(0, 0, 0);          <span class="c">/* Create an FAT volume on the logical drive 0. 2nd argument is ignored. */</span>
+    f_mount(0, 0);
+
+    f_mount(1, &amp;Fatfs);
+    f_mkfs(1, 0, 0);
+    f_mount(1, 0);
+
+</pre>
+</div>
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html">f_mkfs</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 74 - 0
app/FatFS/doc/en/filename.html

@@ -0,0 +1,74 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/filename.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - Path Names</title>
+</head>
+
+<body>
+<h1>Path Names</h1>
+
+<div class="para" id="nam">
+<h3>Format of the path names</h3>
+<p>The path name format on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p>
+<p><tt>"[drive#:][/]directory/file"</tt></p>
+<p>The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled <tt>(_USE_LFN &gt; 0)</tt>. The sub directories are separated with a \ or / in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the logical drive is specified in a numeral with a colon. When the drive number is omitted, it is assumed as default drive (0 or current drive).</p>
+<p>Control characters (\0 to \x1F) are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name on LFN configuration but they are recognized as end of the path name on non-LFN configuration. Trailing spaces and dots are ignored.</p>
+<p>In default configuration <tt>(_FS_RPATH == 0)</tt>, it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive number is fixed to 0.</p>
+<p>When relative path feature is enabled <tt>(_FS_RPATH == 1)</tt>, specified path is followed from the root directory if a heading separator is exist. If not, it is followed from the current directory set with <a href="chdir.html">f_chdir</a> function. Dot names are also allowed for the path name. The default drive is the current drive set with <a href="chdrive.html">f_chdrive</a> function.</p>
+<table class="lst2">
+<tr><td>Path name</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr>
+<tr class="lst3"><td>file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the current directory of the current drive</td></tr>
+<tr><td>/file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the root directory of the current drive</td></tr>
+<tr><td></td><td>The root directory of the drive 0</td><td>The current directory of the current drive</td></tr>
+<tr><td>/</td><td>The root directory of the drive 0</td><td>The root directory of the current drive</td></tr>
+<tr><td>2:</td><td>The root directory of the drive 2</td><td>The current directory of the drive 2</td></tr>
+<tr><td>2:/</td><td>The root directory of the drive 2</td><td>The root directory of the drive 2</td></tr>
+<tr><td>2:file.txt</td><td>A file in the root directory of the drive 2</td><td>A file in the current directory of the drive 2</td></tr>
+<tr><td>../file.txt</td><td>Invalid name</td><td>A file in the parent directory</td></tr>
+<tr><td>.</td><td>Invalid name</td><td>This directory</td></tr>
+<tr><td>..</td><td>Invalid name</td><td>Parent directory of the current directory</td></tr>
+<tr><td>dir1/..</td><td>Invalid name</td><td>The current directory</td></tr>
+<tr><td>/..</td><td>Invalid name</td><td>The root directory (sticks the top level)</td></tr>
+</table>
+</div>
+
+<p><br></p>
+<div class="para" id="uni">
+<h3>Unicode API</h3>
+<p>The path names are input/output in either ANSI/OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments that specifies the file names are defined as <tt>TCHAR</tt> which is an alias of <tt>char</tt> in default. The code set of the file name string is the ANSI/OEM code set specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1 under LFN configuration, the type of the <tt>TCHAR</tt> is switched to <tt>unsigned short</tt> (UCS-2 character) to support Unicode. In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, <tt>_T(s)</tt> and <tt>_TEXT(s)</tt> macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.</p>
+<pre>
+ f_open(fp, "filename.txt", FA_READ);      <span class="c">/* ANSI/OEM only */</span>
+ f_open(fp, L"filename.txt", FA_READ);     <span class="c">/* Unicode only */</span>
+ f_open(fp, _T("filename.txt"), FA_READ);  <span class="c">/* Changed automatically */</span>
+</pre>
+</div>
+
+<p><br></p>
+<div class="para" id="vol">
+<h3>Correspondence between logical and physical drives</h3>
+<p>The FatFs module has work areas that called <em>file system object</em> for each volume (logical drive). In default, each logical drive is bound to the physical drive that has same drive number. It attempts to mount a volume as SFD format and first FDISK partition. When <tt>_MULTI_PARTITION &gt;= 1</tt> is specified in configuration option, each individual logical drive is bound to any physical drive/partition. In this case, a volume management table must be defined by user. It is used to resolve relationship between logical drives and partitions as follows:</p>
+<pre>
+Example: Logical drive 0-2 are assigned to three pri-partitions on the physical drive 0 (fixed disk)
+         Logical drive 3 is assigned to physical drive 1 (removable disk)
+
+PARTITION VolToPart[] = {
+    {0, 1},     <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span>
+    {0, 2},     <span class="c">/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span>
+    {0, 3},     <span class="c">/* Logical drive 2 ==> Physical drive 0, 3rd partition */</span>
+    {1, 0}      <span class="c">/* Logical drive 3 ==> Physical drive 1 (auto detection) */</span>
+};
+</pre>
+<p>There are some considerations when use <tt>_MULTI_PARTITION</tt> configuration.</p>
+<ul>
+<li>Only four pri-partitions can be mounted. Extended partition is not supported.</li>
+<li>The physical drive that has two or more partitions must be non-removable class.</li>
+</ul>
+</div>
+
+</body>
+</html>

+ 139 - 0
app/FatFS/doc/en/forward.html

@@ -0,0 +1,139 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/forward.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_forward</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_forward</h2>
+<p>The f_forward function reads the file data and forward it to the data streaming device.</p>
+<pre>
+FRESULT f_forward (
+  FIL* <em>FileObject</em>,                 <span class="c">/* File object */</span>
+  UINT (*<em>Func</em>)(const BYTE*,UINT),  <span class="c">/* Data streaming function */</span>
+  UINT <em>ByteToFwd</em>,                  <span class="c">/* Number of bytes to forward */</span>
+  UINT* <em>ByteFwd</em>                    <span class="c">/* Number of bytes forwarded */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object.</dd>
+<dt>Func</dt>
+<dd>Pointer to the user-defined data streaming function. For details, refer to the sample code.</dd>
+<dt>ByteToFwd</dt>
+<dd>Number of bytes to forward in range of UINT.</dd>
+<dt>ByteFwd</dt>
+<dd>Pointer to the UINT variable to return number of bytes forwarded.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_forward function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of <tt>*ByteFwd &lt; ByteToFwd</tt> without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_USE_FORWARD == 1</tt> and <tt>_FS_TINY == 1</tt>.</p>
+</div>
+
+
+<div class="para use">
+<h4>Example (Audio playback)</h4>
+<pre>
+<span class="c">/*------------------------------------------------------------------------*/</span>
+<span class="c">/* Sample code of data transfer function to be called back from f_forward */</span>
+<span class="c">/*------------------------------------------------------------------------*/</span>
+
+UINT out_stream (   <span class="c">/* Returns number of bytes sent or stream status */</span>
+    const BYTE *p,  <span class="c">/* Pointer to the data block to be sent */</span>
+    UINT btf        <span class="c">/* &gt;0: Transfer call (Number of bytes to be sent). 0: Sense call */</span>
+)
+{
+    UINT cnt = 0;
+
+
+    if (btf == 0) {     <span class="c">/* Sense call */</span>
+        <span class="c">/* Return stream status (0: Busy, 1: Ready) */</span>
+        <span class="c">/* When once it returned ready to sense call, it must accept a byte at least */</span>
+        <span class="c">/* at subsequent transfer call, or f_forward will fail with FR_INT_ERR. */</span>
+        if (FIFO_READY) cnt = 1;
+    }
+    else {              <span class="c">/* Transfer call */</span>
+        do {    <span class="c">/* Repeat while there is any data to be sent and the stream is ready */</span>
+            FIFO_PORT = *p++;
+            cnt++;
+        } while (cnt &lt; btf &amp;&amp; FIFO_READY);
+    }
+
+    return cnt;
+}
+
+
+<span class="c">/*------------------------------------------------------------------------*/</span>
+<span class="c">/* Sample code using f_forward function                                   */</span>
+<span class="c">/*------------------------------------------------------------------------*/</span>
+
+FRESULT play_file (
+    char *fn        <span class="c">/* Pointer to the audio file name to be played */</span>
+)
+{
+    FRESULT rc;
+    FIL fil;
+    UINT dmy;
+
+    <span class="c">/* Open the audio file in read only mode */</span>
+    rc = f_open(&amp;fil, fn, FA_READ);
+    if (rc) return rc;
+
+    <span class="c">/* Repeat until the file pointer reaches end of the file */</span>
+    while (rc == FR_OK &amp;&amp; fil.fptr &lt; fil.fsize) {
+
+        <span class="c">/* any other processes... */</span>
+
+        <span class="c">/* Fill output stream periodicaly or on-demand */</span>
+        rc = f_forward(&amp;fil, out_stream, 1000, &amp;dmy);
+    }
+
+    <span class="c">/* Close the file and return */</span>
+    f_close(&amp;fil);
+    return rc;
+}
+</pre>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="gets.html">fgets</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 70 - 0
app/FatFS/doc/en/getcwd.html

@@ -0,0 +1,70 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/getcwd.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_getcwd</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_getcwd</h2>
+<p>The f_getcwd function retrieves the current directory.</p>
+<pre>
+FRESULT f_getcwd (
+  TCHAR* <em>Buffer</em>,  <span class="c">/* Pointer to the buffer */</span>
+  UINT <em>BufferLen</em>  <span class="c">/* The length of the buffer */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Buffer</dt>
+<dd>Pointer to the buffer to receive the current directory string.</dd>
+<dt>BufferLen</dt>
+<dd>Size of the buffer in unit of TCHAR.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_getcwd function retrieves the current directory of the current drive in full path string including drive number.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_RPATH == 2</tt>.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="chdrive.html">f_chdrive</a>, <a href="chdir.html">f_chdir</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 96 - 0
app/FatFS/doc/en/getfree.html

@@ -0,0 +1,96 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/getfree.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_getfree</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_getfree</h2>
+<p>The f_getfree function gets number of the free clusters.</p>
+<pre>
+FRESULT f_getfree (
+  const TCHAR* <em>Path</em>,        <span class="c">/* Logical drive number */</span>
+  DWORD* <em>Clusters</em>,          <span class="c">/* Pointer to the variable to store number of free clusters */</span>
+  FATFS** <em>FileSystemObject</em>  <span class="c">/* Pointer to pointer to file system object */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Path</dt>
+<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">logical drive</a>.</dd>
+<dt>Clusters</dt>
+<dd>Pointer to the DWORD variable to store number of free clusters.</dd>
+<dt>FileSystemObject</dt>
+<dd>Pointer to pointer that to store a pointer to the corresponding file system object.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Descriptions</h4>
+<p>The f_getfree function gets number of free clusters on the drive. The member <tt>csize</tt> in the file system object is refrecting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When FSInfo structure on FAT32 volume is not in sync, this function can return an incorrect free cluster count.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
+</div>
+
+
+<div class="para use">
+<h4>Example</h4>
+<pre>
+    FATFS *fs;
+    DWORD fre_clust, fre_sect, tot_sect;
+
+
+    <span class="c">/* Get volume information and free clusters of drive 1 */</span>
+    res = f_getfree("1:", &amp;fre_clust, &amp;fs);
+    if (res) die(res);
+
+    <span class="c">/* Get total sectors and free sectors */</span>
+    tot_sect = (fs->n_fatent - 2) * fs->csize;
+    fre_sect = fre_clust * fs->csize;
+
+    <span class="c">/* Print free space in unit of KB (assuming 512 bytes/sector) */</span>
+    printf("%lu KB total drive space.\n"
+           "%lu KB available.\n",
+           fre_sect / 2, tot_sect / 2);
+</pre>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 65 - 0
app/FatFS/doc/en/gets.html

@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/gets.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_gets</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_gets</h2>
+<p>The f_gets reads a string from the file.</p>
+<pre>
+TCHAR* f_gets (
+  TCHAR* <em>Str</em>,       <span class="c">/* Read buffer */</span>
+  int <em>Size</em>,         <span class="c">/* Size of the read buffer */</span>
+  FIL* <em>FileObject</em>   <span class="c">/* File object */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Str</dt>
+<dd>Pointer to read buffer to store the read string.</dd>
+<dt>Size</dt>
+<dd>Size of the read buffer in unit of character.</dd>
+<dt>FileObject</dt>
+<dd>Pointer to the open file object structure.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>When the function succeeded, <tt>Str</tt> will be returuned.</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_gets() is a wrapper function of <a href="read.html">f_read()</a>. The read operation continues until a <tt>'\n'</tt> is stored, reached end of the file or the buffer is filled with <tt>Size - 1</tt> characters. The read string is terminated with a <tt>'\0'</tt>. When no character to read or any error occured during read operation, f_gets() returns a null pointer. The end of file and error status can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macros.</p>
+<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the file is read in UTF-8 encoding and stored it to the buffer in UCS-2. If not the case, the file will be read in one byte per character without any code conversion.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\r'</tt>s contained in the file are stripped out.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 128 - 0
app/FatFS/doc/en/lseek.html

@@ -0,0 +1,128 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/lseek.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_lseek</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_lseek</h2>
+<p>The f_lseek function moves the file read/write pointer of an open file object. It can also be used to increase the file size (cluster pre-allocation). </p>
+
+<pre>
+FRESULT f_lseek (
+  FIL* <em>FileObject</em>,   <span class="c">/* Pointer to the file object structure */</span>
+  DWORD <em>Offset</em>       <span class="c">/* File offset in unit of byte */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object.</dd>
+<dt>Offset</dt>
+<dd>Number of bytes where from start of the file</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_lseek function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is increased to the offset and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, current read/write pointer (member <tt>fptr</tt> in the file object) should be checked in order to make sure the read/write pointer has been moved correctry. In case of the current read/write pointer is not the expected value, either of followings has been occured.</p>
+<ul>
+<li>End of file. The specified Offset was clipped at the file size because the file has been opened in read-only mode.</li>
+<li>Disk full. There is insufficient free space on the volume to expand the file size.</li>
+</ul>
+<p>Fast seek mode is enabled when <tt>_USE_FASTSEEK</tt> is set to 1 and the member <tt>cltbl</tt> in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by cluster link map table (CLMT) stored in the user defined table. It is also applied to f_read/f_write functions. In this mode, the file size cannot be increased by f_write/f_lseek functions.</p>
+<p>The CLMT must be created in the user defined DWORD array prior to use fast seek feature. To create the CLMT, set pointer to the DWORD array to the member <tt>cltbl</tt> in the file object, set the array size in unit of items into the first item and call the f_lseek function with <tt>Offset = CREATE_LINKMAP</tt>. After the function succeeded and CLMT is created, no FAT access is occured in subsequent f_read/f_write/f_lseek functions to the file. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file and the required items is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT. </p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_MINIMIZE &lt;= 2</tt>.</p>
+</div>
+
+
+<div class="para use">
+<h4>Example</h4>
+<pre>
+    <span class="c">/* Open file */</span>
+    file = malloc(sizeof(FIL));
+    if (!file) ...
+    res = f_open(file, "file.dat", FA_READ|FA_WRITE);
+    if (res) ...
+
+    <span class="c">/* Move to offset of 5000 from top of the file */</span>
+    res = f_lseek(file, 5000);
+
+    <span class="c">/* Move to end of the file to append data */</span>
+    res = f_lseek(file, f_size(file));
+
+    <span class="c">/* Forward 3000 bytes */</span>
+    res = f_lseek(file, f_tell(file) + 3000);
+
+    <span class="c">/* Rewind 2000 bytes (take care on overflow) */</span>
+    res = f_lseek(file, f_tell(file) - 2000);
+</pre>
+<pre>    <span class="c">/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span>
+
+    res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); <span class="c">/* Create a file */</span>
+
+    res = f_lseek(file, PRE_SIZE);           <span class="c">/* Pre-allocate clusters */</span>
+    if (res || f_tell(file) != PRE_SIZE) ... <span class="c">/* Check if the file size has been increased correctly */</span>
+
+    res = f_lseek(file, DATA_START);         <span class="c">/* Record data stream without cluster allocation delay */</span>
+    ...
+
+    res = f_truncate(file);                  <span class="c">/* Truncate unused area */</span>
+    res = f_lseek(file, 0);                  <span class="c">/* Put file header */</span>
+    ...
+
+    res = f_close(file);
+</pre>
+<pre>    <span class="c">/* Using fast seek feature */</span>
+
+    DWORD lktbl[SZ_TBL];                   <span class="c">/* Link map table buffer */</span>
+
+    res = f_lseek(file, ofs1);             <span class="c">/* This is normal seek (file.cltbl is nulled on file open) */</span>
+
+    file.cltbl = lktbl;                    <span class="c">/* Enable fast seek feature */</span>
+    lktbl[0] = SZ_TBL;                     <span class="c">/* Set table size to the first item */</span>
+    res = f_lseek(file, CREATE_LINKMAP);   <span class="c">/* Create CLMT */</span>
+    ...
+
+    res = f_lseek(file, ofs2);             <span class="c">/* This is fast seek (file.cltbl != NULL) */</span>
+</pre>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 80 - 0
app/FatFS/doc/en/mkdir.html

@@ -0,0 +1,80 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/mkdir.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_mkdir</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_mkdir</h2>
+<p>The f_mkdir function creates a new directory.</p>
+<pre>
+FRESULT f_mkdir (
+  const TCHAR* <em>DirName</em> <span class="c">/* Pointer to the directory name */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>DirName</dt>
+<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">directory name</a> to create. </dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Value</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#de">FR_DENIED</a>,
+<a href="rc.html#ex">FR_EXIST</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_mkdir function creates a new directory.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
+</div>
+
+
+<div class="para use">
+<h4>Example</h4>
+<pre>
+    res = f_mkdir("sub1");
+    if (res) die(res);
+    res = f_mkdir("sub1/sub2");
+    if (res) die(res);
+    res = f_mkdir("sub1/sub2/sub3");
+    if (res) die(res);
+</pre>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 73 - 0
app/FatFS/doc/en/mkfs.html

@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/mkfs.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_mkfs</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_mkfs</h2>
+<p>The f_mkfs fucntion creates an FAT file system on the logical drive.</p>
+<pre>
+FRESULT f_mkfs (
+  BYTE  <em>Drive</em>,            <span class="c">/* Logical drive number */</span>
+  BYTE  <em>PartitioningRule</em>, <span class="c">/* Partitioning rule */</span>
+  UINT  <em>AllocSize</em>         <span class="c">/* Size of the allocation unit */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>Logical drive number (0-9) to be formatted.</dd>
+<dt>PartitioningRule</dt>
+<dd>Specifies partitioning rule, FDISK(0) or SFD(1). This argument is ignored on some case.</dd>
+<dt>AllocSize</dt>
+<dd>Force the allocation unit (cluter) size in unit of byte. The value must be power of 2 and between the sector size and 128 * sector size. When a zero is given, the cluster size is determined depends on the volume size.</dd>
+</dl>
+</div>
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ma">FR_MKFS_ABORTED</a>,
+<a href="rc.html#ip">FR_INVALID_PARAMETER</a>
+</p>
+</div>
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_mkfs function creates an FAT volume on the logical drive. When FDISK is specified, a primary partition occupies the entire disk space is created and then an FAT volume is created on the partition. When SFD is specified, the FAT volume starts from the first sector of the physical drive.</p>
+<p>If the logical drive is being bound to any partition (1-4) by multiple partition feature <tt>(_MULTI_PARTITION)</tt>, the FAT volume is created into the specified partition. In this case, the second argument is ignored. The physical drive must be partitioned with f_fdisk function or any other partitioning tool prior to use this function.</p>
+<p>Note that there are two partitioning rules, FDISK and SFD. The FDISK format is usually used for harddisk, MMC, SDC and CFC. It can divide a physical drive into one or more partitions with a partition table on the MBR. The SFD format is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is used for floppy disk, Microdrive, optical disk and super-floppy media.</p>
+<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.</p>
+<p>When the number of clusters gets near the FAT sub-type boundaries, the function can fail with FR_MKFS_ABORTED.</p>
+</div>
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READOLNY == 0</tt> and <tt>_USE_MKFS == 1</tt>.</p>
+</div>
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="filename.html#vol">Volume management</a>, <a href="fdisk.html">f_fdisk</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 64 - 0
app/FatFS/doc/en/mount.html

@@ -0,0 +1,64 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/mount.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_mount</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_mount</h2>
+<p>The f_mount fucntion registers/unregisters a work area to the FatFs module.</p>
+<pre>
+FRESULT f_mount (
+  BYTE  <em>Drive</em>,              <span class="c">/* Logical drive number */</span>
+  FATFS*  <em>FileSystemObject</em>  <span class="c">/* Pointer to the work area */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>Logical drive number (0-9) to register/unregister the work area.</dd>
+<dt>FileSystemObject</dt>
+<dd>Pointer to the work area (file system object) to be registered.</dd>
+</dl>
+</div>
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_mount function registers/unregisters a work area to the FatFs module. The work area must be given to the each volume with this function prior to use any other file function. To unregister a work area, specify a NULL to the <em>FileSystemObject</em>, and then the work area can be discarded.</p>
+<p>This function always succeeds regardless of the drive status. No media access is occured in this function. It only initializes the given work area and registers its address to the internal table. The volume mount process is performed on first file access after f_mount function or media change.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Always available.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 139 - 0
app/FatFS/doc/en/open.html

@@ -0,0 +1,139 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/open.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_open</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_open</h2>
+<p>The f_open function creates a <em>file object</em> to be used to access the file.</p>
+<pre>
+FRESULT f_open (
+  FIL* <em>FileObject</em>,       <span class="c">/* Pointer to the blank file object structure */</span>
+  const TCHAR* <em>FileName</em>, <span class="c">/* Pointer to the file neme */</span>
+  BYTE <em>ModeFlags</em>         <span class="c">/* Mode flags */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the file object structure to be created.</dd>
+<dt>FileName</dt>
+<dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file name</a> to create or open.</dd>
+<dt>ModeFlags</dt>
+<dd>Specifies the type of access and open method for the file. It is specified by a combination of following flags.<br>
+<table class="lst">
+<tr><th>Value</th><th>Description</th></tr>
+<tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.<br>Combine with <tt>FA_WRITE</tt> for read-write access.</td></tr>
+<tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file.<br>Combine with <tt>FA_READ</tt> for read-write access.</td></tr>
+<tr><td>FA_OPEN_EXISTING</td><td>Opens the file. The function fails if the file is not existing. (Default)</td></tr>
+<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file is created.<br>
+To append data to the file, use <a href="lseek.html">f_lseek</a> function after file open in this method.</td></tr>
+<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails with <tt>FR_EXIST</tt> if the file is existing.</td></tr>
+<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it is truncated and overwritten.</td></tr>
+</table>
+</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ok">FR_NO_FILE</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#de">FR_DENIED</a>,
+<a href="rc.html#ex">FR_EXIST</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#lo">FR_LOCKED</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>,
+<a href="rc.html#tf">FR_TOO_MANY_OPEN_FILES</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>After f_open function succeeded, the file object is valid. The file object is used for subsequent read/write functions to identify the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file data can be collapsed.</p>
+<p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully.</p>
+<p>Before using any file function, a work area (file system object) must be registered to the logical drive with <a href="mount.html">f_mount</a> function. All API functions except for <a href="fdisk.html">f_fdisk</a> function can work after this procedure.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Always available. The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW and FA_OPEN_ALWAYS</tt>, are not available when <tt>_FS_READONLY == 1</tt>.</p>
+</div>
+
+
+<div class="para use">
+<h4>Example (File Copy)</h4>
+<pre>
+void main (void)
+{
+    FATFS fs[2];         <span class="c">/* Work area (file system object) for logical drives */</span>
+    FIL fsrc, fdst;      <span class="c">/* file objects */</span>
+    BYTE buffer[4096];   <span class="c">/* file copy buffer */</span>
+    FRESULT res;         <span class="c">/* FatFs function common result code */</span>
+    UINT br, bw;         <span class="c">/* File read/write count */</span>
+
+
+    <span class="c">/* Register work area for each volume (Always succeeds regardless of disk status) */</span>
+    f_mount(0, &amp;fs[0]);
+    f_mount(1, &amp;fs[1]);
+
+    <span class="c">/* Open source file on the drive 1 */</span>
+    res = f_open(&amp;fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
+    if (res) die(res);
+
+    <span class="c">/* Create destination file on the drive 0 */</span>
+    res = f_open(&amp;fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
+    if (res) die(res);
+
+    <span class="c">/* Copy source to destination */</span>
+    for (;;) {
+        res = f_read(&amp;fsrc, buffer, sizeof buffer, &amp;br);     <span class="c">/* Read a chunk of src file */</span>
+        if (res || br == 0) break; <span class="c">/* error or eof */</span>
+        res = f_write(&amp;fdst, buffer, br, &amp;bw);               <span class="c">/* Write it to the dst file */</span>
+        if (res || bw &lt; br) break; <span class="c">/* error or disk full */</span>
+    }
+
+    <span class="c">/* Close open files */</span>
+    f_close(&amp;fsrc);
+    f_close(&amp;fdst);
+
+    <span class="c">/* Unregister work area prior to discard it */</span>
+    f_mount(0, NULL);
+    f_mount(1, NULL);
+}
+</pre>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 73 - 0
app/FatFS/doc/en/opendir.html

@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/opendir.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_opendir</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_opendir</h2>
+<p>The f_opendir function opens a directory.</p>
+<pre>
+FRESULT f_opendir (
+  DIR* <em>DirObject</em>,       <span class="c">/* Pointer to the blank directory object structure */</span>
+  const TCHAR* <em>DirName</em>  <span class="c">/* Pointer to the directory name */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>DirObject</dt>
+<dd>Pointer to the blank directory object to be created.</dd>
+<dt>DirName</dt>
+<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_opendir function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_MINIMIZE &lt;= 1</tt>.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 90 - 0
app/FatFS/doc/en/printf.html

@@ -0,0 +1,90 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/printf.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_printf</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_printf</h2>
+<p>The f_printf function writes formatted string to the file.</p>
+<pre>
+int f_printf (
+  FIL* <em>FileObject</em>,      <span class="c">/* File object */</span>
+  const TCHAR* <em>Foramt</em>,  <span class="c">/* Format stirng */</span>
+  ...
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object structure.</dd>
+<dt>Format</dt>
+<dd>Pointer to the null terminated format string.</dd>
+<dt>...</dt>
+<dd>Optional arguments.</dd>
+
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>When the function succeeded, number of characters written is returned. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_printf() is a wrapper function of <a href="putc.html">f_putc()</a> and <a href="puts.html">f_puts()</a>. The format control directive is a sub-set of standard library shown as follos:</p>
+<ul>
+<li>Type: <tt>c C s S d D u U x X b B</tt></li>
+<li>Size: <tt>l L</tt></li>
+<li>Flag: <tt>0 -</tt></li>
+</ul>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the output are converted to <tt>"\r\n"</tt>.</p>
+<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the generated UCS-2 characters are written to the file in UTF-8 encoding. If not the case, the byte characters will be written directly.</p>
+</div>
+
+
+<div class="para use">
+<h4>Example</h4>
+<pre>
+    f_printf(&amp;fil, "%d", 1234);            <span class="c">/* "1234" */</span>
+    f_printf(&amp;fil, "%6d,%3d%%", -200, 5);  <span class="c">/* "  -200,  5%" */</span>
+    f_printf(&amp;fil, "%-6u", 100);           <span class="c">/* "100   " */</span>
+    f_printf(&amp;fil, "%ld", 12345678L);      <span class="c">/* "12345678" */</span>
+    f_printf(&amp;fil, "%04x", 0xA3);          <span class="c">/* "00a3" */</span>
+    f_printf(&amp;fil, "%08LX", 0x123ABC);     <span class="c">/* "00123ABC" */</span>
+    f_printf(&amp;fil, "%016b", 0x550F);       <span class="c">/* "0101010100001111" */</span>
+    f_printf(&amp;fil, "%s", "String");        <span class="c">/* "String" */</span>
+    f_printf(&amp;fil, "%-4s", "abc");         <span class="c">/* "abc " */</span>
+    f_printf(&amp;fil, "%4s", "abc");          <span class="c">/* " abc" */</span>
+    f_printf(&amp;fil, "%c", 'a');             <span class="c">/* "a" */</span>
+    f_printf(&amp;fil, "%f", 10.0);            <span class="c">/* f_printf lacks floating point support */</span>
+</pre>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 62 - 0
app/FatFS/doc/en/putc.html

@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/putc.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_putc</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_putc</h2>
+<p>The f_putc funciton puts a character to the file.</p>
+<pre>
+int f_putc (
+  TCHAR <em>Chr</em>,        <span class="c">/* A character to put */</span>
+  FIL* <em>FileObject</em>   <span class="c">/* File object */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Chr</dt>
+<dd>A character to be put.</dd>
+<dt>FileObject</dt>
+<dd>Pointer to the open file object structuer.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>When the character was written successfuly, the function returns 1. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
+<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UTF-16 character is written to the file in UTF-8 encoding. If not the case, the byte will be written directly.</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_putc() is a wrapper function of <a href="write.html">f_write()</a>.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, a <tt>'\n'</tt> is converted to <tt>"\r\n"</tt>.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 62 - 0
app/FatFS/doc/en/puts.html

@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/puts.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_puts</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_puts</h2>
+<p>The f_puts function writes a string to the file.</p>
+<pre>
+int f_puts (
+  const TCHAR* <em>Str</em>,  <span class="c">/* String */</span>
+  FIL* <em>FileObject</em>    <span class="c">/* File object */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>Str</dt>
+<dd>Pointer to the null terminated string to be written. The null character will not be written.</dd>
+<dt>FileObject</dt>
+<dd>Pointer to the open file object structure.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Value</h4>
+<p>When the function succeeded, number of characters written that is not minus value is returned. When the write operation is aborted due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
+<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UTF-16 string is written to the file in UTF-8 encoding. If not the case, the byte stream will be written directly.</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_puts() is a wrapper function of <a href="putc.html">f_putc()</a>.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the string are converted to <tt>"\r\n"</tt>.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="putc.html">f_putc</a>, <a href="printf.html">f_printf</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 86 - 0
app/FatFS/doc/en/rc.html

@@ -0,0 +1,86 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/rc.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - Return Codes</title>
+</head>
+
+<body>
+<h1>Return Code of the File Functions</h1>
+<p>On the FatFs API, most of file functions return common result code as enum type. When a function succeeded, it returns zero, otherwise returns non-zero value that indicates type of error.</p>
+
+<dl class="ret">
+<dt id="ok">FR_OK (0)</dt>
+<dd>The function succeeded.</dd>
+<dt id="de">FR_DISK_ERR</dt>
+<dd>An unrecoverable error occured in the lower layer (disk I/O functions).</dd>
+<dt id="ie">FR_INT_ERR</dt>
+<dd>Assertion failed. An insanity is detected in the internal process. One of the following possibilities are suspected.
+<ul>
+<li>There is any error of the FAT structure on the volume.</li>
+<li>Work area (file system object, file object or etc...) is broken by stack overflow or any other application. This is the reason in most case.</li>
+<li>An <tt>FR_DISK_ERR</tt> has occured on the file object.</li>
+</ul>
+</dd>
+<dt id="nr">FR_NOT_READY</dt>
+<dd>The disk drive cannot work due to incorrect medium removal or disk_initialize function failed.</dd>
+<dt id="nf">FR_NO_FILE</dt>
+<dd>Could not find the file.</dd>
+<dt id="np">FR_NO_PATH</dt>
+<dd>Could not find the path.</dd>
+<dt id="in">FR_INVALID_NAME</dt>
+<dd>The given string is invalid as the <a href="filename.html">path name</a>.</dd>
+<dt id="dn">FR_DENIED</dt>
+<dd>The required access was denied due to one of the following reasons:
+<ul>
+<li>Write mode open against the file with read-only attribute.</li>
+<li>Deleting the file or directory with read-only attribute.</li>
+<li>Deleting the non-empty directory or current directory.</li>
+<li>Reading the file opened without FA_READ flag.</li>
+<li>Any modification to the file opened without FA_WRITE flag.</li>
+<li>Could not create the file or directory due to the directory table is full.</li>
+<li>Could not create the directory due to the volume is full.</li>
+</ul>
+</dd>
+<dt id="ex">FR_EXIST</dt>
+<dd>Any object that has the same name is already existing.</dd>
+<dt id="io">FR_INVALID_OBJECT</dt>
+<dd>The given file/directory object structure is invalid.</dd>
+<dt id="wp">FR_WRITE_PROTECTED</dt>
+<dd>Any write mode action against write-protected media.</dd>
+<dt id="id">FR_INVALID_DRIVE</dt>
+<dd>Invalid drive number is specified. (Related option: _VOLUMES)</dd>
+<dt id="ne">FR_NOT_ENABLED</dt>
+<dd>Work area for the logical drive has not been registered by f_mount function.</dd>
+<dt id="ns">FR_NO_FILESYSTEM</dt>
+<dd>There is no valid FAT volume on the drive.</dd>
+<dt id="ma">FR_MKFS_ABORTED</dt>
+<dd>The f_mkfs function aborted before start in format due to a reason as follows:
+<ul>
+<li>The disk size is too small.</li>
+<li>Not allowable cluster size for this disk. This can occure when number of clusters gets near the 0xFF7 and 0xFFF7.</li>
+</ul>
+</dd>
+<dt id="tm">FR_TIMEOUT</dt>
+<dd>The function canceled due to a timeout of <a href="appnote.html#reentrant">thread-safe control</a>. (Related option: _TIMEOUT)</dd>
+<dt id="lo">FR_LOCKED</dt>
+<dd>The file access is rejected by <a href="appnote.html#dup">file sharing control</a>. (Related option: _FS_SHARE)</dd>
+<dt id="nc">FR_NOT_ENOUGH_CORE</dt>
+<dd>Not enough memory for the operation. There is one of the following reasons:
+<ul>
+<li>Could not allocate a memory for LFN working buffer. (Related option: _USE_LFN)</li>
+<li>Given table size is insufficient for the required size.</li>
+</ul>
+</dd>
+<dt id="tf">FR_TOO_MANY_OPEN_FILES</dt>
+<dd>Number of open files has been reached maximum value and no more file can be opened. (Related option: _FS_SHARE)</dd>
+<dt id="ip">FR_INVALID_PARAMETER</dt>
+<dd>The given parameter is invalid or there is any inconsistent.</dd>
+</dl>
+
+</body>
+</html>

+ 74 - 0
app/FatFS/doc/en/read.html

@@ -0,0 +1,74 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/read.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_read</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_read</h2>
+<p>The f_read function reads data from a file.</p>
+<pre>
+FRESULT f_read (
+  FIL* <em>FileObject</em>,    <span class="c">/* Pointer to the file object structure */</span>
+  void* <em>Buffer</em>,       <span class="c">/* Pointer to the buffer to store read data */</span>
+  UINT <em>ByteToRead</em>,    <span class="c">/* Number of bytes to read */</span>
+  UINT* <em>ByteRead</em>      <span class="c">/* Pointer to the variable to return number of bytes read */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object.</dd>
+<dt>Buffer</dt>
+<dd>Pointer to the buffer to store read data</dd>
+<dt>ByteToRead</dt>
+<dd>Number of bytes to read in range of UINT.</dd>
+<dt>ByteRead</dt>
+<dd>Pointer to the UINT variable to return number of bytes read. The value is always valid after the function call regardless of the result.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The file pointer of the file object increases in number of bytes read. After the function succeeded, <tt>*ByteRead</tt> should be checked to detect the end of file. In case of <tt>*ByteRead &lt; ByteToRead</tt>, it means the read/write pointer reached end of the file during read operation.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Always available.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="gets.html">fgets</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 119 - 0
app/FatFS/doc/en/readdir.html

@@ -0,0 +1,119 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/readdir.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_readdir</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_readdir</h2>
+<p>The f_readdir function reads directory entries.</p>
+<pre>
+FRESULT f_readdir (
+  DIR* <em>DirObject</em>,    <span class="c">/* Pointer to the open directory object */</span>
+  FILINFO* <em>FileInfo</em>  <span class="c">/* Pointer to the file information structure */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>DirObject</dt>
+<dd>Pointer to the open directory object.</dd>
+<dt>FileInfo</dt>
+<dd>Pointer to the file information structure to store the read item.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_readdir function reads directory entries in sequence. All items in the directory can be read by calling f_readdir function repeatedly. When all directory entries have been read and no item to read, the function returns a null string into <tt>f_name[]</tt> member without any error. When a null pointer is given to the <tt>FileInfo</tt>, the read index of the directory object will be rewinded.</p>
+<p>When LFN feature is enabled, <tt>lfname</tt> and <tt>lfsize</tt> in the file information structure must be initialized with valid value prior to use the f_readdir function. The <tt>lfname</tt> is a pointer to the string buffer to return the long file name. The <tt>lfsize</tt> is the size of the string buffer in unit of TCHAR. If either the size of read buffer or LFN working buffer is insufficient for the LFN or the object has no LFN, a null string will be returned to the LFN read buffer. If the LFN contains any charactrer that cannot be converted to OEM code, a null string will be returned but this is not the case on Unicode API configuration. When <tt>lfname</tt> is a NULL, nothing of the LFN is returned. When the object has no LFN, some small capitals can be contained in the SFN.</p>
+<p>When relative path feature is enabled <tt>(_FS_RPATH == 1)</tt>, "." and ".." entries are not filtered out and it will appear in the read entries.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_MINIMIZE &lt;= 1</tt>.</p>
+</div>
+
+
+<div class="para use">
+<h4>Sample Code</h4>
+<pre>
+FRESULT scan_files (
+    char* path        <span class="c">/* Start node to be scanned (also used as work area) */</span>
+)
+{
+    FRESULT res;
+    FILINFO fno;
+    DIR dir;
+    int i;
+    char *fn;   <span class="c">/* This function is assuming non-Unicode cfg. */</span>
+<span class="k">#if</span> _USE_LFN
+    static char lfn[_MAX_LFN + 1];
+    fno.lfname = lfn;
+    fno.lfsize = sizeof(lfn);
+<span class="k">#endif</span>
+
+
+    res = f_opendir(&amp;dir, path);                       <span class="c">/* Open the directory */</span>
+    if (res == FR_OK) {
+        i = strlen(path);
+        for (;;) {
+            res = f_readdir(&amp;dir, &amp;fno);                   <span class="c">/* Read a directory item */</span>
+            if (res != FR_OK || fno.fname[0] == 0) break;  <span class="c">/* Break on error or end of dir */</span>
+            if (fno.fname[0] == '.') continue;             <span class="c">/* Ignore dot entry */</span>
+<span class="k">#if</span> _USE_LFN
+            fn = *fno.lfname ? fno.lfname : fno.fname;
+<span class="k">#else</span>
+            fn = fno.fname;
+<span class="k">#endif</span>
+            if (fno.fattrib &amp; AM_DIR) {                    <span class="c">/* It is a directory */</span>
+                sprintf(&amp;path[i], "/%s", fn);
+                res = scan_files(path);
+                if (res != FR_OK) break;
+                path[i] = 0;
+            } else {                                       <span class="c">/* It is a file. */</span>
+                printf("%s/%s\n", path, fn);
+            }
+        }
+    }
+
+    return res;
+}
+</pre>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="opendir.html">f_opendir</a>, <a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 84 - 0
app/FatFS/doc/en/rename.html

@@ -0,0 +1,84 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/rename.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_rename</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_rename</h2>
+<p>Renames an object.</p>
+<pre>
+FRESULT f_rename (
+  const TCHAR* <em>OldName</em>, <span class="c">/* Pointer to old object name */</span>
+  const TCHAR* <em>NewName</em>  <span class="c">/* Pointer to new object name */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>OldName</dt>
+<dd>Pointer to a null-terminated string specifies the old <a href="filename.html">object name</a> to be renamed.</dd>
+<dt>NewName</dt>
+<dd>Pointer to a null-terminated string specifies the new object name without drive number.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ok">FR_NO_FILE</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#de">FR_DENIED</a>,
+<a href="rc.html#ex">FR_EXIST</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#lo">FR_LOCKED</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>Renames an object (file or directory) and can also move it to other directory. The logical drive number is determined by old name, new name must not contain a logical drive number. <em>Do not rename open objects</em>.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
+</div>
+
+
+<div class="para use">
+<h4>Example</h4>
+<pre>
+    <span class="c">/* Rename an object */</span>
+    f_rename("oldname.txt", "newname.txt");
+
+    <span class="c">/* Rename and move an object to other directory */</span>
+    f_rename("oldname.txt", "dir1/newname.txt");
+</pre>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 37 - 0
app/FatFS/doc/en/sdir.html

@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sdir.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - DIR</title>
+</head>
+
+<body>
+
+<div class="para">
+<h2>DIR</h2>
+<p>The <tt>DIR</tt> structure is used for the work area to read a directory by f_oepndir, f_readdir function. There is no member that can be changed by application.</p>
+<pre>
+<span class="k">typedef</span> <span class="k">struct</span> {
+    FATFS*  fs;         <span class="c">/* Pointer to the owner file system object */</span>
+    WORD    id;         <span class="c">/* Owner file system mount ID */</span>
+    WORD    index;      <span class="c">/* Directory index number to be read/write next */</span>
+    DWORD   sclust;     <span class="c">/* Table start cluster (0:Root dir) */</span>
+    DWORD   clust;      <span class="c">/* Current cluster */</span>
+    DWORD   sect;       <span class="c">/* Current sector */</span>
+    BYTE*   dir;        <span class="c">/* Pointer to the current SFN entry in the win[] */</span>
+    BYTE*   fn;         <span class="c">/* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */</span>
+<span class="k">#if</span> _USE_LFN
+    WCHAR*  lfn;        <span class="c">/* Pointer to the LFN working buffer */</span>
+    WORD    lfn_idx;    <span class="c">/* Last matched LFN index (0xFFFF:No LFN) */</span>
+<span class="k">#endif</span>
+} DIR;
+</pre>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 54 - 0
app/FatFS/doc/en/sfatfs.html

@@ -0,0 +1,54 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sfatfs.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - FATFS</title>
+</head>
+
+<body>
+
+<div class="para">
+<h2>FATFS</h2>
+<p>The <tt>FATFS</tt> structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount function. Initialization is done on first file access after f_mount or media change. There is no member that can be changed from the application program.</p>
+<pre>
+<span class="k">typedef</span> <span class="k">struct</span> {
+    BYTE    fs_type;      <span class="c">/* FAT sub-type (0:Not mounted) */</span>
+    BYTE    drv;          <span class="c">/* Physical drive number */</span>
+    BYTE    csize;        <span class="c">/* Sectors per cluster (1,2,4...128) */</span>
+    BYTE    n_fats;       <span class="c">/* Number of FAT copies (1,2) */</span>
+    BYTE    wflag;        <span class="c">/* win[] dirty flag */</span>
+    BYTE    fsi_flag;     <span class="c">/* fsinfo dirty flag */</span>
+    WORD    id;           <span class="c">/* File system mount ID */</span>
+    WORD    n_rootdir;    <span class="c">/* Number of root directory entries (FAT12/16) */</span>
+<span class="k">#if</span> _MAX_SS != 512
+    WORD    ssize;        <span class="c">/* Sector size (512,1024,2048,4096) */</span>
+<span class="k">#endif</span>
+<span class="k">#if</span> _FS_REENTRANT
+    _SYNC_t sobj;         <span class="c">/* Identifier of sync object */</span>
+<span class="k">#endif</span>
+<span class="k">#if</span> !_FS_READONLY
+    DWORD   last_clust;   <span class="c">/* Last allocated cluster */</span>
+    DWORD   free_clust;   <span class="c">/* Number of free clusters */</span>
+    DWORD   fsi_sector;   <span class="c">/* fsinfo sector (FAT32) */</span>
+<span class="k">#endif</span>
+<span class="k">#if</span> _FS_RPATH
+    DWORD   cdir;         <span class="c">/* Current directory cluster (0:root) */</span>
+<span class="k">#endif</span>
+    DWORD   n_fatent;     <span class="c">/* Number of FAT entries (= number of clusters + 2) */</span>
+    DWORD   fsize;        <span class="c">/* Sectors per FAT */</span>
+    DWORD   fatbase;      <span class="c">/* FAT area start sector */</span>
+    DWORD   dirbase;      <span class="c">/* Root directory area start sector (FAT32: cluster#) */</span>
+    DWORD   database;     <span class="c">/* Data area start sector */</span>
+    DWORD   winsect;      <span class="c">/* Current sector appearing in the win[] */</span>
+    BYTE    win[_MAX_SS]; <span class="c">/* Disk access window for Directory, FAT (and Data on tiny cfg) */</span>
+} FATFS;
+</pre>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 49 - 0
app/FatFS/doc/en/sfile.html

@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sfile.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - FIL</title>
+</head>
+
+<body>
+
+<div class="para">
+<h2>FIL</h2>
+<p>The FIL structure (file object) holds state of an open file. It is created by f_open function and discarded by f_close function. There is no member that can be changed by the application program except for <tt>cltbl</tt>. Note that a sector buffer is defined in this structure under non-tiny configuration so that the FIL structures should not be defined as auto variable.</p>
+
+<pre>
+<span class="k">typedef</span> <span class="k">struct</span> {
+    FATFS*  fs;           <span class="c">/* Pointer to the owner file system object */</span>
+    WORD    id;           <span class="c">/* Owner file system mount ID */</span>
+    BYTE    flag;         <span class="c">/* File status flags */</span>
+    BYTE    pad1;
+    DWORD   fptr;         <span class="c">/* File read/write pointer (Byte offset origin from top of the file) */</span>
+    DWORD   fsize;        <span class="c">/* File size */</span>
+    DWORD   sclust;       <span class="c">/* File start cluster */</span>
+    DWORD   clust;        <span class="c">/* Current cluster */</span>
+    DWORD   dsect;        <span class="c">/* Current data sector */</span>
+<span class="k">#if</span> !_FS_READONLY
+    DWORD   dir_sect;     <span class="c">/* Sector containing the directory entry */</span>
+    BYTE*   dir_ptr;      <span class="c">/* Ponter to the directory entry in the window */</span>
+<span class="k">#endif</span>
+<span class="k">#if</span> _USE_FASTSEEK
+    DWORD*  cltbl;        <span class="c">/* Pointer to the cluster link map table (Nulled on file open) */</span>
+<span class="k">#endif</span>
+<span class="k">#if</span> _FS_SHARE
+    UINT    lockid;       <span class="c">/* File lock ID */</span>
+<span class="k">#endif</span>
+<span class="k">#if</span> !_FS_TINY
+    BYTE    buf[_MAX_SS]; <span class="c">/* Data read/write buffer */</span>
+<span class="k">#endif</span>
+} FIL;
+</pre>
+
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 70 - 0
app/FatFS/doc/en/sfileinfo.html

@@ -0,0 +1,70 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sfileinfo.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - FILINFO</title>
+</head>
+
+<body>
+
+<div class="para">
+<h2>FILINFO</h2>
+<p>The <tt>FILINFO</tt> structure holds a file information returned by f_stat and f_readdir function.</p>
+<pre>
+<span class="k">typedef struct</span> {
+    DWORD fsize;      <span class="c">/* File size */</span>
+    WORD  fdate;      <span class="c">/* Last modified date */</span>
+    WORD  ftime;      <span class="c">/* Last modified time */</span>
+    BYTE  fattrib;    <span class="c">/* Attribute */</span>
+    TCHAR fname[13];  <span class="c">/* Short file name (8.3 format) */</span>
+<span class="k">#if</span> _USE_LFN
+    TCHAR* lfname;    <span class="c">/* Pointer to the LFN buffer */</span>
+    int   lfsize;     <span class="c">/* Size of the LFN buffer in unit of TCHAR */</span>
+<span class="k">#endif</span>
+} FILINFO;
+</pre>
+</div>
+
+<h4>Members</h4>
+<dl>
+<dt>fsize</dt>
+<dd>Indicates size of the file in unit of byte. Always zero for directories.</dd>
+<dt>fdate</dt>
+<dd>Indicates the date that the file was modified or the directory was created.<br>
+<dl>
+<dt>bit15:9</dt>
+<dd>Year origin from 1980 (0..127)</dd>
+<dt>bit8:5</dt>
+<dd>Month (1..12)</dd>
+<dt>bit4:0</dt>
+<dd>Day (1..31)</dd>
+</dl>
+</dd>
+<dt>ftime</dt>
+<dd>Indicates the time that the file was modified or the directory was created.<br>
+<dl>
+<dt>bit15:11</dt>
+<dd>Hour (0..23)</dd>
+<dt>bit10:5</dt>
+<dd>Minute (0..59)</dd>
+<dt>bit4:0</dt>
+<dd>Second / 2 (0..29)</dd>
+</dl>
+</dd>
+<dt>fattrib</dt>
+<dd>Indicates the file/directory attribute in combination of <tt>AM_DIR</tt>, <tt>AM_RDO</tt>, <tt>AM_HID</tt>, <tt>AM_SYS</tt> and <tt>AM_ARC</tt>.</dd>
+<dt>fname[]</dt>
+<dd>Indicates the file/directory name in 8.3 format null-terminated string. It is always returnd with upper case on non-LFN configuration but it can be returned with lower case on LFN configuration.</dd>
+<dt>lfname</dt>
+<dd>Pointer to the LFN buffer to store the read LFN. This member must be initialized by application prior to use this structure. Not available on non-LFN configuration.</dd>
+<dt>lfsize</dt>
+<dd>Size of the LFN buffer in unit of TCHAR. This member must be initialized by application prior to use this structure. Not available on non-LFN configuration.</dd>
+</dl>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 62 - 0
app/FatFS/doc/en/size.html

@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/size.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_size</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_size</h2>
+<p>The f_size function gets the size of a file.</p>
+<pre>
+DWORD f_size (
+  FIL* <em>FileObject</em>   <span class="c">/* File object */</span>
+);
+</pre>
+</div>
+
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object structure.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>Returns the size of the file in unit of byte.</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>In this revision, the f_size function is implemented as a macro.</p>
+<pre>
+<span class="k">#define</span> f_size(fp) ((fp)->fsize)
+</pre>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Always available.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 68 - 0
app/FatFS/doc/en/stat.html

@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/stat.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_stat</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_stat</h2>
+<p>The f_stat gets the file status.</p>
+<pre>
+FRESULT f_stat (
+  const TCHAR* <em>FileName</em>,  <span class="c">/* Pointer to the file or directory name */</span>
+  FILINFO* <em>FileInfo</em>       <span class="c">/* Pointer to the FILINFO structure */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileName</dt>
+<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">file or directory</a> to get its information.</dd>
+<dt>FileInfo</dt>
+<dd>Pointer to the blank <tt>FILINFO</tt> structure to store the information.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ok">FR_NO_FILE</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_stat gets the information of a file or directory. For details of the infomation, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html">f_readdir</a> function. This function is not supported in minimization level of &gt;= 1.</p>
+</div>
+
+
+<div class="para ref">
+<h4>References</h4>
+<p><tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 65 - 0
app/FatFS/doc/en/sync.html

@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sync.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_sync</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_sync</h2>
+<p>The f_sync function flushes the cached information of a writing file.</p>
+<pre>
+FRESULT f_sync (
+  FIL* <em>FileObject</em>     <span class="c">/* Pointer to the file object */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object to be flushed.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_sync function performs the same process as f_close function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing f_sync of periodic or immediataly after f_write can minimize the risk of data loss due to a sudden blackout or an unintentional disk removal. However f_sync immediataly before f_close has no advantage because f_close performs f_sync in it. In other words, the differnce between those functions is that the file object is invalidated or not. </p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt>.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="close.html">f_close</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 62 - 0
app/FatFS/doc/en/tell.html

@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/tell.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_tell</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_tell</h2>
+<p>The f_tell function gets the current read/write pointer of a file.</p>
+<pre>
+DWORD f_tell (
+  FIL* <em>FileObject</em>   <span class="c">/* File object */</span>
+);
+</pre>
+</div>
+
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object structure.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>Returns current read/write pointer of the file.</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>In this revision, the f_tell function is implemented as a macro.</p>
+<pre>
+<span class="k">#define</span> f_tell(fp) ((fp)->fptr)
+</pre>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Always available.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 66 - 0
app/FatFS/doc/en/truncate.html

@@ -0,0 +1,66 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/truncate.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_truncate</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_truncate</h2>
+<p>The f_truncate function truncates the file size.</p>
+<pre>
+FRESULT f_truncate (
+  FIL* <em>FileObject</em>     <span class="c">/* Pointer to the file object */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object to be truncated.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_truncate function truncates the file size to the current file read/write point. This function has no effect if the file read/write pointer is already pointing end of the file.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 76 - 0
app/FatFS/doc/en/unlink.html

@@ -0,0 +1,76 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/unlink.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_unlink</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_unlink</h2>
+<p>The f_unlink function removes a file or directory.</p>
+<pre>
+FRESULT f_unlink (
+  const TCHAR* <em>FileName</em>  <span class="c">/* Pointer to the object name */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>FileName</dt>
+<dd>Pointer to the null-terminated string that specifies an <a href="filename.html">object</a> to be removed.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ok">FR_NO_FILE</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#de">FR_DENIED</a>,
+<a href="rc.html#ex">FR_EXIST</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#lo">FR_LOCKED</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>
+If condition of the object to be removed is applicable to the following terms, the function will fail with error.
+<ul>
+<li>The object must not have read-only attribute (AM_RDO) or the function will be rejected with <tt>FR_DENIED</tt>.</li>
+<li>The directory must be empty and must not be current directory or the function will be rejected with <tt>FR_DENIED</tt>.</li>
+<li>The file must not have been opened or the <em>FAT volume can be collapted</em>. It will able to be rejected with <tt>FR_LOCKED</tt> when <a href="appnote.html#dup">file shareing control</a> is enabled.</li>
+</ul>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
+</div>
+
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 99 - 0
app/FatFS/doc/en/utime.html

@@ -0,0 +1,99 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/utime.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_utime</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_utime</h2>
+<p>The f_utime function changes the timestamp of a file or directory.</p>
+<pre>
+FRESULT f_utime (
+  const TCHAR* <em>FileName</em>,   <span class="c">/* Pointer to the file or directory path */</span>
+  const FILINFO* <em>TimeDate</em>  <span class="c">/* Time and data to be set */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileName</dt>
+<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">file or directory</a> to be changed.</dd>
+<dt>TimeDate</dt>
+<dd>Pointer to the file information structure that has a timestamp to be set in member fdate and ftime. Do not care any other members.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ok">FR_NO_FILE</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The f_utime function changes the timestamp of a file or directory</p>
+</div>
+
+
+<div class="para use">
+<h4>Example</h4>
+<pre>
+FRESULT set_timestamp (
+    char *obj,     <span class="c">/* Pointer to the file name */</span>
+    int year,
+    int month,
+    int mday,
+    int hour,
+    int min,
+    int sec
+)
+{
+    FILINFO fno;
+
+    fno.fdate = (WORD)(((year - 1980) * 512U) | month * 32U | mday);
+    fno.ftime = (WORD)(hour * 2048U | min * 32U | sec / 2U);
+
+    return f_utime(obj, &amp;fno);
+}
+</pre>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 74 - 0
app/FatFS/doc/en/write.html

@@ -0,0 +1,74 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_e.html">
+<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/write.html">
+<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_write</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_write</h2>
+<p>The f_write writes data to a file.</p>
+<pre>
+FRESULT f_write (
+  FIL* <em>FileObject</em>,     <span class="c">/* Pointer to the file object structure */</span>
+  const void* <em>Buffer</em>,  <span class="c">/* Pointer to the data to be written */</span>
+  UINT <em>ByteToWrite</em>,    <span class="c">/* Number of bytes to write */</span>
+  UINT* <em>ByteWritten</em>    <span class="c">/* Pointer to the variable to return number of bytes written */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>Pointer to the open file object structure.</dd>
+<dt>Buffer</dt>
+<dd>Pointer to the data to be written.</dd>
+<dt>ByteToWrite</dt>
+<dd>Specifies number of bytes to write in range of UINT.</dd>
+<dt>ByteWritten</dt>
+<dd>Pointer to the UINT variable to return the number of bytes written. The value is always valid after the function call regardless of the result.</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>Return Values</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The read/write pointer in the file object is increased in number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect the disk full. In case of <tt>*ByteWritten &lt; ByteToWrite</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p>
+</div>
+
+
+<div class="para comp">
+<h4>QuickInfo</h4>
+<p>Available when <tt>_FS_READONLY == 0</tt>.</p>
+</div>
+
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">fputc</a>, <a href="puts.html">fputs</a>, <a href="printf.html">fprintf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

BIN
app/FatFS/doc/img/Thumbs.db


BIN
app/FatFS/doc/img/f1.png


BIN
app/FatFS/doc/img/f2.png


BIN
app/FatFS/doc/img/f3.png


BIN
app/FatFS/doc/img/f4.png


BIN
app/FatFS/doc/img/f5.png


BIN
app/FatFS/doc/img/f6.png


BIN
app/FatFS/doc/img/layers.png


BIN
app/FatFS/doc/img/layers3.png


BIN
app/FatFS/doc/img/rwtest.png


BIN
app/FatFS/doc/img/rwtest2.png


BIN
app/FatFS/doc/img/rwtest3.png


+ 255 - 0
app/FatFS/doc/ja/appnote.html

@@ -0,0 +1,255 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/appnote.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFsモジュール アプリケーション・ノート</title>
+</head>
+
+<body>
+<h1>FatFsモジュール アプリケーション・ノート</h1>
+<ol class="toc">
+<li><a href="#port">ポーティングの際に配慮すべきこと</a></li>
+<li><a href="#limits">限界値</a></li>
+<li><a href="#memory">メモリ使用量</a></li>
+<li><a href="#reduce">モジュール・サイズの縮小</a></li>
+<li><a href="#lfn">長いファイル名</a></li>
+<li><a href="#jap">日本語ファイル名の大文字変換</a></li>
+<li><a href="#unicode">Unicode入出力への対応</a></li>
+<li><a href="#reentrant">リエントランシー</a></li>
+<li><a href="#dup">多重ファイル・アクセス</a></li>
+<li><a href="#fs1">効率的なファイル・アクセス</a></li>
+<li><a href="#fs2">フラッシュ・メモリの特性への配慮</a></li>
+<li><a href="#critical">クリチカル・セクション</a></li>
+<li><a href="#license">FatFsのライセンスについて</a></li>
+</ol>
+<hr>
+
+<div class="para" id="port">
+<h3>ポーティングの際に配慮すべきこと</h3>
+<h4>移植の際の前提条件</h4>
+<p>FatFsモジュールは移植性に関して次の点を前提としています。</p>
+<ul>
+<li>処理系はANSI C準拠であること。<br>
+FatFsモジュールはANSI C(C89)準拠で記述されているので、ANSI Cに準拠したまともなコンパイラなら特に処理系依存になる点はありません。</li>
+<li>char/short/longのサイズは、それぞれ8/16/32ビットで、intは16または32ビットであること。<br>
+サイズを明示する整数型が integer.h 内で定義されています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合はユーザによって解決されなければなりません。</li>
+</ul>
+<h4>ユーザの作成する関数</h4>
+<p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるならその APIを FatFsに合わせるだけで済みますが、無い場合はほかから移植するか、最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
+<table class="lst2">
+<tr><th>ユーザ作成関数</th><th>必要となる条件</th><th>備考</th></tr>
+<tr><td>disk_initialize<br>disk_status<br>disk_read</td><td>常時</td><td rowspan="5">ffsample.zip (サンプル)<br>その他web上に多数</td></tr>
+<tr><td>disk_write<br>get_fattime<br>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr>
+<tr><td>disk_ioctl (GET_SECTOR_COUNT)<br>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
+<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS &gt;= 1024</td></tr>
+<tr><td>disk_ioctl (CTRL_ERASE_SECTOR)</td><td>_USE_ERASE == 1</td></tr>
+<tr><td>ff_convert<br>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td><td>option/cc*.c</td></tr>
+<tr><td>ff_cre_syncobj<br>ff_rel_grant<br>ff_req_grant<br>ff_del_syncobj</td><td>_FS_REENTRANT == 1</td><td rowspan="2">option/syscall.c (サンプル)</td></tr>
+<tr><td>ff_mem_alloc<br>ff_mem_free</td><td>_USE_LFN == 3</td></tr>
+</table>
+</div>
+
+<div class="para" id="limits">
+<h3>限界値</h3>
+<ul>
+<li>FATタイプ: FAT12, FAT16, FAT32。</li>
+<li>同時オープン・ファイル数: 無制限。(利用可能メモリによる)</li>
+<li>ボリューム数: 最大 10。</li>
+<li>ファイル・サイズ: FAT規格に依存。(最大 4G-1バイト)</li>
+<li>ボリューム・サイズ: FAT規格に依存。(最大 2Tバイト(512バイト/セクタ時))</li>
+<li>クラスタ・サイズ: FAT規格に依存。(最大 64Kバイト(512バイト/セクタ時))</li>
+<li>セクタ・サイズ: FAT規格に依存。(最大 4Kバイト)</li>
+</ul>
+</div>
+
+<div class="para" id="memory">
+<h3>メモリ使用量 (R0.09)</h3>
+<p>次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、<em>V</em>は同時マウント・ボリューム数、<em>F</em>は同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。</p>
+<table class="lst2">
+<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>Cortex-M3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX62N</th><th>IA-32</th></tr>
+<tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr>
+<tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
+<tr class="lst3"><td>text (Full, R/W)</td><td>10459</td><td>7201</td><td>6623</td><td>12646</td><td>10686</td><td>11466</td><td>12967</td><td>7732</td><td>8752</td><td>5747</td><td>7545</td></tr>
+<tr><td>text (Min, R/W)</td><td>6503</td><td>4745</td><td>4297</td><td>8306</td><td>6986</td><td>7440</td><td>8745</td><td>4938</td><td>5576</td><td>3746</td><td>4923</td></tr>
+<tr><td>text (Full, R/O)</td><td>4535</td><td>3181</td><td>2869</td><td>5960</td><td>4876</td><td>5286</td><td>6060</td><td>3554</td><td>3804</td><td>2659</td><td>3450</td></tr>
+<tr><td>text (Min, R/O)</td><td>3303</td><td>2493</td><td>2171</td><td>4366</td><td>3770</td><td>3984</td><td>4604</td><td>2684</td><td>2940</td><td>2025</td><td>2664</td></tr>
+<tr><td>bss</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
+<tr><td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr>
+<tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr>
+</table>
+<pre>
+_FS_READONLY     0 (R/W), 1 (R/O)
+_FS_MINIMIZE     0 (Full function), 3 (Minimized function)
+_USE_STRFUNC     0 (Disable string functions)
+_USE_MKFS        0 (Disable f_mkfs function)
+_USE_FORWARD     0 (Disable f_forward function)
+_USE_FASTSEEK    0 (Disable fast seek feature)
+_CODE_PAGE       932 (Japanese Shift-JIS)
+_USE_LFN         0 (Disable LFN)
+_MAX_SS          512 (Fixed sector size)
+_FS_RPATH        0 (Disable relative path)
+_VOLUMES         D (Number of logical drives to be used)
+_MULTI_PARTITION 0 (Single partition per drive)
+_FS_REENTRANT    0 (Disable reentrancy)
+_FS_SHARE        0 (Disable shareing control)
+</pre>
+</div>
+
+<div class="para" id="reduce">
+<h3>モジュール・サイズの縮小</h3>
+<p>次の表は構成オプションの設定値によりどの機能が削除されるかを示します。</p>
+<table class="lst2">
+<tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr>
+<tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0&nbsp;&nbsp;</td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0/1</td><td>2</td></tr>
+<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr>
+<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr>
+<tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+</table>
+</div>
+
+<div class="para" id="lfn">
+<h3>長いファイル名</h3>
+<p>FatFsモジュールはR0.07から長いファイル名(LFN)をサポートしました。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、f_readdir関数を除くファイル操作関数において透過です。LFN機能を有効にするには、<tt>_USE_LFN</tt>を1,2または3に設定し、Unicode変換関数<tt>ff_convert(), ff_wtoupper()</tt>をプロジェクトに追加します。これらの関数は、<tt>option/cc*.c</tt>に含まれています。LFN機能は、加えてある程度のワーク・エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて<tt>_MAX_LFN</tt>オプションで構成されることができます。LFNの長さは最大255文字に達するので、LFN完全対応のためには<tt>_MAX_LFN</tt>は255に設定されるべきです。与えられたファイル名に対してバッファ長が不足した場合、ファイル関数は<tt>FR_INVALID_NAME</tt>で失敗します。</p>
+<p>何らかのリエントラント状態の下でLFN機能を使用する場合は、<tt>_USE_LFN</tt>は2または3に設定されなければなりません。この場合、ファイル関数はバッファをスタックやヒープに確保します。バッファ・サイズは、<tt>(_MAX_LFN + 1) * 2</tt>バイトになるので、スタック等のサイズはそれを考慮した十分なサイズでなければなりません。</p>
+<table class="lst2 rset">
+<caption>LFN cfg on ARM7</caption>
+<tr><th>コードページ</th><th>コードサイズ[bytes]</th></tr>
+<tr><td>SBCS</td><td>+3721</td></tr>
+<tr><td>932(Shift-JIS)</td><td>+62609</td></tr>
+<tr><td>936(GBK)</td><td>+177797</td></tr>
+<tr><td>949(Korean)</td><td>+139857</td></tr>
+<tr><td>950(Big5)</td><td>+111497</td></tr>
+</table>
+<p>LFN機能の上手な使い方は、それを使わないということです。実際、組み込み用途ではLFN機能がどうしても必要になるということはほとんど無いはずです。LFNを有効にすると、選択されたコード・ページに応じてモジュール・サイズが増大されます。右の表に各コード・ページにおけるLFNを有効にしたときのモジュール・サイズの違いを示します。私たち日本人、中国人および韓国人は数万の文字を持ちます。不幸なことに、それは巨大なOEM-Unicode相互変換テーブルを要求し、モジュール・サイズは劇的に増大されます。その結果、LFNを有効にしたFatFsモジュールは、AVRを含む殆どの8ビット・マイコンにインプリメントされることができません。<small>これは長い間私がLFNをインプリメントすることに興味を持ってこなかった理由です。</small></p>
+<p>注: マイクロソフト社はFATファイル・システムについていくつかの特許を保有しています。いずれもLFNの実装に関するもので、LFN機能に対して$0.25/unitのライセンス料を要求しています。最近のFAT32ドライバの多くはLFN機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFsではLFN機能の有効・無効を任意に構成できます。このため、商用製品でLFN機能を有効にするときは、最終仕向地によってはライセンスが必要かも知れません。</p>
+</div>
+
+<div class="para" id="jap">
+<h3>日本語ファイル名の大文字変換</h3>
+<p>CP932(Shift_JIS)でかつ非LFN構成のときは、拡張文字の小文字(2バイト英字・キリル文字・ギリシャ文字)に対して大文字変換を行わず、小文字のままSFNエントリに記録・検索されます(日本語MSDOS仕様)。このため、非LFN構成で全角小文字を含むファイルを作成すると、NT系Windowsでそのファイルを開けなくなります。LFN構成では大文字変換を行います(NT系Windows仕様)。</p>
+</div>
+
+<div class="para" id="unicode">
+<h3>Unicode入出力への対応</h3>
+<p>ファイル関数のファイル名入出力はデフォルトでは ANSI/OEMコードですが、これをUnicodeに切り替えることもできます。Unicodeファイル名に関する詳細は、<a href="filename.html">ファイル名</a>を参照してください。</p>
+</div>
+
+<div class="para" id="reentrant">
+<h3>リエントランシー</h3>
+<p>互いに異なるボリュームに対するファイル操作はリエントラントで、常に同時平行に動作できます。同じボリュームに対してはデフォルトではリエントラントではありませんが、<tt>_FS_REENTRANT</tt>オプションでリエントラント(スレッド・セーフ)にすることはできます。この場合、OS依存の同期オブジェクト操作関数<tt>ff_cre_syncobj, ff_del_syncobj, ff_req_grant</tt> と <tt>ff_rel_grant</tt>もまたプロジェクトに追加されなければなりません。サンプル・コードと解説は<tt>option/syncobj.c</tt>にあります。</p>
+<p>この場合、あるタスクがボリュームを使用中に他のタスクからそのボリュームに対するファイル関数が呼び出されると、そのアクセスは先のタスクがファイル関数を抜けるまでブロックされます。もし、待ち時間が<tt>_TIMEOUT</tt>で指定された期間を越すと、その関数は<tt>FR_TIMEOUT</tt>でアボートします。いくつかのRTOSではタイムアウト機能はサポートされないかも知れません。</p>
+<p>ひとつの例外が<tt>f_mount()</tt>と<tt>f_mkfs()</tt>にあります。これらの関数は同じボリュームに対してリエントラントではありません。これらの関数を使用するときは、アプリケーション・レベルで排他制御しなければなりません。</p>
+<p>注: このセクションはFatFsモジュールそれ自体のリエントランシーについて説明しています。ディスクI/Oモジュールのリエントランシーに関しては何の前提もありません。</p>
+</div>
+
+<div class="para" id="dup">
+<h3>多重ファイル・アクセス</h3>
+<p>FatFsモジュールではデフォルトでは多重アクセス制御機能をサポートしていません。ファイルに対する多重アクセスは、そのアクセス・モードによって制限されます。一つのファイルに対する多重オープンは、それらが全てリード・モードのときに限って許可されます。書き込みモードを含む多重オープン、また開かれているファイルに対するリネームや削除を行ってはなりません。さもないと、そのボリュームのFAT構造が破壊される可能性があります。</p>
+<p><tt>_FS_SHARE</tt>に1以上の値(値は同時に管理できるファイル数)をセットすることで多重アクセス制御機能が有効になり、ファイル単位の排他制御を自動で行うこともできます。この場合、上記のルールを破ったオープン・リネーム・削除を試みると、その関数は<tt>FR_LOCKED</tt>で失敗します。<tt>_FS_SHARE</tt>を越えた数のファイルをオープンしようとすると、<tt>FR_TOO_MANY_OPEN_FILES</tt>で失敗します。</p>
+</div>
+
+<div class="para" id="fs1">
+<h3>効率的なファイル・アクセス</h3>
+<p>小規模な組込システムでのファイルの読み書きにおける効率の良いアクセスのため、アプリケーション・プログラマはFatFsモジュールの中でどのような処理が行われているか考慮すべきです。ストレージ上のデータはf_read関数により次のシーケンスで転送されます。</p>
+<p>図1. セクタ・ミスアラインド・リード (ショート)<br>
+<img src="../img/f1.png" width="490" height="110" alt="fig.1">
+</p>
+<p>図2. セクタ・ミスアラインド・リード (ロング)<br>
+<img src="../img/f2.png" width="490" height="140" alt="fig.2">
+</p>
+<p>図3. セクタ・アラインド・リード<br>
+<img src="../img/f3.png" width="490" height="119" alt="fig.3">
+</p>
+<p>ファイルI/Oバッファはセクタの一部のデータを読み書きするためのセクタ・バッファを意味します。セクタ・バッファは、それぞれのファイル・オブジェクト内のプライベート・セクタ・バッファまたはファイル・システム・オブジェクト内の共有セクタ・バッファのどちらかです。バッファ構成オプションの<tt>_FS_TINY</tt>は、データ転送にどちらを使うかを決定します。タイニー・バッファ(1)が選択されるとデータ・メモリの消費はそれぞれのファイル・オブジェクトで512バイト減少されます。この場合、FatFsモジュールはファイル・データの転送とFAT/ディレクトリ・アクセスにファイル・システム・オブジェクト内のセクタ・バッファだけを使用します。タイニー・バッファの欠点は、セクタ・バッファにキャッシュされたFATデータがファイル・データの転送により失われ、クラスタ境界の毎にリロードされなければならないことです。でも、悪くない性能と少ないメモリ消費の視点から多くのアプリケーションに適するでしょう。</p>
+<p>図1はセクタの一部のデータがファイルI/Oバッファを経由で転送されることを示します。図2に示される長いデータの転送では、転送データの中間の1セクタまたはそれ以上のセクタにまたがる転送データがアプリケーション・バッファに直接転送されています。図3は転送データ全体がセクタ境界にアライメントされている場合を示しています。この場合、ファイルI/Oバッファは使用されません。直接転送においては最大の範囲のセクタがdisk_read関数で一度に読み込まれますが、クラスタ境界を越えるマルチ・セクタ転送はそれが隣接であっても行われません。</p>
+<p>このように、セクタにアライメントしたファイルの読み書きへの配慮はバッファ経由のデータ転送を避け、読み書き性能は改善されるでしょう。その効果に加え、タイニー構成でキャッシュされたFATデータがファイル・データの転送によりフラッシュされず、非タイニー構成と同じ性能を小さなメモリ・フットプリントで達成できます。</p>
+</div>
+
+<div class="para" id="fs2">
+<h3>フラッシュ・メモリの特性への配慮</h3>
+<p>HDDなどのディスク・メディアとは異なり、SDCやCFCなどのフラッシュ・メモリ・メディアの性能を引き出すには、その特性を意識した制御が必要になります。</p>
+<h4>マルチ・セクタ書き込み</h4>
+<div class="rset">
+図6. マルチ/シングル・セクタ・ライトの比較<br>
+<img src="../img/f6.png" width="630" height="148" alt="fig.6">
+</div>
+<p>フラッシュ・メモリ・メディアの書き込み速度はシングル・セクタ書き込みの時に最も低いものになり、一回のトランザクションで転送されるセクタ数が大きくなるほど書き込み速度は向上します。この効果はバス速度が高速になるほど顕著で、10倍以上の差が現れることも珍しくありません。書き込みトランザクションの回数はまた、メディアの寿命にも影響してきます。このため、アプリケーションはなるべく大きなブロック(クラスタ・サイズまたは2の累乗セクタ境界にアライメントした)で読み書きを行う必要があります。もちろん、アプリケーションからメディアに至る全てのレイヤがマルチ・セクタ転送に対応していないと意味がありません。残念ながら、既存のオープン・ソースのドライバの多くはマルチ・セクタ転送に未対応です。なお、FatFsモジュールおよびそれ用のサンプル・ドライバはマルチ・セクタ転送に対応しています。</p>
+<h4>明示的なメモリ消去</h4>
+<p>通常のファイル消去では、記録されたデータに対して何らかの制御が行われるわけではなく、単にFAT上に未使用クラスタとして記録されているだけです。このため、ファイルが消去されたあともそれらは有効なメモリ・ブロックとしてフラッシュ・メモリ上に残ります。そこで、ファイルを消去するとき、占有していたデータ・セクタを明示的に消去(つまり未使用ブロックにする)することにより、メディア内の空きブロックを増やすことができます。これにより、次にそのブロックに書き込むときの消去動作が無くなり、書き込み性能が向上する可能性があります。また、ウェアレベリングに使えるブロックが増え、メディアの耐久性も向上するかも知れません。この機能を有効にするには、構成オプションの<tt>_USE_ERASE</tt>に1を設定します。これはフラッシュ・メモリ・メディアの内部動作に期待した制御なので、効果があるとは限りません。また、ファイル消去の時間が延びることも考慮に入れるべきです。</p>
+</div>
+
+<div class="para" id="critical">
+<h3>クリチカル・セクション</h3>
+<p>ストレージ上のFAT構造を操作している途中で、停電、不正なメディアの取り外し、回復不能なデータ・エラー等の障害が発生すると、処理が中途半端な状態で中断され、その結果としてFAT構造が破壊される可能性があります。次にFatFsモジュールにおけるクリチカル・セクションと、その間の障害により起きうるエラーの状態を示します。</p>
+<div class="lset">
+図4. 長いクリチカル・セクション<br>
+<img src="../img/f4.png" width="320" height="436" alt="fig.4">
+</div>
+<div class="lset">
+図5. 最小化したクリチカル・セクション<br>
+<img src="../img/f5.png" width="320" height="436" alt="fig.5">
+</div>
+<br class="clr">
+<p>赤で示したセクションを実行中に障害が発生した場合、クロス・リンクが発生して操作対象のファイル・ディレクトリが失われる可能性があります。黄色で示したセクションを実行中に障害が発生した場合、つぎのうちいずれかまたは複数の結果が生じる可能性があります。</p>
+<ul>
+<li>書き換え中のファイルのデータが破壊される。</li>
+<li>追記中のファイルがオープン前の状態に戻る。</li>
+<li>新規に作成されたファイルが消える。</li>
+<li>新規または上書きで作成されたファイルの長さがゼロになって残る。</li>
+<li>ロストチェーンの発生によりボリュームの利用効率が悪化する。</li>
+</ul>
+<p>いずれも書き込み中や操作対象でないファイルには影響はありません。これらのクリチカル・セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、f_sync()を適宜使用することで図5のようにリスクを最小化することができます。</p>
+</div>
+
+<div class="para" id="license">
+<h3>FatFsのライセンスについて</h3>
+<p>ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。</p>
+<pre>/*----------------------------------------------------------------------------/
+/  FatFs - FAT file system module  R0.09                    (C)ChaN, 2011
+/-----------------------------------------------------------------------------/
+/ FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・
+/ モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために
+/ 以下のライセンス・ポリシーの下で公開されています。
+/
+/  Copyright (C) 2011, ChaN, all right reserved.
+/
+/ * FatFsモジュールはフリー・ソフトウェアであり、また<em>無保証です</em>。
+/ * 用途に制限はありません。<em>あなたの責任の下において</em>、個人的・非営利的な
+/   ものから商用製品の開発に及ぶ目的に使用・改変・再配布することができます。
+/ * ソース・コードを再配布するときは、上記の著作権表示を保持しなければなりません。
+/
+/-----------------------------------------------------------------------------/</pre>
+<p>要するにFatFsはタダで自由に使えるということです。ソース・コードを再配布するときは、このブロックをそのまま保持しておくこと。このようにFatFsはBSDライクなライセンスとしていますが、一つ大きな違いがあります。特に組み込み用途での利用価値を高めるため、バイナリ形式(ソース・コードを含まない形式全て)での再配布については、条件は設けていません。その場合は、FatFsおよびそのライセンス文書についてはドキュメントに明記してもしなくてもかまいません。もちろんGNU GPLプロジェクトとも共存可能です。何らかの変更を加えて再配布する際は、矛盾しない他のライセンス(GNU GPLやBSDライセンスなど)に変更することも可能です。</p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 81 - 0
app/FatFS/doc/ja/chdir.html

@@ -0,0 +1,81 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/chdir.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_chdir</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_chdir</h2>
+<p>カレント・ディレクトリを変更します。</p>
+<pre>
+FRESULT f_chdir (
+  const XCHAR* <em>Path</em> <span class="c">/* ディレクトリ名へのポインタ */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Path</dt>
+<dd>移動対象のディレクトリの<a href="filename.html">パス名</a>の入った<tt>'\0'</tt>で終わる文字列を指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ok">FR_NO_FILE</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>f_chdir関数は各ボリュームのカレント・ディレクトリを変更します。カレント・ディレクトリはファイル・システム・オブジェクトの初期化が行われたとき、ルート・ディレクトリに設定されます。カレント・ディレクトリは、ファイル・システム・オブジェクトに記録されるため、そのボリュームを使用する全てのタスクに対して影響を与えます。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_FS_RPATH == 1</tt>のときに使用可能となります。</p>
+</div>
+
+
+<div class="para exa">
+<h4>使用例</h4>
+<pre>
+    // カレント・ドライブのカレント・ディレクトリを変更 (ルート下のdir1へ)
+    f_chdir("/dir1");
+
+    // ドライブ2のカレント・ディレクトリを変更 (親ディレクトリへ)
+    f_chdir("2:..");
+</pre>
+</div>
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="chdrive.html">f_chdrive</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 61 - 0
app/FatFS/doc/ja/chdrive.html

@@ -0,0 +1,61 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/chdrive.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_chdrive</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_chdrive</h2>
+<p>カレント・ドライブを変更します。</p>
+<pre>
+FRESULT f_chdrive (
+  BYTE <em>Drive</em> <span class="c">/* 論理ドライブ番号 */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>カレント・ドライブに設定する<a href="filename.html">論理ドライブ番号</a>を指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>f_chdrive関数はカレント・ドライブを変更します。システム起動時の初期値は0です。この設定はFatFsモジュールの静的変数に記録されるため、全てのタスクに対して影響を与えます。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_FS_RPATH == 1</tt>のときに使用可能となります。</p>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="chdir.html">f_chdir</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">Return</a></p>
+</body>
+</html>

+ 89 - 0
app/FatFS/doc/ja/chmod.html

@@ -0,0 +1,89 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/chmod.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_chmod</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_chmod</h2>
+<p>ファイルまたはディレクトリの属性を変更します。</p>
+<pre>
+FRESULT f_chmod (
+  const TCHAR* <em>FileName</em>, <span class="c">/* ファイルまたはディレクトリ名へのポインタ */</span>
+  BYTE <em>Attribute</em>,        <span class="c">/* 設定値 */</span>
+  BYTE <em>AttributeMask</em>     <span class="c">/* 変更マスク */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>FileName</dt>
+<dd>属性変更対象のファイルまたはディレクトリの<a href="filename.html">パス名</a>の入った<tt>'\0'</tt>で終わる文字列を指定します。</dd>
+<dt>Attribute</dt>
+<dd>設定する属性。指定可能な属性は次の通りで、これらの組み合わせで指定します。指定されなかった属性は解除されます。<br>
+<table class="lst">
+<tr><th>値</th><th>意味</th></tr>
+<tr><td>AM_RDO</td><td>リード・オンリー</td></tr>
+<tr><td>AM_ARC</td><td>アーカイブ</td></tr>
+<tr><td>AM_SYS</td><td>システム</td></tr>
+<tr><td>AM_HID</td><td>ヒドゥン</td></tr>
+</table>
+</dd>
+<dt>AttributeMask</dt>
+<dd>変更する属性のマスク。指定した属性が設定または解除され、指定されなかった属性は状態が保持されます。<tt>Attribute</tt>と同じ値を使います。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ok">FR_NO_FILE</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#lo">FR_LOCKED</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>ファイルまたはディレクトリの属性を変更します。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のとき使用可能です。</p>
+</div>
+
+
+<div class="para use">
+<h4>使用例</h4>
+<pre>
+    <span class="c">/* リードオンリーをセット、アーカイブをクリア、その他は変更しない */</span>
+    f_chmod("file.txt", AM_RDO, AM_RDO | AM_ARC);
+</pre>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 65 - 0
app/FatFS/doc/ja/close.html

@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/close.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_close</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_close</h2>
+<p>ファイルを閉じます。</p>
+<pre>
+FRESULT f_close (
+  FIL* <em>FileObject</em>     <span class="c">/* ファイル・オブジェクトへのポインタ */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>閉じようとするファイルのファイル・オブジェクト構造体へのポインタを指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>ファイルを閉じます。何らかの書き込みの行われたファイルの場合、キャッシュされた状態(リード/ライト・バッファ上のデータ、変更されたFATやディレクトリ項目)はディスクに書き戻されます。関数が正常終了すると、そのファイル・オブジェクトは無効になり、そのメモリも解放できます。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p>全ての構成で使用可能です。</p>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="write.html">f_write</a>,  <a href="sync.html">f_sync</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 46 - 0
app/FatFS/doc/ja/dinit.html

@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/dinit.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - disk_initialize</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>disk_initialize</h2>
+<p>ディスク・ドライブを初期化します。</p>
+<pre>
+DSTATUS disk_initialize (
+  BYTE <em>Drive</em>      <span class="c">/* 物理ドライブ番号 */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>初期化する物理ドライブ番号(0-9)を指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>この関数は戻り値としてディスク・ステータスを返します。ディスク・ステータスの詳細に関しては<tt><a href="dstat.html">disk_status()</a></tt>を参照してください。</p>
+</div>
+
+<div class="para desc">
+<h4>解説</h4>
+<p>ディスク・ドライブを初期化します。関数が成功すると、戻り値の<tt>STA_NOINIT</tt>フラグがクリアされます。</p>
+<p><em>アプリケーションからはこの関数を呼び出してはなりません。さもないと、FATボリュームが破壊されます。エラー等により再初期化が必要なときは、<tt>f_mount()</tt>を使用してください。</em>FatFsモジュールは、自動マウント動作により、必要に応じてこの関数を呼び出します。</p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 68 - 0
app/FatFS/doc/ja/dioctl.html

@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/dioctl.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - disk_ioctl</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>disk_ioctl</h2>
+<p>セクタの読み書き以外のディスク・ドライブ自体に対する様々な制御をします。</p>
+<pre>
+DRESULT disk_ioctl (
+  BYTE <em>Drive</em>,      <span class="c">/* 物理ドライブ番号 */</span>
+  BYTE <em>Command</em>,    <span class="c">/* 制御コマンド */</span>
+  void* <em>Buffer</em>     <span class="c">/* データ受け渡しバッファ */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>物理ドライブ番号(0-9)を指定します。</dd>
+<dt>Command</dt>
+<dd>制御コマンド・コードを指定します。</dd>
+<dt>Buffer</dt>
+<dd>制御コマンドに依存したパラメータを授受するバッファを指すポインタを指定します。データの授受のないコマンドの場合は、NULLを指定します。</dd>
+</dl>
+</div>
+
+<div class="para ret">
+<h4>戻り値</h4>
+<dl class="ret">
+<dt>RES_OK (0)</dt>
+<dd>正常終了。</dd>
+<dt>RES_ERROR</dt>
+<dd>何らかのエラーが発生した。</dd>
+<dt>RES_PARERR</dt>
+<dd>コマンドが不正。</dd>
+<dt>RES_NOTRDY</dt>
+<dd>ドライブが動作可能状態ではない、または初期化されていない。</dd>
+</dl>
+</div>
+
+<div class="para desc">
+<h4>解説</h4>
+<p>物理ドライブの種類によりサポートされるコマンドは異なりますが、FatFsモジュールでは、次の汎用コマンドのみ使用し、特定のハードウェアに依存した制御は行いません。</p>
+<table class="lst">
+<tr><th>コマンド</th><th>解説</th></tr>
+<tr><td>CTRL_SYNC</td><td>ドライブがデータの書き込み処理を完了するのを待ちます。また、ライト・バック・キャッシュが存在する場合は、書き込まれていないデータを即時書き戻します。リード・オンリー構成では使用されません。</td></tr>
+<tr><td>GET_SECTOR_SIZE</td><td><tt>Buffer</tt>の指すWORD変数にドライブのセクタ・サイズを返します。セクタ・サイズが固定(<tt>_MAX_SS</tt>が512)のときはこのコマンドは使われません。</td></tr>
+<tr><td>GET_SECTOR_COUNT</td><td><tt>Buffer</tt>の指すDWORD変数にドライブ上の総セクタ数を返します。f_mkfs関数内で作成するボリュームのサイズを決定するために使用されます。</td></tr>
+<tr><td>GET_BLOCK_SIZE</td><td>フラッシュ・メモリの消去ブロック・サイズを<tt>Buffer</tt>の指すDWORD変数にセクタ単位で返します。1から32768でかつ2の累乗の値でなければなりません。不明な場合またはフラッシュ・メモリ以外のメディアでは1を返します。f_mkfs関数内でのみ使用され、ボリュームのデータ領域はこの境界にアライメントされます。</td></tr>
+<tr><td>CTRL_ERASE_SECTOR</td><td>フラッシュ・メモリの一部の領域を消去します。<tt>Buffer</tt>の指すDWORD配列には消去する領域 {開始セクタ,終了セクタ} を指定して呼び出します。この機能をサポートしない場合やフラッシュ・メモリ以外のメディアでは何もしません。この機能の戻り値はチェックされず、また、指定領域の消去が完全に行われなかったとしてもファイル・システムの動作には影響ありません。<tt>_USE_ERASE</tt>が1のとき、クラスタが解放されるときに呼び出されます。</td></tr>
+</table>
+</div>
+
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 59 - 0
app/FatFS/doc/ja/dread.html

@@ -0,0 +1,59 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/dread.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - disk_read</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>disk_read</h2>
+<p>ディスクからセクタを読み出します。</p>
+<pre>
+DRESULT disk_read (
+  BYTE <em>Drive</em>,          <span class="c">/* 物理ドライブ番号 */</span>
+  BYTE* <em>Buffer</em>,        <span class="c">/* 読み出しバッファへのポインタ */</span>
+  DWORD <em>SectorNumber</em>,  <span class="c">/* 読み出し開始セクタ番号 */</span>
+  BYTE <em>SectorCount</em>     <span class="c">/* 読み出しセクタ数 */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>物理ドライブ番号(0-9)を指定します。</dd>
+<dt>Buffer</dt>
+<dd>ディスクから読み出したデータを格納する<em>バイト配列</em>で、読み出されるバイト数分のサイズが必要です。指定されるアドレスはワード・アライメントされているとは限りません。</dd>
+<dt>SectorNumber</dt>
+<dd>読み出しを開始するセクタ番号。LBAで指定します。</dd>
+<dt>SectorCount</dt>
+<dd>読み出すセクタ数。 1~128の範囲で指定します。一般的に、複数セクタの転送要求はデバイスに対して可能な限りマルチ・セクタ転送しなければなりません。複数のシングル・セクタ転送に分解した場合、読み出し速度が低下します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<dl class="ret">
+<dt>RES_OK (0)</dt>
+<dd>正常終了。</dd>
+<dt>RES_ERROR</dt>
+<dd>読み込み中にエラーが発生し、その回復にも失敗した。</dd>
+<dt>RES_PARERR</dt>
+<dd>パラメータが不正。</dd>
+<dt>RES_NOTRDY</dt>
+<dd>ドライブが動作可能状態ではない(初期化されていない)。</dd>
+</dl>
+</div>
+
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 48 - 0
app/FatFS/doc/ja/dstat.html

@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/dstat.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - disk_status</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>disk_status</h2>
+<p>ディスク・ドライブの状態を取得します。</p>
+<pre>
+DSTATUS disk_status (
+  BYTE <em>Drive</em>           <span class="c">/* 物理ドライブ番号 */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>ステータスを取得する物理ドライブ番号を指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>物理ドライブの状態が次のフラグの組み合わせの値で返されます。</p>
+<dl class="ret">
+<dt>STA_NOINIT</dt>
+<dd>ドライブが初期化されていないことを示すフラグ。システム・リセットやメディアの取り外し等でセットされ、disk_initialize() の正常終了でクリア、失敗でセットされます。</dd>
+<dt>STA_NODISK</dt>
+<dd>メディアがセットされていないことを示すフラグ。メディアが取り外されている間はセットされ、メディアがセットされている間はクリアされます。固定ディスクでは常にクリアされています。</dd>
+<dt>STA_PROTECTED</dt>
+<dd>メディアがライト・プロテクトされていることを示すフラグ。ライト・プロテクト機能をサポートしないメディアでは常にクリアされています。</dd>
+</dl>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 67 - 0
app/FatFS/doc/ja/dwrite.html

@@ -0,0 +1,67 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/dwrite.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - disk_write</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>disk_write</h2>
+<p>ディスクにデータを書き込みます。</p>
+<pre>
+DRESULT disk_write (
+  BYTE <em>Drive</em>,          <span class="c">/* 物理ドライブ番号 */</span>
+  const BYTE* <em>Buffer</em>,  <span class="c">/* 書き込むデータへのポインタ */</span>
+  DWORD <em>SectorNumber</em>,  <span class="c">/* 書き込み開始セクタ番号 */</span>
+  BYTE <em>SectorCount</em>     <span class="c">/* 書き込みセクタ数 */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>物理ドライブ番号(0-9)を指定します。</dd>
+<dt>Buffer</dt>
+<dd>ディスクに書き込む<em>バイト配列</em>を指定します。指定されるアドレスはワード・アライメントされているとは限りません。</dd>
+<dt>SectorNumber</dt>
+<dd>書き込みを開始するセクタ番号。LBAで指定します。</dd>
+<dt>SectorCount</dt>
+<dd>書き込むセクタ数。 1~128で指定します。一般的に、複数セクタの転送要求はデバイスに対して可能な限りマルチ・セクタ転送しなければなりません。複数のシングル・セクタ転送に分解した場合、書き込み速度は極端に低下します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<dl class="ret">
+<dt>RES_OK (0)</dt>
+<dd>正常終了。</dd>
+<dt>RES_ERROR</dt>
+<dd>書き込み中にエラーが発生し、その回復にも失敗した。</dd>
+<dt>RES_WRPRT</dt>
+<dd>メディアが書き込み禁止状態。</dd>
+<dt>RES_PARERR</dt>
+<dd>パラメータが不正。</dd>
+<dt>RES_NOTRDY</dt>
+<dd>ドライブが動作可能状態ではない(初期化されていない)。</dd>
+</dl>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>リード・オンリー構成ではこの関数は必要とされません。</p>
+</div>
+
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 62 - 0
app/FatFS/doc/ja/eof.html

@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/eof.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_eof</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_eof</h2>
+<p>リード/ライト・ポインタがファイル終端に達しているかどうか調べます。.</p>
+<pre>
+int f_eof (
+  FIL* <em>FileObject</em>   <span class="c">/* ファイル・オブジェクト */</span>
+);
+</pre>
+</div>
+
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>リード/ライト・ポインタがファイル終端にあり読み出すデータがない場合は、0以外の値を返します。それ以外の時は0を返します。</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>f_eof関数は、現リビジョンではマクロとして実装されています。</p>
+<pre>
+<span class="k">#define</span> f_eof(fp) (((fp)->fptr) == ((fp)->fsize) ? 1 : 0)
+</pre>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p>常に使用可能。</p>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 62 - 0
app/FatFS/doc/ja/error.html

@@ -0,0 +1,62 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/error.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_error</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_error</h2>
+<p>エラー発生の有無を調べます。</p>
+<pre>
+int f_error (
+  FIL* <em>FileObject</em>   <span class="c">/* ファイル・オブジェクト */</span>
+);
+</pre>
+</div>
+
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>ファイル操作中のエラーで処理が中断されている場合は、0以外の値を返します。それ以外の時は0を返します。</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>f_error関数は、現リビジョンではマクロとして実装されています。</p>
+<pre>
+<span class="k">#define</span> f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
+</pre>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p>常に使用可能。</p>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 51 - 0
app/FatFS/doc/ja/fattime.html

@@ -0,0 +1,51 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/fattime.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - get_fattime</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>get_fattime</h2>
+<p>現在時刻を取得します。</p>
+<pre>
+DWORD get_fattime (void);
+</pre>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>現在のローカル・タイムが<tt>DWORD</tt>値にパックされて返されます。ビット・フィールドは次に示すようになります。</p>
+<dl>
+<dt>bit31:25</dt>
+<dd>1980年を起点とした年が 0..127 で入ります。</dd>
+<dt>bit24:21</dt>
+<dd>月が 1..12 の値で入ります。</dd>
+<dt>bit20:16</dt>
+<dd>日が 1..31 の値で入ります。</dd>
+<dt>bit15:11</dt>
+<dd>時が 0..23 の値で入ります。</dd>
+<dt>bit10:5</dt>
+<dd>分が 0..59 の値で入ります。</dd>
+<dt>bit4:0</dt>
+<dd>秒/2が 0..29 の値で入ります。</dd>
+</dl>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>RTCをサポートしないシステムでも、何らかの日付として有効な値を返さなければなりません。0を返した場合、そのファイルは日付を持ちません。リード・オンリー構成ではこの関数は必要とされません。</p>
+</div>
+
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 97 - 0
app/FatFS/doc/ja/fdisk.html

@@ -0,0 +1,97 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/fdisk.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_fdisk</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_fdisk</h2>
+<p>物理ドライブを分割します。</p>
+<pre>
+FRESULT f_fdisk (
+  BYTE  <em>Drive</em>,              <span class="c">/* 物理ドライブ番号 */</span>
+  const DWORD <em>Partitions[]</em>, <span class="c">/* 区画マップ・テーブル */</span>
+  void* <em>Work</em>                <span class="c">/* ワークエリア */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>分割する<em>物理ドライブ</em>を指定します。</dd>
+<dt>Partitions[]</dt>
+<dd>区画マップ・テーブルへのポインタを指定します。</dd>
+<dt>Work</dt>
+<dd>ワークエリアへのポインタを指定します。サイズは<tt>_MAX_SS</tt>バイト必要です。</dd>
+</dl>
+</div>
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#ip">FR_INVALID_PARAMETER</a>
+</p>
+</div>
+
+<div class="para desc">
+<h4>説明</h4>
+<p>f_fdisk関数は、指定された物理ドライブのMBRに区画テーブルを作成します。区画分けは一般的なFDISK形式で行うため、最大4つの基本区画を作成することができます。拡張区画には対応していません。区画マップテーブル Partitions[] にはドライブをどのように分割するか指定して渡します。この配列は4つの項目から成り、先頭の項目が1番目の、最後の項目が4番目の区画のサイズを示します。値が100以下の場合、ドライブの総容量に対する割合をパーセント単位で指定します。100を超える値の場合はセクタ数の直接指定になります。</p>
+</div>
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_FS_READOLNY == 0</tt> で <tt>_USE_MKFS == 1</tt> で <tt>_MULTI_PARTITION == 2</tt> のとき使用可能です。</p>
+</div>
+
+<div class="para use">
+<h4>使用例</h4>
+<pre>
+    <span class="c">/* ユーザ定義のボリューム管理テーブル (_MULTI_PARTITION != 0 のとき必要) */</span>
+
+    PARTITION VolToPart[] = {
+        {0, 1},    <span class="c">/* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */</span>
+        {0, 2},    <span class="c">/* 論理ドライブ 1 ==> 物理ドライブ 0, 第2区画 */</span>
+        {1, 0}     <span class="c">/* 論理ドライブ 2 ==> 物理ドライブ 1, 自動検出 */</span>
+    };
+</pre>
+<pre>
+    <span class="c">/* 新しい物理ドライブ(0)の初期化 */</span>
+
+    FATFS Fatfs;
+    DWORD plist[] = {50, 50, 0, 0};  <span class="c">/* 2分割 */</span>
+    BYTE work[_MAX_SS];
+
+    f_fdisk(0, plist, work);  <span class="c">/* 物理ドライブ 0 の分割 */</span>
+
+    f_mount(0, &amp;Fatfs);
+    f_mkfs(0, 0, 0);          <span class="c">/* 論理ドライブ 0 の初期化. 第二引数は無視される.  */</span>
+    f_mount(0, 0);
+
+    f_mount(1, &amp;Fatfs);
+    f_mkfs(1, 0, 0);
+    f_mount(1, 0);
+
+</pre>
+</div>
+
+<div class="para ref">
+<h4>See Also</h4>
+<p><tt><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html">f_mkfs</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">Return</a></p>
+</body>
+</html>

+ 71 - 0
app/FatFS/doc/ja/filename.html

@@ -0,0 +1,71 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/filename.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - パス名のフォーマット</title>
+</head>
+
+<body>
+<h1>パス名のフォーマット</h1>
+<div class="para" id="nam">
+<h3>ファイル・ディレクトリ名</h3>
+<p>FatFsモジュールでのファイル、ディレクトリ、ドライブの指定方法はDOS/Windows APIとほぼ同じです。パス名のフォーマットは次の通りです。</p>
+<p><tt>"[論理ドライブ番号:][/]ディレクトリ名/ファイル名"</tt></p>
+<p>FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、<tt>(_USE_LFN &gt; 0)</tt>のとき使用可能になります。ディレクトリ・セパレータにはDOS/Windows APIと同じく / と \ を使用します。連続したセパレータは無視され1個として扱われます。唯一の違いは、論理ドライブの指定だけです。論理ドライブ番号は、'0'~'9'の一文字の数字とコロンで指定し、省略した場合はデフォルト・ドライブ(0またはカレント・ドライブ)が選択されます。</p>
+<p>Nul文字と制御文字(\0~\x1F)は、パス名の終端として認識されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではスペースはパス名の終端として認識されます。</p>
+<p>標準構成<tt>(_FS_RPATH == 0)</tt>のときは、全てのオブジェクトがルート・ディレクトリから辿る絶対パスで指定されます。OS指向なカレント・ディレクトリという概念は無く、またドット・ディレクトリ(&quot;.&quot;や&quot;..&quot;)は使用できません。パス名先頭のセパレータは無視されます。デフォルト・ドライブ番号は常に0になります。</p>
+<p>相対パスを有効<tt>(_FS_RPATH == 1)</tt>にしたときは、先行するセパレータの有無によって検索開始ディレクトリが変わり、セパレータがある場合はルート・ディレクトリから、無い場合は<a href="chdir.html">f_chdir関数</a>で設定されるカレント・ディレクトリからになります。またパス名にドット・ディレクトリが使用できます。デフォルト・ドライブ番号は<a href="chdrive.html">f_chdrive関数</a>で設定された値となります。</p>
+<table class="lst2">
+<tr><td>パス名</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr>
+<tr class="lst3"><td>file.txt</td><td>ドライブ0のルート・ディレクトリ下のファイル</td><td>カレント・ドライブのカレント・ディレクトリ下のファイル</td></tr>
+<tr><td>/file.txt</td><td>ドライブ0のルート・ディレクトリ下のファイル</td><td>カレント・ドライブのルート・ディレクトリ下のファイル</td></tr>
+<tr><td></td><td>ドライブ0のルート・ディレクトリ</td><td>カレント・ドライブのカレント・ディレクトリ</td></tr>
+<tr><td>2:</td><td>ドライブ2のルート・ディレクトリ</td><td>ドライブ2のカレント・ディレクトリ</td></tr>
+<tr><td>2:file1.txt</td><td>ドライブ2のルート・ディレクトリ下のファイル</td><td>ドライブ2のカレント・ディレクトリ下のファイル</td></tr>
+<tr><td>2:/</td><td>ドライブ2のルート・ディレクトリ</td><td>ドライブ2のルート・ディレクトリ</td></tr>
+<tr><td>../file.txt</td><td>無効</td><td>親ディレクトリ下のファイル</td></tr>
+<tr><td>.</td><td>無効</td><td>このディレクトリ</td></tr>
+<tr><td>..</td><td>無効</td><td>カレント・ディレクトリの親ディレクトリ</td></tr>
+<tr><td>dir1/..</td><td>無効</td><td>カレント・ディレクトリ</td></tr>
+<tr><td>/..</td><td>無効</td><td>ルート・ディレクトリ(その上は辿れない)</td></tr>
+</table>
+</div>
+
+<p><br></p>
+<div class="para" id="uni">
+<h3>Unicode API</h3>
+<p>ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、<tt>TCHAR</tt>で定義されていますが、これは<tt>char</tt>のエリアスになっています。そして、<tt>_CODE_PAGE</tt>で指定される ANSI/OEMコード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(LFN構成で、かつ<tt>_LFN_UNICODE</tt>を 1)にしたときは、<tt>TCHAR</tt>はワイド文字(<tt>unsigned short</tt>)に切り替わり、パス名にUnicodeを使用するようになります。これにより LFNフル対応となり、ANSI/OEMコードにない文字(たとえば ✝☪✡☸☭など)も使用できます。この設定は文字列入出力関数のデータ型とエンコーディングにも影響を与えます。リテラル文字列を定義するとき、次に示すように<tt>_T(s)</tt>および<tt>_TEXT(s)</tt>マクロを使ってANSI/OEMとUnicodeを自動切り替えすることができます。</p>
+<pre>
+ f_open(fp, "filename.txt", FA_READ);      <span class="c">/* ANSI/OEM専用コード */</span>
+ f_open(fp, L"filename.txt", FA_READ);     <span class="c">/* Unicode専用コード */</span>
+ f_open(fp, _T("filename.txt"), FA_READ);  <span class="c">/* 両用コード */</span>
+</pre>
+</div>
+
+<p><br></p>
+<div class="para" id="vol">
+<h3>論理ドライブ(ボリューム)と物理ドライブ(ディスク装置)の対応</h3>
+<p>デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、SFDとしてまたは第1区画のボリュームがマウントされます。<tt>_MULTI_PARTITION</tt>に 1以上を指定すると、個々の論理ドライブに対して個別に物理ドライブ番号・区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p>
+<pre>
+例:論理ドライブ0~2を物理ドライブ0(固定ディスク)の3つの基本区画に割り当て、
+   論理ドライブ3を物理ドライブ1(リムーバブル・ディスク)に割り当てる場合。
+
+PARTITION VolToPart[] = {
+    {0, 1},     <span class="c">/* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */</span>
+    {0, 2},     <span class="c">/* 論理ドライブ 1 ==> 物理ドライブ 0, 第2区画 */</span>
+    {0, 3},     <span class="c">/* 論理ドライブ 2 ==> 物理ドライブ 0, 第3区画 */</span>
+    {1, 0}      <span class="c">/* 論理ドライブ 3 ==> 物理ドライブ 1, 自動検出 */</span>
+};
+</pre>
+<p>複数区画指定を使用する場合、次の点に注意しなければなりません。
+<ul>
+<li>マウント可能な区画は基本区画のみで、拡張区画内には対応しない。</li>
+<li>複数の区画を持つ物理ドライブは、非リムーバブルでなければならない。</li>
+</ul>
+
+</body>
+</html>

+ 140 - 0
app/FatFS/doc/ja/forward.html

@@ -0,0 +1,140 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/forward.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_forward</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_forward</h2>
+<p>ファイルからデータを読み出し、送信ストリームに直接転送します。</p>
+<pre>
+FRESULT f_forward (
+  FIL* <em>FileObject</em>,                 <span class="c">/* ファイル・オブジェクト構造体 */</span>
+  UINT (*<em>Func</em>)(const BYTE*,UINT),  <span class="c">/* データ転送関数 */</span>
+  UINT <em>ByteToFwd</em>,                  <span class="c">/* 転送するバイト数 */</span>
+  UINT* <em>ByteFwd</em>                    <span class="c">/* 転送されたバイト数 */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
+<dt>Func</dt>
+<dd>データを渡すユーザ定義関数へのポインタを指定します。この関数の仕様はサンプルを参照してください。</dd>
+<dt>ByteToRead</dt>
+<dd>転送するバイト数(0~UINTの最大値)を指定します。</dd>
+<dt>ByteRead</dt>
+<dd>実際に転送されたバイト数を格納する変数を指すポインタを指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#de">FR_DENIED</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>ファイルのデータをバッファに読み出さずに送信ストリームに直接転送します。アプリケーション側でデータ・バッファを必要としないので、メモリの限られた環境で有効です。リード/ライト・ポインタは転送されたバイト数だけ進みます。指定されたバイト数の転送中にファイルの終端に達した場合や送信ストリームがビジーになった場合、<tt>*ByteFwd</tt>は<tt>ByteToFwd</tt>よりも小さくなります。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_USE_FORWARD == 1</tt>で、且つ<tt>_FS_TINY == 1</tt>のときに使用可能です。</p>
+</div>
+
+
+<div class="para use">
+<h4>使用例(オーディオ再生)</h4>
+<pre>
+<span class="c">/*-----------------------------------------------------------------------*/</span>
+<span class="c">/* f_forward関数から呼ばれるデータ送信関数の例                           */</span>
+<span class="c">/*-----------------------------------------------------------------------*/</span>
+
+UINT out_stream (   <span class="c">/* 戻り値: 転送されたバイト数またはストリームの状態 */</span>
+    const BYTE *p,  <span class="c">/* 転送するデータを指すポインタ */</span>
+    UINT btf        <span class="c">/* &gt;0: 転送を行う(バイト数). 0: ストリームの状態を調べる */</span>
+)
+{
+    UINT cnt = 0;
+
+
+    if (btf == 0) {     <span class="c">/* センス要求 */</span>
+        <span class="c">/* ストリームの状態を返す (0: ビジー, 1: レディ) */</span>
+        <span class="c">/* 一旦、レディを返したら、続く転送要求で少なくとも1バイトは */</span>
+        <span class="c">/* 転送されないと f_forward関数は FR_INT_ERR となる。 */</span>
+        if (FIFO_READY) cnt = 1;
+    }
+    else {              <span class="c">/* 転送要求 */</span>
+        do {    <span class="c">/* 全てのバイトを転送するか、ストリームがビジーになるまで繰り返す */</span>
+            FIFO_PORT = *p++;
+            cnt++;
+        } while (cnt &lt; btf &amp;&amp; FIFO_READY);
+    }
+
+    return cnt;
+}
+
+
+<span class="c">/*-----------------------------------------------------------------------*/</span>
+<span class="c">/* f_forward関数の使用例                                                 */</span>
+<span class="c">/*-----------------------------------------------------------------------*/</span>
+
+FRESULT play_file (
+    char *fn        <span class="c">/* 再生するオーディオ・ファイル名を指すポインタ */</span>
+)
+{
+    FRESULT rc;
+    FIL fil;
+    UINT dmy;
+
+    <span class="c">/* ファイルを読み出しモードで開く */</span>
+    rc = f_open(&amp;fil, fn, FA_READ);
+    if (rc) return rc;
+
+    <span class="c">/* 全てのデータが転送されるかエラーが発生するまで続ける */</span>
+    while (rc == FR_OK &amp;&amp; fil.fptr &lt; fil.fsize) {
+
+        <span class="c">/* ほかの処理... */</span>
+
+        <span class="c">/* 定期的または要求に応じてデータをストリームに送出する */</span>
+        rc = f_forward(&amp;fil, out_stream, 1000, &amp;dmy);
+    }
+
+    <span class="c">/* ファイルを閉じて戻る */</span>
+    f_close(&amp;fil);
+    return rc;
+}
+</pre>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="gets.html">fgets</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 70 - 0
app/FatFS/doc/ja/getcwd.html

@@ -0,0 +1,70 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/getcwd.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_getcwd</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_getcwd</h2>
+<p>カレント・ディレクトリを得ます</p>
+<pre>
+FRESULT f_getcwd (
+  TCHAR* <em>Buffer</em>,  <span class="c">/* バッファ */</span>
+  UINT <em>BufferLen</em>  <span class="c">/* バッファ・サイズ */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Buffer</dt>
+<dd>カレント・ディレクトリの文字列を格納するバッファ</dd>
+<dt>BufferLen</dt>
+<dd>TCHAR単位のバッファ・サイズ</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>f_getcwd関数は、カレント・ドライブのカレント・ディレクトリのパス文字列を取得します。パス文字列は、ドライブ番号を含んだフル・パス名です。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_FS_RPATH == 2</tt>のとき使用可能です。</p>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="chdrive.html">f_chdrive</a>, <a href="chdir.html">f_chdir</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 96 - 0
app/FatFS/doc/ja/getfree.html

@@ -0,0 +1,96 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/getfree.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_getfree</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_getfree</h2>
+<p>論理ドライブ上の未使用クラスタ数を得ます。</p>
+<pre>
+FRESULT f_getfree (
+  const TCHAR* <em>Path</em>,       <span class="c">/* 対象ドライブを指定します */</span>
+  DWORD* <em>Clusters</em>,         <span class="c">/* 空きクラスタ数を格納する変数へのポインタ */</span>
+  FATFS** <em>FileSystemObject</em> <span class="c">/* ファイル・システム・オブジェクトを指すポインタへのポインタ */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Path</dt>
+<dd>調べる対象の論理ドライブを示す<a href="filename.html">パス名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
+<dt>Clusters</dt>
+<dd>空きクラスタ数を格納する<tt>DWORD</tt>変数へのポインタを指定します。</dd>
+<dt>FileSystemObject</dt>
+<dd>対象ドライブのファイル・システム・オブジェクトを指すポインタが返されます。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>論理ドライブ上の空きクラスタ数を取得します。返されたファイル・システム・オブジェクトの<tt>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。FAT32ボリュームにおいては、FSINFOセクタの状態によっては不正確な値を返したり、処理に時間がかかったりする可能性があります。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のとき使用可能です。</p>
+</div>
+
+
+<div class="para use">
+<h4>使用例</h4>
+<pre>
+    FATFS *fs;
+    DWORD fre_clust, fre_sect, tot_sect;
+
+
+    <span class="c">/* ドライブ1のボリューム情報と空きクラスタ数を得る */</span>
+    res = f_getfree("1:", &amp;fre_clust, &amp;fs);
+    if (res) die(res);
+
+    <span class="c">/* 全セクタ数と空きセクタ数を計算 */</span>
+    tot_sect = (fs->n_fatent - 2) * fs->csize;
+    fre_sect = fre_clust * fs->csize;
+
+    <span class="c">/* ドライブサイズと空きサイズの表示 (512バイト/セクタと仮定) */</span>
+    printf("%lu KB total drive space.\n"
+           "%lu KB available.\n",
+           fre_sect / 2, tot_sect / 2);
+</pre>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<tt><a href="sfatfs.html">FATFS</a></tt>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 65 - 0
app/FatFS/doc/ja/gets.html

@@ -0,0 +1,65 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/gets.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_gets</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_gets</h2>
+<p>ファイルから文字列を読み出します。</p>
+<pre>
+TCHAR* f_gets (
+  TCHAR* <em>Str</em>,       <span class="c">/* バッファ */</span>
+  int <em>Size</em>,         <span class="c">/* バッファのサイズ */</span>
+  FIL* <em>FileObject</em>   <span class="c">/* ファイル・オブジェクト */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Str</dt>
+<dd>文字列を読み出すバッファを指すポインタを指定します。</dd>
+<dt>Size</dt>
+<dd>バッファのサイズを要素数で指定します。</dd>
+<dt>FileObject</dt>
+<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>関数が成功すると<tt>Str</tt>が返されます。</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>この関数は<a href="read.html">f_read()</a>のラッパー関数です。読み出し動作は、最初の<tt>'\n'</tt>を読み込むか、ファイル終端に達するか、<tt>Size - 1</tt>文字を読み出すまで続きます。読み込まれた文字列の終端には<tt>'\0'</tt>が付加されます。既にファイル終端で1文字も読み込まれなかったとき、または何らかのエラーが発生したときは関数は失敗しヌル・ポインタを返します。ファイル終端かエラーかは<tt>f_eof()</tt>,<tt>f_error()</tt>マクロで調べられます。</p>
+<p>APIにUnicodeが選択されている(<tt>_LFN_UNICODE</tt>が1)ときは、UTF-8エンコードのテキスト・ファイルとしてUCS-2に変換してバッファに読み込みます。それ以外の時は無変換(1文字1バイト)で読み込みます。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_USE_STRFUNC</tt>が 1または 2のとき使用可能です。2のときは、ファイルに含まれる<tt>'\r'</tt>が取り除かれてバッファに読み込まれます。</p>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 130 - 0
app/FatFS/doc/ja/lseek.html

@@ -0,0 +1,130 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/lseek.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_lseek</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_lseek</h2>
+<p>ファイルのリード/ライト・ポインタを移動します。また、高速シーク機能使用時にはCLMT(後述)の作成にも使用します。</p>
+<pre>
+FRESULT f_lseek (
+  FIL* <em>FileObject</em>,    <span class="c">/* ファイル・オブジェクト構造体へのポインタ */</span>
+  DWORD <em>Offset</em>        <span class="c">/* 移動先オフセット */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>対象となるファイル・オブジェクト構造体へのポインタを指定します。</dd>
+<dt>Offset</dt>
+<dd>移動先のオフセット(リード/ライト・ポインタ)値。ファイル先頭からのオフセットをバイト単位で指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#io">FR_INVALID_OBJECT</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>ファイルのリード/ライト・ポインタ(次に読み出し・書き込みされるバイトのオフセット)を移動します。オフセットの原点はファイル先頭です。書き込みモードでファイル・サイズより大きな値を指定すると、そこまでファイル・サイズが拡張され、拡張された部分のデータは未定義となります。データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイル・サイズを拡張しておくと良いでしょう。f_lseek関数が正常終了したあとは、リード/ライト・ポインタが正しく移動したかチェックするべきです。リード/ライト・ポインタが指定より小さいときは、次の原因が考えられます。</p>
+<ul>
+<li>非書き込みモードまたは高速シーク・モードのため、ファイル・サイズでクリップされた。</li>
+<li>ファイル拡張中にディスクが満杯になった。</li>
+</ul>
+<p><tt>_USE_FASTSEEK</tt>に1が指定されていて、且つファイル・オブジェクトの<tt>cltbl</tt>メンバがNULL以外(ファイルを開いたときはNULL)のとき、高速シーク・モードになります。これはファイルのクラスタ配置情報(CLMT)をメモリ上に保持しておくことにより、FATにアクセスすることなく後方シークやロング・シークを高速に行う機能です。高速シーク・モードは、f_read/f_wtite関数にも適用されます。高速シーク・モードではf_wtite/f_lseek関数によるファイル・サイズの拡張はできません。</p>
+<p>高速シーク動作を行う前に、CLMTを作成しておく必要があります。これを作成するには、まず<tt>cltbl</tt>メンバにCLMT格納バッファ(DWORD配列)へのポインタをセットします。そして、配列の先頭要素にその配列の要素数を入れ、f_lseek関数を<tt>Offset</tt>に<tt>CREATE_LINKMAP</tt>を指定して実行します。関数が成功するとCLMTが作成され、以降のf_read/f_write/f_lseek関数ではFATへのアクセスは発生しません。<tt>FR_NOT_ENOUGH_CORE</tt>で失敗したときは配列サイズが不足で、先頭要素には実際に必要となる要素数が返されます。必要な要素数は、(ファイルの分割数 + 1) * 2 です。たとえば、ファイルが5つに分断されているときに必要な要素数は、12となります。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_FS_MINIMIZE &lt; 3</tt>のとき使用可能です。</p>
+</div>
+
+
+<div class="para use">
+<h4>使用例</h4>
+<pre>
+    <span class="c">/* ファイルを開く */</span>
+    file = malloc(sizeof(FIL));
+    if (!file) ...
+    res = f_open(file, "file.dat", FA_READ|FA_WRITE);
+    if (res) ...
+
+    <span class="c">/* ファイル・オフセット5000へ移動 */</span>
+    res = f_lseek(file, 5000);
+
+    <span class="c">/* ファイル終端へ移動(ファイル追記の準備) */</span>
+    res = f_lseek(file, f_size(file));
+
+    <span class="c">/* 3000バイト進める */</span>
+    res = f_lseek(file, f_tell(file) + 3000);
+
+    <span class="c">/* 2000バイト戻す (オーバーフローに注意) */</span>
+    res = f_lseek(file, f_tell(file) - 2000);
+</pre>
+<pre>
+    <span class="c">/* クラスタ先行割り当て (ストリーミング・ライト時のバッファ・オーバーラン防止) */</span>
+
+    res = f_open(file, "record.wav", FA_CREATE_NEW | FA_WRITE);  <span class="c">/* ファイル作成 */</span>
+
+    res = f_lseek(file, MAX_SIZE);           <span class="c">/* 十分なクラスタの先行割り当て */</span>
+    if (res || f_tell(file) != PRE_SIZE) ... <span class="c">/* 正しくファイルが拡張されたかチェック */</span>
+
+    res = f_lseek(file, DATA_START);         <span class="c">/* データ・ストリームの記録(アロケーションディレイ無し) */</span>
+    ...
+
+    res = f_truncate(file);                  <span class="c">/* 不要領域の切り捨て */</span>
+    res = f_lseek(file, 0);                  <span class="c">/* ヘッダの記録 */</span>
+    ...
+
+    res = f_close(file);
+</pre>
+<pre>
+    <span class="c">/* 高速シーク機能を使う */</span>
+
+    DWORD lktbl[SZ_TBL];                   <span class="c">/* リンク・マップ・テーブル格納バッファ */</span>
+
+    res = f_lseek(file, ofs1);             <span class="c">/* 通常シーク (オープン時、file.cltbl == NULL) */</span>
+
+    file.cltbl = lktbl;                    <span class="c">/* 高速シーク機能の有効化 */</span>
+    lktbl[0] = SZ_TBL;                     <span class="c">/* 先頭要素に配列要素数をセット */</span>
+    res = f_lseek(file, CREATE_LINKMAP);   <span class="c">/* CLMTの作成 */</span>
+    ...
+
+    res = f_lseek(file, ofs2);             <span class="c">/* 以降、f_read/f_write/f_lseekでFATアクセスが発生しない */</span>
+</pre>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 80 - 0
app/FatFS/doc/ja/mkdir.html

@@ -0,0 +1,80 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/mkdir.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_mkdir</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_mkdir</h2>
+<p>ディレクトリを作成します。</p>
+<pre>
+FRESULT f_mkdir (
+  const TCHAR* <em>DirName</em> <span class="c">/* 作成するディレクトリ名へのポインタ */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>DirName</dt>
+<dd>作成するディレクトリの<a href="filename.html">パス名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#de">FR_DENIED</a>,
+<a href="rc.html#ex">FR_EXIST</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>空のディレクトリを作成します。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のとき使用可能です。</p>
+</div>
+
+
+<div class="para use">
+<h4>使用例</h4>
+<pre>
+    res = f_mkdir("sub1");
+    if (res) die(res);
+    res = f_mkdir("sub1/sub2");
+    if (res) die(res);
+    res = f_mkdir("sub1/sub2/sub3");
+    if (res) die(res);
+</pre>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 73 - 0
app/FatFS/doc/ja/mkfs.html

@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/mkfs.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_mkfs</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_mkfs</h2>
+<p>論理ドライブ上にFATボリュームを作成(フォーマット)します。</p>
+<pre>
+FRESULT f_mkfs (
+  BYTE  <em>Drive</em>,              <span class="c">/* 論理ドライブ番号 */</span>
+  BYTE  <em>PartitioningRule</em>,   <span class="c">/* 区画作成方法 */</span>
+  UINT  <em>AllocSize</em>           <span class="c">/* クラス・タサイズ */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>フォーマットする論理ドライブ(0-9)。</dd>
+<dt>PartitioningRule</dt>
+<dd>パーテーション形式(0(FDISK) または1(SFD))を指定します。</dd>
+<dt>AllocSize</dt>
+<dd>クラスタ・サイズをバイト単位で指定します。2の累乗、且つセクタ・サイズ以上、且つセクタ・サイズの128倍以下でなければなりません。0を指定した場合、ボリュームのサイズに応じたデフォルトのクラスタ・サイズが選択されます。</dd>
+</dl>
+</div>
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ma">FR_MKFS_ABORTED</a>,
+<a href="rc.html#ip">FR_INVALID_PARAMETER</a>
+</p>
+</div>
+
+<div class="para desc">
+<h4>説明</h4>
+<p>f_mkfs関数は物理ドライブ上にFATボリュームを作成します。第二引数でFDISK形式が指定された場合は、物理ドライブ全体を占める基本区画(パーテーション)が作成され、その中にFATボリュームが作成されます。SFD形式では、FATボリュームは物理ドライブの先頭からベタで作成されます。</p>
+<p>マルチパーテーション機能<tt>(_MULTI_PARTITION)</tt>により、指定された論理ドライブが特定の区画(1~4)に結び付けられている場合、その区画の中にFATボリュームが作成されます。この場合、第二引数は無視され、また対応する物理ドライブはこれに先立ち、f_fdisk関数または他のツールで適切に区画設定されている必要があります。</p>
+<p>パーテーション形式には、FDISK形式とSFD形式の二通りありがあります。FDISK形式は、ハードディスク、MMC、SDC、CFCなどで使用されます。FDISK形式では一台の物理ドライブ上に一つまたは複数の区画を作成することができます。管理情報はMBR(物理ドライブの先頭セクタ)に記録されます。SFD形式は単に何の分割も行わない形式で、ボリュームは物理ドライブの先頭セクタから開始します。SFD形式は、フロッピーディスク、マイクロドライブ、光学ディスク、およびその他スーパーフロッピーメディアで使用されています。</p>
+<p>FATタイプ(FAT12/FAT16/FAT32)は、その論理ドライブ上の<em>クラスタ数によってのみ決定</em>される決まり[FAT仕様書より]になっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはドライブ・サイズとクラスタ・サイズに依存します。クラスタ・サイズは大きくするほど性能が上がり、ディスク利用効率は落ちます。</p>
+<p>クラスタ数がFATタイプの境界に近くなるときは、FR_MKFS_ABORTEDで関数が失敗する可能性があります。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_MKFS == 1</tt>のとき使用可能です。</p>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="filename.html#vol">ボリューム管理</a>, <a href="fdisk.html">f_fdisk</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 64 - 0
app/FatFS/doc/ja/mount.html

@@ -0,0 +1,64 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/mount.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_mount</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_mount</h2>
+<p>論理ドライブのワーク・エリアを登録・抹消します。</p>
+<pre>
+FRESULT f_mount (
+  BYTE  <em>Drive</em>,               <span class="c">/* 論理ドライブ番号 */</span>
+  FATFS*  <em>FileSystemObject</em>   <span class="c">/* ワーク・エリアへのポインタ */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>Drive</dt>
+<dd>論理ドライブ番号(0-9)。</dd>
+<dt>FileSystemObject</dt>
+<dd>登録するワーク・エリア(ファイル・システム・オブジェクト)へのポインタ。</dd>
+</dl>
+</div>
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>FatFsモジュールではそれぞれの論理ドライブにファイル・システム・オブジェクトというワーク・エリアが必要です。この関数は論理ドライブにそのワーク・エリアを登録したり抹消したりします。何らかのファイル関数を使用する前にこの関数でその論理ドライブのワーク・エリアを与えておかなければなりません。<tt>FileSystemObject</tt>にヌル・ポインタを指定するとその論理ドライブのワーク・エリアの登録は抹消され、登録されていたワーク・エリアは破棄できます。操作対象のドライブに対して開かれているファイルやディレクトリがあった場合、それらは全て無効になります。</p>
+<p>この関数は、ドライブの状態に関わらず常に成功します。関数内では下位レイヤ(物理ドライブ)へのアクセスは発生せず、ワーク・エリアを初期化して内部配列にそのアドレスを登録するだけです。実際のマウント動作は、この関数の実行またはメディア交換発生の後、最初のファイル・アクセスのときに行われます。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p>全ての構成で使用可能です。</p>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 137 - 0
app/FatFS/doc/ja/open.html

@@ -0,0 +1,137 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/open.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_open</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_open</h2>
+<p>ファイルをオープンまたは作成します。</p>
+<pre>
+FRESULT f_open (
+  FIL* <em>FileObject</em>,       <span class="c">/* 空のファイル・オブジェクト構造体へのポインタ */</span>
+  const TCHAR* <em>FileName</em>, <span class="c">/* ファイルのフルパス名へのポインタ */</span>
+  BYTE <em>ModeFlags</em>         <span class="c">/* モードフラグ */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>FileObject</dt>
+<dd>新しく作成するファイル・オブジェクト構造体へのポインタを指定します。以降、そのファイルを閉じるまでこのファイル・オブジェクトを使用してファイル操作をします。</dd>
+<dt>FileName</dt>
+<dd>開く(または作成する)ファイルの <a href="filename.html">ファイル名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
+<dt>ModeFlags</dt>
+<dd>ファイルのアクセス方法やオープン方法を決めるフラグです。このパラメータには次の組み合わせを指定します。<br>
+<table class="lst">
+<tr><th>値</th><th>意味</th></tr>
+<tr><td>FA_READ</td><td>読み出しモードで開きます。読み書きする場合は<tt>FA_WRITE</tt>と共に指定します。</td></tr>
+<tr><td>FA_WRITE</td><td>書き込みモードで開きます。読み書きする場合は<tt>FA_READ</tt>と共に指定します。</td></tr>
+<tr><td>FA_OPEN_EXISTING</td><td>既存のファイルを開きます。ファイルが無いときはエラーになります。(デフォルト)</td></tr>
+<tr><td>FA_OPEN_ALWAYS</td><td>既存のファイルを開きます。ファイルが無いときはファイルを作成します。追記の場合は、この方法でオープンした後、<a href="lseek.html">f_lseek()</a>でファイルの最後尾に移動してください。</td></tr>
+<tr><td>FA_CREATE_NEW</td><td>ファイルを作成します。同名のファイルがある場合は、<tt>FR_EXIST</tt>で失敗します。</td></tr>
+<tr><td>FA_CREATE_ALWAYS</td><td>ファイルを作成します。同名のファイルがある場合は、サイズを0にしてから開きます。</td></tr>
+</table>
+</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#ok">FR_NO_FILE</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#de">FR_DENIED</a>,
+<a href="rc.html#ex">FR_EXIST</a>,
+<a href="rc.html#wp">FR_WRITE_PROTECTED</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#lo">FR_LOCKED</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>,
+<a href="rc.html#tf">FR_TOO_MANY_OPEN_FILES</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>既存のファイルを開いたり、新しいファイルを作成します。関数が成功するとファイル・オブジェクトが作成され、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html">f_close()</a>を使用します。何らかの変更が行われたファイルがその後正しく閉じられなかった場合、そのファイルが破損する場合があります。</p>
+<p>もしも既に開かれているファイルを開く必要がある場合は、<a href="appnote.html#dup">多重アクセス制御</a>を参照してください。</p>
+<p>ファイル・アクセスを開始する前に、<a href="mount.html">f_mount()</a>を使ってそれぞれの論理ドライブにワーク・エリア(ファイル・システム・オブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p>全ての構成で使用可能です。<tt>_FS_READONLY == 1</tt>のときは、<tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>の各フラグはサポートされません。</p>
+</div>
+
+
+<div class="para use">
+<h4>使用例(ファイル・コピー)</h4>
+<pre>
+void main (void)
+{
+    FATFS fs[2];         <span class="c">/* 論理ドライブのワーク・エリア(ファイル・システム・オブジェクト) */</span>
+    FIL fsrc, fdst;      <span class="c">/* ファイル・オブジェクト */</span>
+    BYTE buffer[4096];   <span class="c">/* file copy buffer */</span>
+    FRESULT res;         <span class="c">/* FatFs function common result code */</span>
+    UINT br, bw;         <span class="c">/* File R/W count */</span>
+
+    <span class="c">/* ドライブ0,1にワーク・エリアを与える (常に成功する) */</span>
+    f_mount(0, &amp;fs[0]);
+    f_mount(1, &amp;fs[1]);
+
+    <span class="c">/* ドライブ1のソース・ファイルを開く */</span>
+    res = f_open(&amp;fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
+    if (res) die(res);
+
+    <span class="c">/* ドライブ0にデスティネーション・ファイルを作成する */</span>
+    res = f_open(&amp;fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
+    if (res) die(res);
+
+    <span class="c">/* ソースからデスティネーションにコピーする */</span>
+    for (;;) {
+        res = f_read(&amp;fsrc, buffer, sizeof(buffer), &amp;br);
+        if (res || br == 0) break;   <span class="c">/* エラーかファイル終端 */</span>
+        res = f_write(&amp;fdst, buffer, br, &amp;bw);
+        if (res || bw &lt; br) break;   <span class="c">/* エラーかディスク満杯 */</span>
+    }
+
+    <span class="c">/* 全てのファイルを閉じる */</span>
+    f_close(&amp;fsrc);
+    f_close(&amp;fdst);
+
+    <span class="c">/* ワーク・エリアを開放する */</span>
+    f_mount(0, NULL);
+    f_mount(1, NULL);
+}
+</pre>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

+ 73 - 0
app/FatFS/doc/ja/opendir.html

@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="ja">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<link rel="up" title="FatFs" href="../00index_j.html">
+<link rel="alternate" hreflang="en" title="English" href="../en/opendir.html">
+<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
+<title>FatFs - f_opendir</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_opendir</h2>
+<p>ディレクトリを開きます。</p>
+<pre>
+FRESULT f_opendir (
+  DIR* <em>DirObject</em>,       <span class="c">/* ディレクトリ・ブジェクト構造体へのポインタ */</span>
+  const TCHAR* <em>DirName</em>  <span class="c">/* ディレクトリ名へのポインタ */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>引数</h4>
+<dl class="par">
+<dt>DirObject</dt>
+<dd>初期化するディレクトリ・オブジェクト構造体へのポインタを指定します。</dd>
+<dt>DirName</dt>
+<dd>オープンするディレクトリへの<a href="filename.html">パス名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
+</dl>
+</div>
+
+
+<div class="para ret">
+<h4>戻り値</h4>
+<p>
+<a href="rc.html#ok">FR_OK</a>,
+<a href="rc.html#de">FR_DISK_ERR</a>,
+<a href="rc.html#ie">FR_INT_ERR</a>,
+<a href="rc.html#nr">FR_NOT_READY</a>,
+<a href="rc.html#np">FR_NO_PATH</a>,
+<a href="rc.html#in">FR_INVALID_NAME</a>,
+<a href="rc.html#id">FR_INVALID_DRIVE</a>,
+<a href="rc.html#ne">FR_NOT_ENABLED</a>,
+<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
+<a href="rc.html#tm">FR_TIMEOUT</a>,
+<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
+</p>
+</div>
+
+
+<div class="para desc">
+<h4>解説</h4>
+<p>ディレクトリを開きます。正常終了したら、<tt>DirObject</tt>構造体を使ってこのディレクトリの項目を順次読み出せます。<tt>DirObject</tt>構造体は使用後は任意の時点で破棄できます。</p>
+</div>
+
+
+<div class="para comp">
+<h4>対応情報</h4>
+<p><tt>_FS_MINIMIZE &lt;= 1</tt>のとき使用可能になります。</p>
+</div>
+
+
+<div class="para ref">
+<h4>参照</h4>
+<p><tt><a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt></p>
+</div>
+
+<p class="foot"><a href="../00index_j.html">戻る</a></p>
+</body>
+</html>

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott