Jelajahi Sumber

重新构建工程

樊春春 1 tahun lalu
induk
melakukan
0757c6da84
100 mengubah file dengan 7812 tambahan dan 6674 penghapusan
  1. 48 45
      CMakeLists.txt
  2. 1127 0
      Doc/ModBus协议/MODBUS协议整理.htm
  3. TEMPAT SAMPAH
      Doc/ModBus协议/Modbus协议规范(中文详细).pdf
  4. TEMPAT SAMPAH
      Doc/SD卡SDIO规范/SD Card Specification(V1.0).pdf
  5. TEMPAT SAMPAH
      Doc/STM32 CPU 数据手册/STM32F405xx STM32F407xx 数据手册(2012-05 Rev 3).pdf
  6. TEMPAT SAMPAH
      Doc/STM32 CPU 数据手册/STM32F405xx,F407xx, STM32F415xx,F417xx 参考手册(2012-10 Rev 2).pdf
  7. TEMPAT SAMPAH
      Doc/STM32 CPU 数据手册/STM32F40x and STM32F41x 勘误表(2012-08 Rev 3).pdf
  8. TEMPAT SAMPAH
      Doc/STM32 CPU 数据手册/STM32F40xxx、STM32F41xxx、STM32F42xxx、STM32F43xxx参考手册(中文).pdf
  9. TEMPAT SAMPAH
      Doc/STM32 CPU 数据手册/STM32F415xx STM32F417xx 数据手册(2012-05 Rev 3).pdf
  10. 5 0
      Doc/STM32 CPU 数据手册/说明.txt
  11. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【CAN收发芯片】SN65HVD230(VP230).pdf
  12. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【I2S音频CODEC】WM8978(V4.5_2011).pdf
  13. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【I2S音频CODEC】WM8978中文资料.pdf
  14. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【LDO】XC6206.pdf
  15. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【LDO电源】AMS1117.pdf
  16. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【NAND Flash】HY27UF(08_16)1G2A Series(Rev0.4).pdf
  17. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【NOR Flash】S29GL-P_MirrorBit(NOR Flash 中文数据手册).pdf
  18. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【NOR Flash】S29GL128P10TFI01.pdf
  19. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【RJ45网络变压器】HR911105A.pdf
  20. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【RS232接口】SP3232EEN.pdf
  21. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【RS485】SP3485.pdf
  22. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【RS485】SP3485_cn.pdf
  23. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【SRAM】IS61WV102416BLL-10TL.pdf
  24. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【三轴磁力计】HMC5883L.pdf
  25. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【三轴磁力计】HMC5883L中文规格书.pdf
  26. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【三轴磁力计】MAG3110.pdf
  27. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【三轴陀螺仪】MPU-6050_寄存器.pdf
  28. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【三轴陀螺仪】MPU-6050_规格书.pdf
  29. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【串行EEPROM】AT24C128.pdf
  30. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【串行Flash】W25Q64CV(80MHz).pdf
  31. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【串行Flash】W25Q64FV(104MHz).pdf
  32. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【以太网PHY】DM9161C-DS-F01_102611.pdf
  33. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【以太网】DM9000A-P03-042105.pdf
  34. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【光照度传感器】BH1750FVI.pdf
  35. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【地址译码器】SN74LVC139A.pdf
  36. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【基准电压源】TL431.pdf
  37. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【大气压力传感器】BMP085.pdf
  38. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【大气压力传感器】BMP180.pdf
  39. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【开关电源芯片】XL1509.pdf
  40. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【收音机】Si4730-D60.pdf
  41. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【温度传感器】DS18B20.pdf
  42. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【温湿度传感器】DHT11.pdf
  43. TEMPAT SAMPAH
      Doc/主板外围芯片数据手册/【红外接收】HS0038B.pdf
  44. TEMPAT SAMPAH
      Doc/主板第6版(D030-8)/D030-8_STM32-V5_PCB走线图.pdf
  45. TEMPAT SAMPAH
      Doc/主板第6版(D030-8)/D030-8_STM32-V5_原理图.pdf
  46. TEMPAT SAMPAH
      Doc/主板第6版(D030-8)/D030-8_STM32-V5_尺寸图.pdf
  47. TEMPAT SAMPAH
      Doc/主板第6版(D030-8)/D030-8_STM32-V5_底层丝印图.pdf
  48. TEMPAT SAMPAH
      Doc/主板第6版(D030-8)/D030-8_STM32-V5_顶层丝印图.pdf
  49. 0 0
      Project/conf/fatfs/bsp_fatfs.c
  50. 0 0
      Project/conf/fatfs/bsp_fatfs.h
  51. 0 0
      Project/conf/fatfs/diskio.c
  52. 251 251
      Project/conf/fatfs/ffconf.h
  53. 151 151
      Project/conf/lwip/lwip_dm9k.c
  54. 8 8
      Project/conf/lwip/lwip_dm9k.h
  55. 186 186
      Project/conf/lwip/lwip_eth.c
  56. 28 28
      Project/conf/lwip/lwip_eth.h
  57. 0 0
      Project/conf/lwip/lwip_init.c
  58. 0 0
      Project/conf/lwip/lwip_init.h
  59. 164 164
      Project/conf/lwip/lwipopts.h
  60. 36 36
      Project/conf/lwip/port/arch/bpstruct.h
  61. 82 82
      Project/conf/lwip/port/arch/cc.h
  62. 36 36
      Project/conf/lwip/port/arch/epstruct.h
  63. 44 44
      Project/conf/lwip/port/arch/init.h
  64. 38 38
      Project/conf/lwip/port/arch/lib.h
  65. 37 37
      Project/conf/lwip/port/arch/lwip_cpu.h
  66. 38 38
      Project/conf/lwip/port/arch/perf.h
  67. 512 512
      Project/conf/lwip/port/arch/sys_arch.c
  68. 77 77
      Project/conf/lwip/port/arch/sys_arch.h
  69. 398 398
      Project/conf/lwip/port/ethernetif_dm9k.c
  70. 10 10
      Project/conf/lwip/port/ethernetif_dm9k.h
  71. 414 413
      Project/conf/lwip/port/ethernetif_eth.c
  72. 9 9
      Project/conf/lwip/port/ethernetif_eth.h
  73. 252 252
      Project/conf/ucos/app_hooks.c
  74. 215 215
      Project/conf/ucos/cpu_cfg.h
  75. 59 59
      Project/conf/ucos/includes.h
  76. 171 171
      Project/conf/ucos/lib_cfg.h
  77. 141 141
      Project/conf/ucos/os_cfg.h
  78. 261 259
      Project/main.c
  79. 25 25
      Project/main.h
  80. 0 0
      Project/project_var.h
  81. 119 119
      Project/stm32f4x7_eth_conf.h
  82. 132 132
      Project/stm32f4xx_conf.h
  83. 197 197
      Project/stm32f4xx_it.c
  84. 61 61
      Project/stm32f4xx_it.h
  85. 1220 1220
      Project/system_stm32f4xx.c
  86. 118 118
      Third_Party/FATFS/doc/00index_e.html
  87. 118 118
      Third_Party/FATFS/doc/00index_j.html
  88. 65 65
      Third_Party/FATFS/doc/css_e.css
  89. 68 68
      Third_Party/FATFS/doc/css_j.css
  90. 1 1
      Third_Party/FATFS/doc/css_p.css
  91. 275 275
      Third_Party/FATFS/doc/en/appnote.html
  92. 81 81
      Third_Party/FATFS/doc/en/chdir.html
  93. 60 60
      Third_Party/FATFS/doc/en/chdrive.html
  94. 89 89
      Third_Party/FATFS/doc/en/chmod.html
  95. 66 66
      Third_Party/FATFS/doc/en/close.html
  96. 64 64
      Third_Party/FATFS/doc/en/closedir.html
  97. 46 46
      Third_Party/FATFS/doc/en/dinit.html
  98. 90 90
      Third_Party/FATFS/doc/en/dioctl.html
  99. 71 71
      Third_Party/FATFS/doc/en/dread.html
  100. 48 48
      Third_Party/FATFS/doc/en/dstat.html

+ 48 - 45
CMakeLists.txt

@@ -24,36 +24,40 @@ set(MCU_PARAMS
 
 # C 源文件
 file(GLOB_RECURSE C_SRCS
-        ${CMAKE_CURRENT_SOURCE_DIR}/User/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Project/main.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Project/stm32f4xx_it.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Project/system_stm32f4xx.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Project/conf/*.c
         ${CMAKE_CURRENT_SOURCE_DIR}/Project/GCC/startup_stm32f40xx.s
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32F4xx_StdPeriph_Driver/src/*.c
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32F4x7_ETH_Driver/src/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/FATFS/ff.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/FATFS/option/cc936.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/api/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/core/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/core/ipv4/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/core/snmp/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/netif/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/netif/ppp/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-CPU/cpu_core.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-CPU/ARM-Cortex-M4/GNU/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-CPU/ARM-Cortex-M4/GNU/*.s
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-LIB/lib_ascii.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-LIB/lib_math.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-LIB/lib_mem.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-LIB/lib_str.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-LIB/Ports/ARM-Cortex-M4/GNU/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-LIB/Ports/ARM-Cortex-M4/GNU/*.s
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/UCOS-BSP/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uCOS-II/Source/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uCOS-II/Ports/ARM-Cortex-M4/Generic/GNU/*.c
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uCOS-II/Ports/ARM-Cortex-M4/Generic/GNU/*.s
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_HOST_Library/Class/MSC/src/*.c
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_HOST_Library/Core/src/*.c
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_OTG_Driver/src/usb_core.c
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_OTG_Driver/src/usb_hcd.c
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_OTG_Driver/src/usb_hcd_int.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/FATFS/ff.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/FATFS/option/cc936.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/api/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/core/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/core/ipv4/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/core/snmp/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/netif/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/netif/ppp/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-CPU/cpu_core.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-CPU/ARM-Cortex-M4/GNU/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-CPU/ARM-Cortex-M4/GNU/*.s
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-LIB/lib_ascii.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-LIB/lib_math.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-LIB/lib_mem.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-LIB/lib_str.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-LIB/Ports/ARM-Cortex-M4/GNU/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-LIB/Ports/ARM-Cortex-M4/GNU/*.s
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/UCOS-BSP/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uCOS-II/Source/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uCOS-II/Ports/ARM-Cortex-M4/Generic/GNU/*.c
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uCOS-II/Ports/ARM-Cortex-M4/Generic/GNU/*.s
+        ${CMAKE_CURRENT_SOURCE_DIR}/User/*.c
         )
 file(GLOB_RECURSE R_SRCS
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_qspi.c
@@ -68,25 +72,32 @@ list(REMOVE_ITEM C_SRCS ${R_SRCS})
 
 # C .h文件
 set(INC_C_DIRS
-        ${CMAKE_CURRENT_SOURCE_DIR}/User
-        ${CMAKE_CURRENT_SOURCE_DIR}/User/bsp/led
+        ${CMAKE_CURRENT_SOURCE_DIR}/Project
+        ${CMAKE_CURRENT_SOURCE_DIR}/Project/conf/fatfs
+        ${CMAKE_CURRENT_SOURCE_DIR}/Project/conf/lwip
+        ${CMAKE_CURRENT_SOURCE_DIR}/Project/conf/lwip/port
+        ${CMAKE_CURRENT_SOURCE_DIR}/Project/conf/lwip/port/arch
+        ${CMAKE_CURRENT_SOURCE_DIR}/Project/conf/ucos
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/CMSIS/Include
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/CMSIS/Device/ST/STM32F4xx/Include
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32F4xx_StdPeriph_Driver/inc
         ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32F4x7_ETH_Driver/inc
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-CPU
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-CPU/ARM-Cortex-M4/GNU
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uC-LIB
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uCOS-BSP
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uCOS-II/Source
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/uCOS_II/uCOS-II/Ports/ARM-Cortex-M4/Generic/GNU
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/include
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/include/lwip
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/include/netif
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/include/posix
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/lwip-2.0.2/src/include/posix/sys
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/FATFS/src
-        ${CMAKE_CURRENT_SOURCE_DIR}/MiddleWare/cJSON
+        ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_HOST_Library/Core/inc
+        ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_HOST_Library/Class/MSC/inc
+        ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_OTG_Driver/inc
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-CPU
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-CPU/ARM-Cortex-M4/GNU
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uC-LIB
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uCOS-BSP
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uCOS-II/Source
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/uCOS_II/uCOS-II/Ports/ARM-Cortex-M4/Generic/GNU
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/include
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/include/lwip
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/include/netif
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/include/posix
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/lwip-2.0.2/src/include/posix/sys
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/FATFS/src
+        ${CMAKE_CURRENT_SOURCE_DIR}/Third_Party/cJSON
         ${CMAKE_CURRENT_SOURCE_DIR}/User
         ${CMAKE_CURRENT_SOURCE_DIR}/User/bsp
         ${CMAKE_CURRENT_SOURCE_DIR}/User/bsp/ad7606
@@ -115,14 +126,6 @@ set(INC_C_DIRS
         ${CMAKE_CURRENT_SOURCE_DIR}/User/app/memory
         ${CMAKE_CURRENT_SOURCE_DIR}/User/app/modbus
         ${CMAKE_CURRENT_SOURCE_DIR}/User/app/net
-        ${CMAKE_CURRENT_SOURCE_DIR}/User/conf/fatfs
-        ${CMAKE_CURRENT_SOURCE_DIR}/User/conf/lwip
-        ${CMAKE_CURRENT_SOURCE_DIR}/User/conf/lwip/port
-        ${CMAKE_CURRENT_SOURCE_DIR}/User/conf/lwip/port/arch
-        ${CMAKE_CURRENT_SOURCE_DIR}/User/conf/ucos
-        ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_HOST_Library/Core/inc
-        ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_HOST_Library/Class/MSC/inc
-        ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/STM32_USB_OTG_Driver/inc
         )
 
 set(INC_CXX_DIRS)

File diff ditekan karena terlalu besar
+ 1127 - 0
Doc/ModBus协议/MODBUS协议整理.htm


TEMPAT SAMPAH
Doc/ModBus协议/Modbus协议规范(中文详细).pdf


TEMPAT SAMPAH
Doc/SD卡SDIO规范/SD Card Specification(V1.0).pdf


TEMPAT SAMPAH
Doc/STM32 CPU 数据手册/STM32F405xx STM32F407xx 数据手册(2012-05 Rev 3).pdf


TEMPAT SAMPAH
Doc/STM32 CPU 数据手册/STM32F405xx,F407xx, STM32F415xx,F417xx 参考手册(2012-10 Rev 2).pdf


TEMPAT SAMPAH
Doc/STM32 CPU 数据手册/STM32F40x and STM32F41x 勘误表(2012-08 Rev 3).pdf


TEMPAT SAMPAH
Doc/STM32 CPU 数据手册/STM32F40xxx、STM32F41xxx、STM32F42xxx、STM32F43xxx参考手册(中文).pdf


TEMPAT SAMPAH
Doc/STM32 CPU 数据手册/STM32F415xx STM32F417xx 数据手册(2012-05 Rev 3).pdf


+ 5 - 0
Doc/STM32 CPU 数据手册/说明.txt

@@ -0,0 +1,5 @@
+勘误表 : CPU的硬件BUG说明, 也即应用限制
+
+数据手册 : MCU的功能概述, 管脚定义。电气指标等
+
+参考手册 : MCU内部功能的详细描述,含寄存器定义

TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【CAN收发芯片】SN65HVD230(VP230).pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【I2S音频CODEC】WM8978(V4.5_2011).pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【I2S音频CODEC】WM8978中文资料.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【LDO】XC6206.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【LDO电源】AMS1117.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【NAND Flash】HY27UF(08_16)1G2A Series(Rev0.4).pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【NOR Flash】S29GL-P_MirrorBit(NOR Flash 中文数据手册).pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【NOR Flash】S29GL128P10TFI01.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【RJ45网络变压器】HR911105A.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【RS232接口】SP3232EEN.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【RS485】SP3485.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【RS485】SP3485_cn.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【SRAM】IS61WV102416BLL-10TL.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【三轴磁力计】HMC5883L.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【三轴磁力计】HMC5883L中文规格书.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【三轴磁力计】MAG3110.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【三轴陀螺仪】MPU-6050_寄存器.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【三轴陀螺仪】MPU-6050_规格书.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【串行EEPROM】AT24C128.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【串行Flash】W25Q64CV(80MHz).pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【串行Flash】W25Q64FV(104MHz).pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【以太网PHY】DM9161C-DS-F01_102611.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【以太网】DM9000A-P03-042105.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【光照度传感器】BH1750FVI.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【地址译码器】SN74LVC139A.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【基准电压源】TL431.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【大气压力传感器】BMP085.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【大气压力传感器】BMP180.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【开关电源芯片】XL1509.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【收音机】Si4730-D60.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【温度传感器】DS18B20.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【温湿度传感器】DHT11.pdf


TEMPAT SAMPAH
Doc/主板外围芯片数据手册/【红外接收】HS0038B.pdf


TEMPAT SAMPAH
Doc/主板第6版(D030-8)/D030-8_STM32-V5_PCB走线图.pdf


TEMPAT SAMPAH
Doc/主板第6版(D030-8)/D030-8_STM32-V5_原理图.pdf


TEMPAT SAMPAH
Doc/主板第6版(D030-8)/D030-8_STM32-V5_尺寸图.pdf


TEMPAT SAMPAH
Doc/主板第6版(D030-8)/D030-8_STM32-V5_底层丝印图.pdf


TEMPAT SAMPAH
Doc/主板第6版(D030-8)/D030-8_STM32-V5_顶层丝印图.pdf


+ 0 - 0
User/conf/fatfs/bsp_fatfs.c → Project/conf/fatfs/bsp_fatfs.c


+ 0 - 0
User/conf/fatfs/bsp_fatfs.h → Project/conf/fatfs/bsp_fatfs.h


+ 0 - 0
User/conf/fatfs/diskio.c → Project/conf/fatfs/diskio.c


+ 251 - 251
User/conf/fatfs/ffconf.h → Project/conf/fatfs/ffconf.h

@@ -1,251 +1,251 @@
-/*---------------------------------------------------------------------------/
-/  FatFs - FAT file system module configuration file  R0.11a (C)ChaN, 2015
-/---------------------------------------------------------------------------*/
-
-#define _FFCONF 8051 /* Revision ID */
-
-/*---------------------------------------------------------------------------/
-/ Function Configurations
-/---------------------------------------------------------------------------*/
-
-#define _FS_READONLY 0
-/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
-/  Read-only configuration removes writing API functions, f_write(), f_sync(),
-/  f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
-/  and optional writing functions as well. */
-
-#define _FS_MINIMIZE 0
-/* This option defines minimization level to remove some basic API functions.
-/
-/   0: All basic functions are enabled.
-/   1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
-/      f_truncate() and f_rename() function are removed.
-/   2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
-/   3: f_lseek() function is removed in addition to 2. */
-
-#define _USE_STRFUNC 1
-/* This option switches string functions, f_gets(), f_putc(), f_puts() and
-/  f_printf().
-/
-/  0: Disable string functions.
-/  1: Enable without LF-CRLF conversion.
-/  2: Enable with LF-CRLF conversion. */
-
-#define _USE_FIND 0
-/* This option switches filtered directory read feature and related functions,
-/  f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */
-
-#define _USE_MKFS 1
-/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
-
-#define _USE_FASTSEEK 0
-/* This option switches fast seek feature. (0:Disable or 1:Enable) */
-
-#define _USE_LABEL 0
-/* This option switches volume label functions, f_getlabel() and f_setlabel().
-/  (0:Disable or 1:Enable) */
-
-#define _USE_FORWARD 0
-/* This option switches f_forward() function. (0:Disable or 1:Enable)
-/  To enable it, also _FS_TINY need to be set to 1. */
-
-/*---------------------------------------------------------------------------/
-/ Locale and Namespace Configurations
-/---------------------------------------------------------------------------*/
-
-#define _CODE_PAGE 936
-/* This option specifies the OEM code page to be used on the target system.
-/  Incorrect setting of the code page can cause a file open failure.
-/
-/   1   - ASCII (No extended character. Non-LFN cfg. only)
-/   437 - U.S.
-/   720 - Arabic
-/   737 - Greek
-/   771 - KBL
-/   775 - Baltic
-/   850 - Latin 1
-/   852 - Latin 2
-/   855 - Cyrillic
-/   857 - Turkish
-/   860 - Portuguese
-/   861 - Icelandic
-/   862 - Hebrew
-/   863 - Canadian French
-/   864 - Arabic
-/   865 - Nordic
-/   866 - Russian
-/   869 - Greek 2
-/   932 - Japanese (DBCS)
-/   936 - Simplified Chinese (DBCS)
-/   949 - Korean (DBCS)
-/   950 - Traditional Chinese (DBCS)
-*/
-
-#define _USE_LFN 2
-#define _MAX_LFN 255
-/* The _USE_LFN option switches the LFN feature.
-/
-/   0: Disable LFN feature. _MAX_LFN has no effect.
-/   1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
-/   2: Enable LFN with dynamic working buffer on the STACK.
-/   3: Enable LFN with dynamic working buffer on the HEAP.
-/
-/  When enable the LFN feature, Unicode handling functions (option/unicode.c) must
-/  be added to the project. The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes.
-/  When use stack for the working buffer, take care on stack overflow. When use heap
-/  memory for the working buffer, memory management functions, ff_memalloc() and
-/  ff_memfree(), must be added to the project. */
-
-#define _LFN_UNICODE 0
-/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
-/  To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE
-/  to 1. This option also affects behavior of string I/O functions. */
-
-#define _STRF_ENCODE 3
-/* When _LFN_UNICODE is 1, this option selects the character encoding on the file to
-/  be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
-/
-/  0: ANSI/OEM
-/  1: UTF-16LE
-/  2: UTF-16BE
-/  3: UTF-8
-/
-/  When _LFN_UNICODE is 0, this option has no effect. */
-
-#define _FS_RPATH 0
-/* This option configures relative path feature.
-/
-/   0: Disable relative path feature and remove related functions.
-/   1: Enable relative path feature. f_chdir() and f_chdrive() are available.
-/   2: f_getcwd() function is available in addition to 1.
-/
-/  Note that directory items read via f_readdir() are affected by this option. */
-
-/*---------------------------------------------------------------------------/
-/ Drive/Volume Configurations
-/---------------------------------------------------------------------------*/
-
-#define _VOLUMES 3
-/* Number of volumes (logical drives) to be used. */
-
-#define _STR_VOLUME_ID 0
-#define _VOLUME_STRS   "RAM", "NAND", "CF", "SD1", "SD2", "USB1", "USB2", "USB3"
-/* _STR_VOLUME_ID option switches string volume ID feature.
-/  When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
-/  number in the path name. _VOLUME_STRS defines the drive ID strings for each
-/  logical drives. Number of items must be equal to _VOLUMES. Valid characters for
-/  the drive ID strings are: A-Z and 0-9. */
-
-#define _MULTI_PARTITION 0
-/* This option switches multi-partition feature. By default (0), each logical drive
-/  number is bound to the same physical drive number and only an FAT volume found on
-/  the physical drive will be mounted. When multi-partition feature is enabled (1),
-/  each logical drive number is bound to arbitrary physical drive and partition
-/  listed in the VolToPart[]. Also f_fdisk() funciton will be available. */
-
-#define _MIN_SS 512
-#define _MAX_SS 512
-/* These options configure the range of sector size to be supported. (512, 1024,
-/  2048 or 4096) Always set both 512 for most systems, all type of memory cards and
-/  harddisk. But a larger value may be required for on-board flash memory and some
-/  type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
-/  to variable sector size and GET_SECTOR_SIZE command must be implemented to the
-/  disk_ioctl() function. */
-
-#define _USE_TRIM 0
-/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
-/  To enable Trim feature, also CTRL_TRIM command should be implemented to the
-/  disk_ioctl() function. */
-
-#define _FS_NOFSINFO 0
-/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
-/  option, and f_getfree() function at first time after volume mount will force
-/  a full FAT scan. Bit 1 controls the use of last allocated cluster number.
-/
-/  bit0=0: Use free cluster count in the FSINFO if available.
-/  bit0=1: Do not trust free cluster count in the FSINFO.
-/  bit1=0: Use last allocated cluster number in the FSINFO if available.
-/  bit1=1: Do not trust last allocated cluster number in the FSINFO.
-*/
-
-/*---------------------------------------------------------------------------/
-/ System Configurations
-/---------------------------------------------------------------------------*/
-
-#define _FS_TINY 0
-/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
-/  At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS
-/  bytes. Instead of private sector buffer eliminated from the file object,
-/  common sector buffer in the file system object (FATFS) is used for the file
-/  data transfer. */
-
-#define _FS_NORTC   0
-#define _NORTC_MON  1
-#define _NORTC_MDAY 1
-#define _NORTC_YEAR 2015
-/* The _FS_NORTC option switches timestamp feature. If the system does not have
-/  an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
-/  the timestamp feature. All objects modified by FatFs will have a fixed timestamp
-/  defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
-/  When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
-/  to be added to the project to read current time form RTC. _NORTC_MON,
-/  _NORTC_MDAY and _NORTC_YEAR have no effect.
-/  These options have no effect at read-only configuration (_FS_READONLY == 1). */
-
-#define _FS_LOCK 0
-/* The _FS_LOCK option switches file lock feature to control duplicated file open
-/  and illegal operation to open objects. This option must be 0 when _FS_READONLY
-/  is 1.
-/
-/  0:  Disable file lock feature. To avoid volume corruption, application program
-/      should avoid illegal open, remove and rename to the open objects.
-/  >0: Enable file lock feature. The value defines how many files/sub-directories
-/      can be opened simultaneously under file lock control. Note that the file
-/      lock feature is independent of re-entrancy. */
-
-#define _FS_REENTRANT 0
-#define _FS_TIMEOUT   1000
-#define _SYNC_t       HANDLE
-/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
-/  module itself. Note that regardless of this option, file access to different
-/  volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
-/  and f_fdisk() function, are always not re-entrant. Only file/directory access
-/  to the same volume is under control of this feature.
-/
-/   0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
-/   1: Enable re-entrancy. Also user provided synchronization handlers,
-/      ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
-/      function, must be added to the project. Samples are available in
-/      option/syscall.c.
-/
-/  The _FS_TIMEOUT defines timeout period in unit of time tick.
-/  The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
-/  SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
-/  included somewhere in the scope of ff.c. */
-
-#define _WORD_ACCESS 0
-/* The _WORD_ACCESS option is an only platform dependent option. It defines
-/  which access method is used to the word data on the FAT volume.
-/
-/   0: Byte-by-byte access. Always compatible with all platforms.
-/   1: Word access. Do not choose this unless under both the following conditions.
-/
-/  * Address misaligned memory access is always allowed to ALL instructions.
-/  * Byte order on the memory is little-endian.
-/
-/  If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.
-/  Following table shows allowable settings of some type of processors.
-/
-/  ARM7TDMI   0   *2          ColdFire   0    *1         V850E      0    *2
-/  Cortex-M3  0   *3          Z80        0/1             V850ES     0/1
-/  Cortex-M0  0   *2          x86        0/1             TLCS-870   0/1
-/  AVR        0/1             RX600(LE)  0/1             TLCS-900   0/1
-/  AVR32      0   *1          RL78       0    *2         R32C       0    *2
-/  PIC18      0/1             SH-2       0    *1         M16C       0/1
-/  PIC24      0   *2          H8S        0    *1         MSP430     0    *2
-/  PIC32      0   *1          H8/300H    0    *1         8051       0/1
-/
-/  *1:Big-endian.
-/  *2:Unaligned memory access is not supported.
-/  *3:Some compilers generate LDM/STM for mem_cpy function.
-*/
+/*---------------------------------------------------------------------------/
+/  FatFs - FAT file system module configuration file  R0.11a (C)ChaN, 2015
+/---------------------------------------------------------------------------*/
+
+#define _FFCONF 8051 /* Revision ID */
+
+/*---------------------------------------------------------------------------/
+/ Function Configurations
+/---------------------------------------------------------------------------*/
+
+#define _FS_READONLY 0
+/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
+/  Read-only configuration removes writing API functions, f_write(), f_sync(),
+/  f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
+/  and optional writing functions as well. */
+
+#define _FS_MINIMIZE 0
+/* This option defines minimization level to remove some basic API functions.
+/
+/   0: All basic functions are enabled.
+/   1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
+/      f_truncate() and f_rename() function are removed.
+/   2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
+/   3: f_lseek() function is removed in addition to 2. */
+
+#define _USE_STRFUNC 1
+/* This option switches string functions, f_gets(), f_putc(), f_puts() and
+/  f_printf().
+/
+/  0: Disable string functions.
+/  1: Enable without LF-CRLF conversion.
+/  2: Enable with LF-CRLF conversion. */
+
+#define _USE_FIND 0
+/* This option switches filtered directory read feature and related functions,
+/  f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */
+
+#define _USE_MKFS 1
+/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
+
+#define _USE_FASTSEEK 0
+/* This option switches fast seek feature. (0:Disable or 1:Enable) */
+
+#define _USE_LABEL 0
+/* This option switches volume label functions, f_getlabel() and f_setlabel().
+/  (0:Disable or 1:Enable) */
+
+#define _USE_FORWARD 0
+/* This option switches f_forward() function. (0:Disable or 1:Enable)
+/  To enable it, also _FS_TINY need to be set to 1. */
+
+/*---------------------------------------------------------------------------/
+/ Locale and Namespace Configurations
+/---------------------------------------------------------------------------*/
+
+#define _CODE_PAGE 936
+/* This option specifies the OEM code page to be used on the target system.
+/  Incorrect setting of the code page can cause a file open failure.
+/
+/   1   - ASCII (No extended character. Non-LFN cfg. only)
+/   437 - U.S.
+/   720 - Arabic
+/   737 - Greek
+/   771 - KBL
+/   775 - Baltic
+/   850 - Latin 1
+/   852 - Latin 2
+/   855 - Cyrillic
+/   857 - Turkish
+/   860 - Portuguese
+/   861 - Icelandic
+/   862 - Hebrew
+/   863 - Canadian French
+/   864 - Arabic
+/   865 - Nordic
+/   866 - Russian
+/   869 - Greek 2
+/   932 - Japanese (DBCS)
+/   936 - Simplified Chinese (DBCS)
+/   949 - Korean (DBCS)
+/   950 - Traditional Chinese (DBCS)
+*/
+
+#define _USE_LFN 2
+#define _MAX_LFN 255
+/* The _USE_LFN option switches the LFN feature.
+/
+/   0: Disable LFN feature. _MAX_LFN has no effect.
+/   1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
+/   2: Enable LFN with dynamic working buffer on the STACK.
+/   3: Enable LFN with dynamic working buffer on the HEAP.
+/
+/  When enable the LFN feature, Unicode handling functions (option/unicode.c) must
+/  be added to the project. The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes.
+/  When use stack for the working buffer, take care on stack overflow. When use heap
+/  memory for the working buffer, memory management functions, ff_memalloc() and
+/  ff_memfree(), must be added to the project. */
+
+#define _LFN_UNICODE 0
+/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
+/  To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE
+/  to 1. This option also affects behavior of string I/O functions. */
+
+#define _STRF_ENCODE 3
+/* When _LFN_UNICODE is 1, this option selects the character encoding on the file to
+/  be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
+/
+/  0: ANSI/OEM
+/  1: UTF-16LE
+/  2: UTF-16BE
+/  3: UTF-8
+/
+/  When _LFN_UNICODE is 0, this option has no effect. */
+
+#define _FS_RPATH 0
+/* This option configures relative path feature.
+/
+/   0: Disable relative path feature and remove related functions.
+/   1: Enable relative path feature. f_chdir() and f_chdrive() are available.
+/   2: f_getcwd() function is available in addition to 1.
+/
+/  Note that directory items read via f_readdir() are affected by this option. */
+
+/*---------------------------------------------------------------------------/
+/ Drive/Volume Configurations
+/---------------------------------------------------------------------------*/
+
+#define _VOLUMES 3
+/* Number of volumes (logical drives) to be used. */
+
+#define _STR_VOLUME_ID 0
+#define _VOLUME_STRS   "RAM", "NAND", "CF", "SD1", "SD2", "USB1", "USB2", "USB3"
+/* _STR_VOLUME_ID option switches string volume ID feature.
+/  When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
+/  number in the path name. _VOLUME_STRS defines the drive ID strings for each
+/  logical drives. Number of items must be equal to _VOLUMES. Valid characters for
+/  the drive ID strings are: A-Z and 0-9. */
+
+#define _MULTI_PARTITION 0
+/* This option switches multi-partition feature. By default (0), each logical drive
+/  number is bound to the same physical drive number and only an FAT volume found on
+/  the physical drive will be mounted. When multi-partition feature is enabled (1),
+/  each logical drive number is bound to arbitrary physical drive and partition
+/  listed in the VolToPart[]. Also f_fdisk() funciton will be available. */
+
+#define _MIN_SS 512
+#define _MAX_SS 512
+/* These options configure the range of sector size to be supported. (512, 1024,
+/  2048 or 4096) Always set both 512 for most systems, all type of memory cards and
+/  harddisk. But a larger value may be required for on-board flash memory and some
+/  type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
+/  to variable sector size and GET_SECTOR_SIZE command must be implemented to the
+/  disk_ioctl() function. */
+
+#define _USE_TRIM 0
+/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
+/  To enable Trim feature, also CTRL_TRIM command should be implemented to the
+/  disk_ioctl() function. */
+
+#define _FS_NOFSINFO 0
+/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
+/  option, and f_getfree() function at first time after volume mount will force
+/  a full FAT scan. Bit 1 controls the use of last allocated cluster number.
+/
+/  bit0=0: Use free cluster count in the FSINFO if available.
+/  bit0=1: Do not trust free cluster count in the FSINFO.
+/  bit1=0: Use last allocated cluster number in the FSINFO if available.
+/  bit1=1: Do not trust last allocated cluster number in the FSINFO.
+*/
+
+/*---------------------------------------------------------------------------/
+/ System Configurations
+/---------------------------------------------------------------------------*/
+
+#define _FS_TINY 0
+/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
+/  At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS
+/  bytes. Instead of private sector buffer eliminated from the file object,
+/  common sector buffer in the file system object (FATFS) is used for the file
+/  data transfer. */
+
+#define _FS_NORTC   0
+#define _NORTC_MON  1
+#define _NORTC_MDAY 1
+#define _NORTC_YEAR 2015
+/* The _FS_NORTC option switches timestamp feature. If the system does not have
+/  an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
+/  the timestamp feature. All objects modified by FatFs will have a fixed timestamp
+/  defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
+/  When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
+/  to be added to the project to read current time form RTC. _NORTC_MON,
+/  _NORTC_MDAY and _NORTC_YEAR have no effect.
+/  These options have no effect at read-only configuration (_FS_READONLY == 1). */
+
+#define _FS_LOCK 0
+/* The _FS_LOCK option switches file lock feature to control duplicated file open
+/  and illegal operation to open objects. This option must be 0 when _FS_READONLY
+/  is 1.
+/
+/  0:  Disable file lock feature. To avoid volume corruption, application program
+/      should avoid illegal open, remove and rename to the open objects.
+/  >0: Enable file lock feature. The value defines how many files/sub-directories
+/      can be opened simultaneously under file lock control. Note that the file
+/      lock feature is independent of re-entrancy. */
+
+#define _FS_REENTRANT 0
+#define _FS_TIMEOUT   1000
+#define _SYNC_t       HANDLE
+/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
+/  module itself. Note that regardless of this option, file access to different
+/  volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
+/  and f_fdisk() function, are always not re-entrant. Only file/directory access
+/  to the same volume is under control of this feature.
+/
+/   0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
+/   1: Enable re-entrancy. Also user provided synchronization handlers,
+/      ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
+/      function, must be added to the project. Samples are available in
+/      option/syscall.c.
+/
+/  The _FS_TIMEOUT defines timeout period in unit of time tick.
+/  The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
+/  SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
+/  included somewhere in the scope of ff.c. */
+
+#define _WORD_ACCESS 0
+/* The _WORD_ACCESS option is an only platform dependent option. It defines
+/  which access method is used to the word data on the FAT volume.
+/
+/   0: Byte-by-byte access. Always compatible with all platforms.
+/   1: Word access. Do not choose this unless under both the following conditions.
+/
+/  * Address misaligned memory access is always allowed to ALL instructions.
+/  * Byte order on the memory is little-endian.
+/
+/  If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.
+/  Following table shows allowable settings of some type of processors.
+/
+/  ARM7TDMI   0   *2          ColdFire   0    *1         V850E      0    *2
+/  Cortex-M3  0   *3          Z80        0/1             V850ES     0/1
+/  Cortex-M0  0   *2          x86        0/1             TLCS-870   0/1
+/  AVR        0/1             RX600(LE)  0/1             TLCS-900   0/1
+/  AVR32      0   *1          RL78       0    *2         R32C       0    *2
+/  PIC18      0/1             SH-2       0    *1         M16C       0/1
+/  PIC24      0   *2          H8S        0    *1         MSP430     0    *2
+/  PIC32      0   *1          H8/300H    0    *1         8051       0/1
+/
+/  *1:Big-endian.
+/  *2:Unaligned memory access is not supported.
+/  *3:Some compilers generate LDM/STM for mem_cpy function.
+*/

+ 151 - 151
User/conf/lwip/lwip_dm9k.c → Project/conf/lwip/lwip_dm9k.c

@@ -1,151 +1,151 @@
-#include "lwip_dm9k.h"
-#include "dm9k.h"
-#include "ethernetif_dm9k.h"
-#include "lwip/tcpip.h"
-#include "lwip_init.h"
-#include "malloc.h"
-#include "memory_manager.h"
-
-struct netif dm9k_netif = {0}; // 定义一个网络接口
-
-#define DM9K_TASK_PRIO     10
-#define DM9K_TASK_STK_SIZE 512
-CPU_STK     dm9k_task_stk[DM9K_TASK_STK_SIZE];
-static void ethernet_link_status_updated(struct netif *netif);
-// lwip 默认IP设置
-void lwip_dm9k_default_ip_set(__lwip_dev *lwipx)
-{
-
-    //默认远端IP为:192.168.1.100
-    lwipx->remoteip[0] = 192;
-    lwipx->remoteip[1] = 168;
-    lwipx->remoteip[2] = 1;
-    lwipx->remoteip[3] = 10;
-
-    // MAC地址设置(高三字节固定为:2.0.0,低三字节用STM32唯一ID)
-    lwipx->mac[0] = 2; //高三字节(IEEE称之为组织唯一ID,OUI)地址固定为:2.0.0
-    lwipx->mac[1] = 0;
-    lwipx->mac[2] = 0;
-    lwipx->mac[3] = 0x90; //低三字节用STM32的唯一ID
-    lwipx->mac[4] = 0x00;
-    lwipx->mac[5] = 0xae;
-
-    //默认本地IP为:192.168.1.30
-    lwipx->ip[0] = 192;
-    lwipx->ip[1] = 168;
-    lwipx->ip[2] = 1;
-    lwipx->ip[3] = 40;
-
-    //默认子网掩码:255.255.255.0
-    lwipx->netmask[0] = 255;
-    lwipx->netmask[1] = 255;
-    lwipx->netmask[2] = 255;
-    lwipx->netmask[3] = 0;
-
-    //默认网关:192.168.1.1
-    lwipx->gateway[0] = 192;
-    lwipx->gateway[1] = 168;
-    lwipx->gateway[2] = 1;
-    lwipx->gateway[3] = 1;
-
-    lwipx->dhcpstatus = 0; //没有DHCP
-}
-
-void ethernet_dm9k_link_thread(void const *argument)
-{
-    struct netif *netif = (struct netif *)(argument);
-
-    for (;;)
-    {
-        ethernet_link_check_state(netif);
-        OSTimeDly(2000);
-    }
-}
-
-// LWIP初始化(LWIP启动的时候使用)
-void lwip_dm9k_init(void)
-{
-    ip4_addr_t ipaddr;
-    ip4_addr_t netmask;
-    ip4_addr_t gw;
-
-    lwip_dm9k_default_ip_set(&dm9kdev); //设置默认IP等信息
-    dm9k_init();
-
-#ifdef USE_DHCP //使用动态IP
-    ip_addr_set_zero_ip4(&ipaddr);
-    ip_addr_set_zero_ip4(&netmask);
-    ip_addr_set_zero_ip4(&gw);
-#else //使用静态IP
-    IP4_ADDR(&ipaddr, dm9kdev.ip[0], dm9kdev.ip[1], dm9kdev.ip[2], dm9kdev.ip[3]);
-    IP4_ADDR(&netmask, dm9kdev.netmask[0], dm9kdev.netmask[1], dm9kdev.netmask[2], dm9kdev.netmask[3]);
-    IP4_ADDR(&gw, dm9kdev.gateway[0], dm9kdev.gateway[1], dm9kdev.gateway[2], dm9kdev.gateway[3]);
-#endif
-
-    netif_add(&dm9k_netif, &ipaddr, &netmask, &gw, NULL, &ethernetif_dm9k_init, &tcpip_input); //向网卡列表中添加一个网口
-    netif_set_default(&dm9k_netif);                                                            //设置netif为默认网口
-
-    /* Set the link callback function, this function is called on change of link status*/
-#if LWIP_NETIF_LINK_CALLBACK
-    netif_set_link_callback(&dm9k_netif, ethernet_link_status_updated);
-#endif
-
-    OSTaskCreateExt((void (*)(void *))ethernet_dm9k_link_thread,
-                    (void const *)&dm9k_netif,
-                    (OS_STK *)&dm9k_task_stk[DM9K_TASK_STK_SIZE - 1],
-                    (INT8U)DM9K_TASK_PRIO,
-                    (INT16U)DM9K_TASK_PRIO,
-                    (OS_STK *)&dm9k_task_stk[0],
-                    (INT32U)DM9K_TASK_STK_SIZE,
-                    (void *)0,
-                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
-
-    // if (DM9K_LINK_STATUS == 1)
-    // {
-    //     dm9k_netif.flags |= NETIF_FLAG_LINK_UP;
-    //     netif_set_up(&dm9k_netif);
-    // }
-}
-
-/**
- * @brief  This function notify user about link status changement.
- * @param  netif: the network interface
- * @retval None
- */
-static void ethernet_link_status_updated(struct netif *netif)
-{
-#if LWIP_DHCP
-    if (DHCPSemaphore == NULL)
-    {
-        osSemaphoreDef(ETH_SEM);
-        DHCPSemaphore = osSemaphoreCreate(osSemaphore(ETH_SEM), 1);
-    }
-#else
-    ip_addr_t ipaddr;
-    ip_addr_t netmask;
-    ip_addr_t gw;
-#endif /* USE_DHCP */
-
-    if (netif_is_link_up(netif))
-    {
-#if LWIP_DHCP
-        /* Update DHCP state machine */
-        dm9kdev.dhcpstatus = DHCP_START;
-        osSemaphoreRelease(DHCPSemaphore);
-#else
-        IP4_ADDR(&ipaddr, dm9kdev.ip[0], dm9kdev.ip[1], dm9kdev.ip[2], dm9kdev.ip[3]);
-        IP4_ADDR(&netmask, dm9kdev.netmask[0], dm9kdev.netmask[1], dm9kdev.netmask[2], dm9kdev.netmask[3]);
-        IP4_ADDR(&gw, dm9kdev.gateway[0], dm9kdev.gateway[1], dm9kdev.gateway[2], dm9kdev.gateway[3]);
-
-        dm9kdev.dhcpstatus = DHCP_ADDRESS_ASSIGNED; //标记网络开启成功。
-#endif /* USE_DHCP */
-    }
-    else
-    {
-#if LWIP_DHCP
-        /* Update DHCP state machine */
-        osSemaphoreRelease(DHCPSemaphore);
-#endif /* USE_DHCP */
-        dm9kdev.dhcpstatus = DHCP_LINK_DOWN;
-    }
-}
+#include "lwip_dm9k.h"
+#include "dm9k.h"
+#include "ethernetif_dm9k.h"
+#include "lwip/tcpip.h"
+#include "lwip_init.h"
+#include "malloc.h"
+#include "memory_manager.h"
+
+struct netif dm9k_netif = {0}; // 定义一个网络接口
+
+#define DM9K_TASK_PRIO     10
+#define DM9K_TASK_STK_SIZE 512
+CPU_STK     dm9k_task_stk[DM9K_TASK_STK_SIZE];
+static void ethernet_link_status_updated(struct netif *netif);
+// lwip 默认IP设置
+void lwip_dm9k_default_ip_set(__lwip_dev *lwipx)
+{
+
+    //默认远端IP为:192.168.1.100
+    lwipx->remoteip[0] = 192;
+    lwipx->remoteip[1] = 168;
+    lwipx->remoteip[2] = 1;
+    lwipx->remoteip[3] = 10;
+
+    // MAC地址设置(高三字节固定为:2.0.0,低三字节用STM32唯一ID)
+    lwipx->mac[0] = 2; //高三字节(IEEE称之为组织唯一ID,OUI)地址固定为:2.0.0
+    lwipx->mac[1] = 0;
+    lwipx->mac[2] = 0;
+    lwipx->mac[3] = 0x90; //低三字节用STM32的唯一ID
+    lwipx->mac[4] = 0x00;
+    lwipx->mac[5] = 0xae;
+
+    //默认本地IP为:192.168.1.30
+    lwipx->ip[0] = 192;
+    lwipx->ip[1] = 168;
+    lwipx->ip[2] = 1;
+    lwipx->ip[3] = 40;
+
+    //默认子网掩码:255.255.255.0
+    lwipx->netmask[0] = 255;
+    lwipx->netmask[1] = 255;
+    lwipx->netmask[2] = 255;
+    lwipx->netmask[3] = 0;
+
+    //默认网关:192.168.1.1
+    lwipx->gateway[0] = 192;
+    lwipx->gateway[1] = 168;
+    lwipx->gateway[2] = 1;
+    lwipx->gateway[3] = 1;
+
+    lwipx->dhcpstatus = 0; //没有DHCP
+}
+
+void ethernet_dm9k_link_thread(void const *argument)
+{
+    struct netif *netif = (struct netif *)(argument);
+
+    for (;;)
+    {
+        ethernet_link_check_state(netif);
+        OSTimeDly(2000);
+    }
+}
+
+// LWIP初始化(LWIP启动的时候使用)
+void lwip_dm9k_init(void)
+{
+    ip4_addr_t ipaddr;
+    ip4_addr_t netmask;
+    ip4_addr_t gw;
+
+    lwip_dm9k_default_ip_set(&dm9kdev); //设置默认IP等信息
+    dm9k_init();
+
+#ifdef USE_DHCP //使用动态IP
+    ip_addr_set_zero_ip4(&ipaddr);
+    ip_addr_set_zero_ip4(&netmask);
+    ip_addr_set_zero_ip4(&gw);
+#else //使用静态IP
+    IP4_ADDR(&ipaddr, dm9kdev.ip[0], dm9kdev.ip[1], dm9kdev.ip[2], dm9kdev.ip[3]);
+    IP4_ADDR(&netmask, dm9kdev.netmask[0], dm9kdev.netmask[1], dm9kdev.netmask[2], dm9kdev.netmask[3]);
+    IP4_ADDR(&gw, dm9kdev.gateway[0], dm9kdev.gateway[1], dm9kdev.gateway[2], dm9kdev.gateway[3]);
+#endif
+
+    netif_add(&dm9k_netif, &ipaddr, &netmask, &gw, NULL, &ethernetif_dm9k_init, &tcpip_input); //向网卡列表中添加一个网口
+    netif_set_default(&dm9k_netif);                                                            //设置netif为默认网口
+
+    /* Set the link callback function, this function is called on change of link status*/
+#if LWIP_NETIF_LINK_CALLBACK
+    netif_set_link_callback(&dm9k_netif, ethernet_link_status_updated);
+#endif
+
+    OSTaskCreateExt((void (*)(void *))ethernet_dm9k_link_thread,
+                    (void const *)&dm9k_netif,
+                    (OS_STK *)&dm9k_task_stk[DM9K_TASK_STK_SIZE - 1],
+                    (INT8U)DM9K_TASK_PRIO,
+                    (INT16U)DM9K_TASK_PRIO,
+                    (OS_STK *)&dm9k_task_stk[0],
+                    (INT32U)DM9K_TASK_STK_SIZE,
+                    (void *)0,
+                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
+
+    // if (DM9K_LINK_STATUS == 1)
+    // {
+    //     dm9k_netif.flags |= NETIF_FLAG_LINK_UP;
+    //     netif_set_up(&dm9k_netif);
+    // }
+}
+
+/**
+ * @brief  This function notify user about link status changement.
+ * @param  netif: the network interface
+ * @retval None
+ */
+static void ethernet_link_status_updated(struct netif *netif)
+{
+#if LWIP_DHCP
+    if (DHCPSemaphore == NULL)
+    {
+        osSemaphoreDef(ETH_SEM);
+        DHCPSemaphore = osSemaphoreCreate(osSemaphore(ETH_SEM), 1);
+    }
+#else
+    ip_addr_t ipaddr;
+    ip_addr_t netmask;
+    ip_addr_t gw;
+#endif /* USE_DHCP */
+
+    if (netif_is_link_up(netif))
+    {
+#if LWIP_DHCP
+        /* Update DHCP state machine */
+        dm9kdev.dhcpstatus = DHCP_START;
+        osSemaphoreRelease(DHCPSemaphore);
+#else
+        IP4_ADDR(&ipaddr, dm9kdev.ip[0], dm9kdev.ip[1], dm9kdev.ip[2], dm9kdev.ip[3]);
+        IP4_ADDR(&netmask, dm9kdev.netmask[0], dm9kdev.netmask[1], dm9kdev.netmask[2], dm9kdev.netmask[3]);
+        IP4_ADDR(&gw, dm9kdev.gateway[0], dm9kdev.gateway[1], dm9kdev.gateway[2], dm9kdev.gateway[3]);
+
+        dm9kdev.dhcpstatus = DHCP_ADDRESS_ASSIGNED; //标记网络开启成功。
+#endif /* USE_DHCP */
+    }
+    else
+    {
+#if LWIP_DHCP
+        /* Update DHCP state machine */
+        osSemaphoreRelease(DHCPSemaphore);
+#endif /* USE_DHCP */
+        dm9kdev.dhcpstatus = DHCP_LINK_DOWN;
+    }
+}

+ 8 - 8
User/conf/lwip/lwip_dm9k.h → Project/conf/lwip/lwip_dm9k.h

@@ -1,8 +1,8 @@
-#ifndef _LWIP_DM9K_H
-#define _LWIP_DM9K_H
-
-#include "fly_config.h"
-
-void lwip_dm9k_init(void);
-
-#endif
+#ifndef _LWIP_DM9K_H
+#define _LWIP_DM9K_H
+
+#include "fly_config.h"
+
+void lwip_dm9k_init(void);
+
+#endif

+ 186 - 186
User/conf/lwip/lwip_eth.c → Project/conf/lwip/lwip_eth.c

@@ -1,186 +1,186 @@
-#include "lwip_eth.h"
-#include "ethernetif_eth.h"
-#include "lwip/dhcp.h"
-#include "lwip/mem.h"
-#include "lwip/memp.h"
-#include "lwip/netif.h"
-#include "lwip/tcpip.h"
-#include "lwip_init.h"
-#include "stm32f4x7_phy.h"
-#include <stdio.h>
-
-#define MAX_DHCP_TRIES 4
-
-#ifdef USE_DHCP
-dhcp_state_enum dhcp_state = DHCP_START;
-ip4_addr_t      ip_address = {0};
-#endif /* USE_DHCP */
-
-struct netif gnetif;
-
-// lwip 默认IP设置
-void lwip_eth_default_ip_set(__lwip_dev *lwipx)
-{
-
-    //默认远端IP为:192.168.1.100
-    lwipx->remoteip[0] = 192;
-    lwipx->remoteip[1] = 168;
-    lwipx->remoteip[2] = 1;
-    lwipx->remoteip[3] = 10;
-
-    // MAC地址设置(高三字节固定为:2.0.0,低三字节用STM32唯一ID)
-    lwipx->mac[0] = 2; //高三字节(IEEE称之为组织唯一ID,OUI)地址固定为:2.0.0
-    lwipx->mac[1] = 0;
-    lwipx->mac[2] = 0;
-    lwipx->mac[3] = 0; //低三字节用STM32的唯一ID
-    lwipx->mac[4] = 0;
-    lwipx->mac[5] = 0;
-
-    //默认本地IP为:192.168.1.30
-    lwipx->ip[0] = 192;
-    lwipx->ip[1] = 168;
-    lwipx->ip[2] = 1;
-    lwipx->ip[3] = 40;
-
-    //默认子网掩码:255.255.255.0
-    lwipx->netmask[0] = 255;
-    lwipx->netmask[1] = 255;
-    lwipx->netmask[2] = 255;
-    lwipx->netmask[3] = 0;
-
-    //默认网关:192.168.1.1
-    lwipx->gateway[0] = 192;
-    lwipx->gateway[1] = 168;
-    lwipx->gateway[2] = 1;
-    lwipx->gateway[3] = 1;
-
-    lwipx->dhcpstatus = 0; //没有DHCP
-}
-
-/*!
-    \brief      initializes the LwIP stack
-    \param[in]  none
-    \param[out] none
-    \retval     none
-*/
-void lwip_eth_setup(void)
-{
-    ip4_addr_t ipaddr;
-    ip4_addr_t netmask;
-    ip4_addr_t gw;
-
-    lwip_eth_default_ip_set(&ethdev); //设置默认IP等信息
-    eth_init();
-    /* IP address setting */
-#ifdef USE_DHCP
-    ipaddr.addr  = 0;
-    netmask.addr = 0;
-    gw.addr      = 0;
-#else
-    IP4_ADDR(&ipaddr, ethdev.ip[0], ethdev.ip[1], ethdev.ip[2], ethdev.ip[3]);
-    IP4_ADDR(&netmask, ethdev.netmask[0], ethdev.netmask[1], ethdev.netmask[2], ethdev.netmask[3]);
-    IP4_ADDR(&gw, ethdev.gateway[0], ethdev.gateway[1], ethdev.gateway[2], ethdev.gateway[3]);
-
-#endif /* USE_DHCP */
-
-    /* - netif_add(struct netif *netif,
-                  struct ip_addr *ipaddr,
-                  struct ip_addr *netmask,
-                  struct ip_addr *gw,
-                  void *state,
-                  err_t (* init)(struct netif *netif),
-                  err_t (* input)(struct pbuf *p,
-                  struct netif *netif))
-
-      将您的网络接口添加到 netif_list。
-      分配结构netif,并将指向该结构的指针作为第一个参数传递。
-      使用DHCP时,请提供指向已清除的ip_addr结构的指针,否则,请使用健全的数字填充它们。
-      状态指针可以为NULL。
-
-      初始化函数指针必须指向您的以太网netif接口的初始化函数。 以下代码说明了它的用法。*/
-    netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_eth_init, &tcpip_input);
-
-    printf("LwIP Registers the default network interface....\r\n");
-    /* 注册默认网络接口.*/
-    netif_set_default(&gnetif);
-
-    if (EthStatus == (ETH_INIT_FLAG))
-    {
-        printf("LwIP Finish interface....\r\n");
-        gnetif.flags |= NETIF_FLAG_LINK_UP;
-        /* 配置完成网卡后启动网卡*/
-        netif_set_up(&gnetif);
-    }
-    else
-    {
-        netif_set_down(&gnetif);
-    }
-}
-
-#ifdef USE_DHCP
-/*!
-    \brief      lwip_dhcp_process_handle
-    \param[in]  none
-    \param[out] none
-    \retval     none
-*/
-void dhcp_task(void *pvParameters)
-{
-    ip4_addr_t   ipaddr;
-    ip4_addr_t   netmask;
-    ip4_addr_t   gw;
-    struct dhcp *dhcp_client;
-
-    dhcp_client = netif_dhcp_data(&gnetif);
-
-    for (;;)
-    {
-        switch (dhcp_state)
-        {
-        case DHCP_START:
-            dhcp_start(&gnetif);
-            ip_address.addr = 0;
-            dhcp_state      = DHCP_WAIT_ADDRESS;
-            break;
-
-        case DHCP_WAIT_ADDRESS:
-            /* read the new IP address */
-            ip_address.addr = gnetif.ip_addr.u_addr.ip4.addr;
-
-            if (ip_address.addr != 0)
-            {
-                dhcp_state = DHCP_ADDRESS_ASSIGNED;
-                /* stop DHCP */
-                dhcp_stop(&gnetif);
-
-                printf("\r\nDHCP -- eval board ip address: %d.%d.%d.%d \r\n", ip4_addr1_16(&ip_address),
-                       ip4_addr2_16(&ip_address), ip4_addr3_16(&ip_address), ip4_addr4_16(&ip_address));
-                OSTaskSuspend(OS_PRIO_SELF);
-            }
-            else
-            {
-                /* DHCP timeout */
-                if (dhcp_client->tries > MAX_DHCP_TRIES)
-                {
-                    dhcp_state = DHCP_TIMEOUT;
-                    /* stop DHCP */
-                    dhcp_stop(&gnetif);
-
-                    /* static address used */
-                    IP4_ADDR(&ipaddr, ethdev.ip[0], ethdev.ip[1], ethdev.ip[2], ethdev.ip[3]);
-                    IP4_ADDR(&netmask, ethdev.netmask[0], ethdev.netmask[1], ethdev.netmask[2], ethdev.netmask[3]);
-                    IP4_ADDR(&gw, ethdev.gateway[0], ethdev.gateway[1], ethdev.gateway[2], ethdev.gateway[3]);
-                    netif_set_addr(&gnetif, &ipaddr, &netmask, &gw);
-                    OSTaskSuspend(OS_PRIO_SELF);
-                }
-            }
-            break;
-
-        default:
-            break;
-        }
-        /* wait 500 ms */
-        OSTimeDlyHMSM(0, 0, 0, 500);
-    }
-}
-#endif /* USE_DHCP */
+#include "lwip_eth.h"
+#include "ethernetif_eth.h"
+#include "lwip/dhcp.h"
+#include "lwip/mem.h"
+#include "lwip/memp.h"
+#include "lwip/netif.h"
+#include "lwip/tcpip.h"
+#include "lwip_init.h"
+#include "stm32f4x7_phy.h"
+#include <stdio.h>
+
+#define MAX_DHCP_TRIES 4
+
+#ifdef USE_DHCP
+dhcp_state_enum dhcp_state = DHCP_START;
+ip4_addr_t      ip_address = {0};
+#endif /* USE_DHCP */
+
+struct netif gnetif;
+
+// lwip 默认IP设置
+void lwip_eth_default_ip_set(__lwip_dev *lwipx)
+{
+
+    //默认远端IP为:192.168.1.100
+    lwipx->remoteip[0] = 192;
+    lwipx->remoteip[1] = 168;
+    lwipx->remoteip[2] = 1;
+    lwipx->remoteip[3] = 10;
+
+    // MAC地址设置(高三字节固定为:2.0.0,低三字节用STM32唯一ID)
+    lwipx->mac[0] = 2; //高三字节(IEEE称之为组织唯一ID,OUI)地址固定为:2.0.0
+    lwipx->mac[1] = 0;
+    lwipx->mac[2] = 0;
+    lwipx->mac[3] = 0; //低三字节用STM32的唯一ID
+    lwipx->mac[4] = 0;
+    lwipx->mac[5] = 0;
+
+    //默认本地IP为:192.168.1.30
+    lwipx->ip[0] = 192;
+    lwipx->ip[1] = 168;
+    lwipx->ip[2] = 1;
+    lwipx->ip[3] = 40;
+
+    //默认子网掩码:255.255.255.0
+    lwipx->netmask[0] = 255;
+    lwipx->netmask[1] = 255;
+    lwipx->netmask[2] = 255;
+    lwipx->netmask[3] = 0;
+
+    //默认网关:192.168.1.1
+    lwipx->gateway[0] = 192;
+    lwipx->gateway[1] = 168;
+    lwipx->gateway[2] = 1;
+    lwipx->gateway[3] = 1;
+
+    lwipx->dhcpstatus = 0; //没有DHCP
+}
+
+/*!
+    \brief      initializes the LwIP stack
+    \param[in]  none
+    \param[out] none
+    \retval     none
+*/
+void lwip_eth_setup(void)
+{
+    ip4_addr_t ipaddr;
+    ip4_addr_t netmask;
+    ip4_addr_t gw;
+
+    lwip_eth_default_ip_set(&ethdev); //设置默认IP等信息
+    eth_init();
+    /* IP address setting */
+#ifdef USE_DHCP
+    ipaddr.addr  = 0;
+    netmask.addr = 0;
+    gw.addr      = 0;
+#else
+    IP4_ADDR(&ipaddr, ethdev.ip[0], ethdev.ip[1], ethdev.ip[2], ethdev.ip[3]);
+    IP4_ADDR(&netmask, ethdev.netmask[0], ethdev.netmask[1], ethdev.netmask[2], ethdev.netmask[3]);
+    IP4_ADDR(&gw, ethdev.gateway[0], ethdev.gateway[1], ethdev.gateway[2], ethdev.gateway[3]);
+
+#endif /* USE_DHCP */
+
+    /* - netif_add(struct netif *netif,
+                  struct ip_addr *ipaddr,
+                  struct ip_addr *netmask,
+                  struct ip_addr *gw,
+                  void *state,
+                  err_t (* init)(struct netif *netif),
+                  err_t (* input)(struct pbuf *p,
+                  struct netif *netif))
+
+      将您的网络接口添加到 netif_list。
+      分配结构netif,并将指向该结构的指针作为第一个参数传递。
+      使用DHCP时,请提供指向已清除的ip_addr结构的指针,否则,请使用健全的数字填充它们。
+      状态指针可以为NULL。
+
+      初始化函数指针必须指向您的以太网netif接口的初始化函数。 以下代码说明了它的用法。*/
+    netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, &ethernetif_eth_init, &tcpip_input);
+
+    printf("LwIP Registers the default network interface....\r\n");
+    /* 注册默认网络接口.*/
+    netif_set_default(&gnetif);
+
+    if (EthStatus == (ETH_INIT_FLAG))
+    {
+        printf("LwIP Finish interface....\r\n");
+        gnetif.flags |= NETIF_FLAG_LINK_UP;
+        /* 配置完成网卡后启动网卡*/
+        netif_set_up(&gnetif);
+    }
+    else
+    {
+        netif_set_down(&gnetif);
+    }
+}
+
+#ifdef USE_DHCP
+/*!
+    \brief      lwip_dhcp_process_handle
+    \param[in]  none
+    \param[out] none
+    \retval     none
+*/
+void dhcp_task(void *pvParameters)
+{
+    ip4_addr_t   ipaddr;
+    ip4_addr_t   netmask;
+    ip4_addr_t   gw;
+    struct dhcp *dhcp_client;
+
+    dhcp_client = netif_dhcp_data(&gnetif);
+
+    for (;;)
+    {
+        switch (dhcp_state)
+        {
+        case DHCP_START:
+            dhcp_start(&gnetif);
+            ip_address.addr = 0;
+            dhcp_state      = DHCP_WAIT_ADDRESS;
+            break;
+
+        case DHCP_WAIT_ADDRESS:
+            /* read the new IP address */
+            ip_address.addr = gnetif.ip_addr.u_addr.ip4.addr;
+
+            if (ip_address.addr != 0)
+            {
+                dhcp_state = DHCP_ADDRESS_ASSIGNED;
+                /* stop DHCP */
+                dhcp_stop(&gnetif);
+
+                printf("\r\nDHCP -- eval board ip address: %d.%d.%d.%d \r\n", ip4_addr1_16(&ip_address),
+                       ip4_addr2_16(&ip_address), ip4_addr3_16(&ip_address), ip4_addr4_16(&ip_address));
+                OSTaskSuspend(OS_PRIO_SELF);
+            }
+            else
+            {
+                /* DHCP timeout */
+                if (dhcp_client->tries > MAX_DHCP_TRIES)
+                {
+                    dhcp_state = DHCP_TIMEOUT;
+                    /* stop DHCP */
+                    dhcp_stop(&gnetif);
+
+                    /* static address used */
+                    IP4_ADDR(&ipaddr, ethdev.ip[0], ethdev.ip[1], ethdev.ip[2], ethdev.ip[3]);
+                    IP4_ADDR(&netmask, ethdev.netmask[0], ethdev.netmask[1], ethdev.netmask[2], ethdev.netmask[3]);
+                    IP4_ADDR(&gw, ethdev.gateway[0], ethdev.gateway[1], ethdev.gateway[2], ethdev.gateway[3]);
+                    netif_set_addr(&gnetif, &ipaddr, &netmask, &gw);
+                    OSTaskSuspend(OS_PRIO_SELF);
+                }
+            }
+            break;
+
+        default:
+            break;
+        }
+        /* wait 500 ms */
+        OSTimeDlyHMSM(0, 0, 0, 500);
+    }
+}
+#endif /* USE_DHCP */

+ 28 - 28
User/conf/lwip/lwip_eth.h → Project/conf/lwip/lwip_eth.h

@@ -1,28 +1,28 @@
-#ifndef LWIP_ETH_H
-#define LWIP_ETH_H
-
-// #include "fly_config.h"
-
-//#define USE_DHCP       1 /* enable DHCP, if disabled static address is used */
-// extern __lwip_dev ethdev; // lwip控制结构体
-
-#define USE_ETH_INTERRUPT
-
-/* MII and RMII mode selection */
-#define RMII_MODE // user have to provide the 50 MHz clock by soldering a 50 MHz oscillator
-//#define MII_MODE
-
-/* clock the PHY from external 25MHz crystal (only for MII mode) */
-#ifdef MII_MODE
-#define PHY_CLOCK_MCO
-#endif
-
-#ifdef USE_DHCP
-/* dhcp_task */
-void dhcp_task(void *pvParameters);
-#include "dhcp.h"
-#endif /* USE_DHCP */
-
-void lwip_eth_setup(void);
-
-#endif /* NETCONF_H */
+#ifndef LWIP_ETH_H
+#define LWIP_ETH_H
+
+// #include "fly_config.h"
+
+//#define USE_DHCP       1 /* enable DHCP, if disabled static address is used */
+// extern __lwip_dev ethdev; // lwip控制结构体
+
+#define USE_ETH_INTERRUPT
+
+/* MII and RMII mode selection */
+#define RMII_MODE // user have to provide the 50 MHz clock by soldering a 50 MHz oscillator
+//#define MII_MODE
+
+/* clock the PHY from external 25MHz crystal (only for MII mode) */
+#ifdef MII_MODE
+#define PHY_CLOCK_MCO
+#endif
+
+#ifdef USE_DHCP
+/* dhcp_task */
+void dhcp_task(void *pvParameters);
+#include "dhcp.h"
+#endif /* USE_DHCP */
+
+void lwip_eth_setup(void);
+
+#endif /* NETCONF_H */

+ 0 - 0
User/conf/lwip/lwip_init.c → Project/conf/lwip/lwip_init.c


+ 0 - 0
User/conf/lwip/lwip_init.h → Project/conf/lwip/lwip_init.h


+ 164 - 164
User/conf/lwip/lwipopts.h → Project/conf/lwip/lwipopts.h

@@ -1,164 +1,164 @@
-/*!
-    \file  lwipopts.h
-    \brief LwIP options configuration
-*/
-
-/*
-    Copyright (C) 2016 GigaDevice
-
-    2016-08-15, V1.0.0, firmware for GD32F4xx
-*/
-
-#ifndef LWIPOPTS_H
-#define LWIPOPTS_H
-
-#define ETHARP_TRUST_IP_MAC 0
-#define IP_REASSEMBLY       0
-#define IP_FRAG             0
-#define ARP_QUEUEING        0
-
-#define SYS_LIGHTWEIGHT_PROT 1 /* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection \
-                                  for certain critical regions during buffer allocation,     \
-                                  deallocation and memory allocation and deallocation */
-
-#define NO_SYS 0 /* NO_SYS==1: provides VERY minimal functionality. \
-                    Otherwise, use lwIP facilities */
-
-/*  memory options  */
-#define MEM_ALIGNMENT 4 /* should be set to the alignment of the CPU for which lwIP \
-                           is compiled. 4 byte alignment -> define MEM_ALIGNMENT    \
-                           to 4, 2 byte alignment -> define MEM_ALIGNMENT to 2 */
-
-#define MEM_SIZE (12 * 1024) /* the size of the heap memory, if the application will    \
-                                send a lot of data that needs to be copied, this should \
-                                be set high */
-
-#define MEMP_NUM_PBUF 20 /* the number of memp struct pbufs. If the application      \
-                            sends a lot of data out of ROM (or other static memory), \
-                            this should be set high */
-
-#define MEMP_NUM_UDP_PCB 6 /* the number of UDP protocol control blocks, one \
-                              per active UDP "connection" */
-
-#define MEMP_NUM_TCP_PCB 10 /* the number of simulatenously active TCP connections */
-
-#define MEMP_NUM_TCP_PCB_LISTEN 5 /* the number of listening TCP connections */
-
-#define MEMP_NUM_TCP_SEG 20 /* the number of simultaneously queued TCP segments */
-
-#define MEMP_NUM_SYS_TIMEOUT 10 /* the number of simulateously active timeouts */
-
-#define MEMP_NUM_NETBUF 8 /* the number of struct netbufs */
-
-/* ---------- pbuf选项 ---------- */
-#define MEMP_NUM_PBUF            15   /* MEMP_NUM_PBUF:memp结构的pbuf数量,如果应用从ROM或者静态存储区发送大量数据时,这个值应该设置大一点 */
-#define PBUF_POOL_SIZE           15   /* PBUF_POOL_SIZE:pbuf内存池个数 */
-#define PBUF_POOL_BUFSIZE        1528 /* PBUF_POOL_BUFSIZE:每个pbuf内存池大小 */
-#define LWIP_SUPPORT_CUSTOM_PBUF 1
-
-/* TCP options */
-#define LWIP_TCP 1
-#define TCP_TTL  255
-
-#define TCP_QUEUE_OOSEQ 0 /* controls if TCP should queue segments that arrive out of \
-                             order, Define to 0 if your device is low on memory. */
-#undef TCPIP_MBOX_SIZE
-#define TCPIP_MBOX_SIZE MAX_QUEUE_ENTRIES /* the mailbox size for the tcpip thread messages */
-
-#undef DEFAULT_TCP_RECVMBOX_SIZE
-#define DEFAULT_TCP_RECVMBOX_SIZE MAX_QUEUE_ENTRIES /* the mailbox size for the incoming packets on a NETCONN_TCP */
-
-#undef DEFAULT_ACCEPTMBOX_SIZE /* the mailbox size for the incoming connections */
-#define DEFAULT_ACCEPTMBOX_SIZE MAX_QUEUE_ENTRIES
-
-#define DEFAULT_UDP_RECVMBOX_SIZE MAX_QUEUE_ENTRIES /* The mailbox size for the incoming packets on a NETCONN_UDP */
-
-#define TCP_MSS (1500 - 40) /* TCP Maximum segment size, \
-                               TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
-
-#define TCP_SND_BUF (5 * TCP_MSS) /* TCP sender buffer space (bytes) */
-
-#define TCP_SND_QUEUELEN ((4 * TCP_SND_BUF) / TCP_MSS) /* TCP sender buffer space (pbufs), this must be at least \
-                                                        as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work */
-
-#define TCP_WND (2 * TCP_MSS) /* TCP receive window */
-
-/* ICMP options */
-#define LWIP_ICMP 1
-
-/* DHCP options */
-#define LWIP_DHCP 0 /* define to 1 if you want DHCP configuration of interfaces, \
-                       DHCP is not implemented in lwIP 0.5.1, however, so        \
-                       turning this on does currently not work. */
-
-#define LWIP_IPV4 1
-#define LWIP_IPV6 0
-
-/* UDP options */
-#define LWIP_UDP 1
-#define UDP_TTL  255
-
-/* statistics options */
-#define LWIP_STATS         0
-#define LWIP_PROVIDE_ERRNO 1
-
-/* checksum options */
-#define CHECKSUM_BY_HARDWARE   /* computing and verifying the IP, UDP, TCP and ICMP \
-                                 checksums by hardware */
-
-/* netconn options */
-#define LWIP_NETCONN 1 /* set to 1 to enable netconn API (require to use api_lib.c) */
-
-#define MEMP_NUM_NETCONN 4 /* the number of struct netconns */
-
-/* socket options */
-#define LWIP_SOCKET 1 /* set to 1 to enable socket API (require to use sockets.c) */
-
-#define LWIP_SO_RCVTIMEO 1 /* set to 1 to enable receive timeout for sockets/netconns and \
-                              SO_RCVTIMEO processing */
-#define LWIP_NETIF_LINK_CALLBACK 1
-/* Lwip debug options */
-#define LWIP_DEBUG 0
-
-#ifdef CHECKSUM_BY_HARDWARE
-/* CHECKSUM_GEN_IP==0: generate checksums by hardware for outgoing IP packets.*/
-#define CHECKSUM_GEN_IP 0
-/* CHECKSUM_GEN_UDP==0: generate checksums by hardware for outgoing UDP packets.*/
-#define CHECKSUM_GEN_UDP 0
-/* CHECKSUM_GEN_TCP==0: generate checksums by hardware for outgoing TCP packets.*/
-#define CHECKSUM_GEN_TCP 0
-/* CHECKSUM_CHECK_IP==0: check checksums by hardware for incoming IP packets.*/
-#define CHECKSUM_CHECK_IP 0
-/* CHECKSUM_CHECK_UDP==0: check checksums by hardware for incoming UDP packets.*/
-#define CHECKSUM_CHECK_UDP 0
-/* CHECKSUM_CHECK_TCP==0: check checksums by hardware for incoming TCP packets.*/
-#define CHECKSUM_CHECK_TCP 0
-#define CHECKSUM_GEN_ICMP  0
-#else
-/* CHECKSUM_GEN_IP==1: generate checksums in software for outgoing IP packets.*/
-#define CHECKSUM_GEN_IP    1
-/* CHECKSUM_GEN_UDP==1: generate checksums in software for outgoing UDP packets.*/
-#define CHECKSUM_GEN_UDP   1
-/* CHECKSUM_GEN_TCP==1: generate checksums in software for outgoing TCP packets.*/
-#define CHECKSUM_GEN_TCP   1
-/* CHECKSUM_CHECK_IP==1: check checksums in software for incoming IP packets.*/
-#define CHECKSUM_CHECK_IP  1
-/* CHECKSUM_CHECK_UDP==1: check checksums in software for incoming UDP packets.*/
-#define CHECKSUM_CHECK_UDP 1
-/* CHECKSUM_CHECK_TCP==1: check checksums in software for incoming TCP packets.*/
-#define CHECKSUM_CHECK_TCP 1
-#define CHECKSUM_GEN_ICMP  1
-#endif
-
-/*
-   ---------------------------------
-   ---------- OS options ----------
-   ---------------------------------
-*/
-#define TCPIP_THREAD_STACKSIZE   1000
-#define DEFAULT_THREAD_STACKSIZE 512
-#define LWIP_COMPAT_MUTEX        1
-#define TCPIP_THREAD_PRIO        5
-#define DEFAULT_THREAD_PRIO      2
-
-#endif /* LWIPOPTS_H */
+/*!
+    \file  lwipopts.h
+    \brief LwIP options configuration
+*/
+
+/*
+    Copyright (C) 2016 GigaDevice
+
+    2016-08-15, V1.0.0, firmware for GD32F4xx
+*/
+
+#ifndef LWIPOPTS_H
+#define LWIPOPTS_H
+
+#define ETHARP_TRUST_IP_MAC 0
+#define IP_REASSEMBLY       0
+#define IP_FRAG             0
+#define ARP_QUEUEING        0
+
+#define SYS_LIGHTWEIGHT_PROT 1 /* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection \
+                                  for certain critical regions during buffer allocation,     \
+                                  deallocation and memory allocation and deallocation */
+
+#define NO_SYS 0 /* NO_SYS==1: provides VERY minimal functionality. \
+                    Otherwise, use lwIP facilities */
+
+/*  memory options  */
+#define MEM_ALIGNMENT 4 /* should be set to the alignment of the CPU for which lwIP \
+                           is compiled. 4 byte alignment -> define MEM_ALIGNMENT    \
+                           to 4, 2 byte alignment -> define MEM_ALIGNMENT to 2 */
+
+#define MEM_SIZE (12 * 1024) /* the size of the heap memory, if the application will    \
+                                send a lot of data that needs to be copied, this should \
+                                be set high */
+
+#define MEMP_NUM_PBUF 20 /* the number of memp struct pbufs. If the application      \
+                            sends a lot of data out of ROM (or other static memory), \
+                            this should be set high */
+
+#define MEMP_NUM_UDP_PCB 6 /* the number of UDP protocol control blocks, one \
+                              per active UDP "connection" */
+
+#define MEMP_NUM_TCP_PCB 10 /* the number of simulatenously active TCP connections */
+
+#define MEMP_NUM_TCP_PCB_LISTEN 5 /* the number of listening TCP connections */
+
+#define MEMP_NUM_TCP_SEG 20 /* the number of simultaneously queued TCP segments */
+
+#define MEMP_NUM_SYS_TIMEOUT 10 /* the number of simulateously active timeouts */
+
+#define MEMP_NUM_NETBUF 8 /* the number of struct netbufs */
+
+/* ---------- pbuf选项 ---------- */
+#define MEMP_NUM_PBUF            15   /* MEMP_NUM_PBUF:memp结构的pbuf数量,如果应用从ROM或者静态存储区发送大量数据时,这个值应该设置大一点 */
+#define PBUF_POOL_SIZE           15   /* PBUF_POOL_SIZE:pbuf内存池个数 */
+#define PBUF_POOL_BUFSIZE        1528 /* PBUF_POOL_BUFSIZE:每个pbuf内存池大小 */
+#define LWIP_SUPPORT_CUSTOM_PBUF 1
+
+/* TCP options */
+#define LWIP_TCP 1
+#define TCP_TTL  255
+
+#define TCP_QUEUE_OOSEQ 0 /* controls if TCP should queue segments that arrive out of \
+                             order, Define to 0 if your device is low on memory. */
+#undef TCPIP_MBOX_SIZE
+#define TCPIP_MBOX_SIZE MAX_QUEUE_ENTRIES /* the mailbox size for the tcpip thread messages */
+
+#undef DEFAULT_TCP_RECVMBOX_SIZE
+#define DEFAULT_TCP_RECVMBOX_SIZE MAX_QUEUE_ENTRIES /* the mailbox size for the incoming packets on a NETCONN_TCP */
+
+#undef DEFAULT_ACCEPTMBOX_SIZE /* the mailbox size for the incoming connections */
+#define DEFAULT_ACCEPTMBOX_SIZE MAX_QUEUE_ENTRIES
+
+#define DEFAULT_UDP_RECVMBOX_SIZE MAX_QUEUE_ENTRIES /* The mailbox size for the incoming packets on a NETCONN_UDP */
+
+#define TCP_MSS (1500 - 40) /* TCP Maximum segment size, \
+                               TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
+
+#define TCP_SND_BUF (5 * TCP_MSS) /* TCP sender buffer space (bytes) */
+
+#define TCP_SND_QUEUELEN ((4 * TCP_SND_BUF) / TCP_MSS) /* TCP sender buffer space (pbufs), this must be at least \
+                                                        as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work */
+
+#define TCP_WND (2 * TCP_MSS) /* TCP receive window */
+
+/* ICMP options */
+#define LWIP_ICMP 1
+
+/* DHCP options */
+#define LWIP_DHCP 0 /* define to 1 if you want DHCP configuration of interfaces, \
+                       DHCP is not implemented in lwIP 0.5.1, however, so        \
+                       turning this on does currently not work. */
+
+#define LWIP_IPV4 1
+#define LWIP_IPV6 0
+
+/* UDP options */
+#define LWIP_UDP 1
+#define UDP_TTL  255
+
+/* statistics options */
+#define LWIP_STATS         0
+#define LWIP_PROVIDE_ERRNO 1
+
+/* checksum options */
+#define CHECKSUM_BY_HARDWARE   /* computing and verifying the IP, UDP, TCP and ICMP \
+                                 checksums by hardware */
+
+/* netconn options */
+#define LWIP_NETCONN 1 /* set to 1 to enable netconn API (require to use api_lib.c) */
+
+#define MEMP_NUM_NETCONN 4 /* the number of struct netconns */
+
+/* socket options */
+#define LWIP_SOCKET 1 /* set to 1 to enable socket API (require to use sockets.c) */
+
+#define LWIP_SO_RCVTIMEO 1 /* set to 1 to enable receive timeout for sockets/netconns and \
+                              SO_RCVTIMEO processing */
+#define LWIP_NETIF_LINK_CALLBACK 1
+/* Lwip debug options */
+#define LWIP_DEBUG 0
+
+#ifdef CHECKSUM_BY_HARDWARE
+/* CHECKSUM_GEN_IP==0: generate checksums by hardware for outgoing IP packets.*/
+#define CHECKSUM_GEN_IP 0
+/* CHECKSUM_GEN_UDP==0: generate checksums by hardware for outgoing UDP packets.*/
+#define CHECKSUM_GEN_UDP 0
+/* CHECKSUM_GEN_TCP==0: generate checksums by hardware for outgoing TCP packets.*/
+#define CHECKSUM_GEN_TCP 0
+/* CHECKSUM_CHECK_IP==0: check checksums by hardware for incoming IP packets.*/
+#define CHECKSUM_CHECK_IP 0
+/* CHECKSUM_CHECK_UDP==0: check checksums by hardware for incoming UDP packets.*/
+#define CHECKSUM_CHECK_UDP 0
+/* CHECKSUM_CHECK_TCP==0: check checksums by hardware for incoming TCP packets.*/
+#define CHECKSUM_CHECK_TCP 0
+#define CHECKSUM_GEN_ICMP  0
+#else
+/* CHECKSUM_GEN_IP==1: generate checksums in software for outgoing IP packets.*/
+#define CHECKSUM_GEN_IP    1
+/* CHECKSUM_GEN_UDP==1: generate checksums in software for outgoing UDP packets.*/
+#define CHECKSUM_GEN_UDP   1
+/* CHECKSUM_GEN_TCP==1: generate checksums in software for outgoing TCP packets.*/
+#define CHECKSUM_GEN_TCP   1
+/* CHECKSUM_CHECK_IP==1: check checksums in software for incoming IP packets.*/
+#define CHECKSUM_CHECK_IP  1
+/* CHECKSUM_CHECK_UDP==1: check checksums in software for incoming UDP packets.*/
+#define CHECKSUM_CHECK_UDP 1
+/* CHECKSUM_CHECK_TCP==1: check checksums in software for incoming TCP packets.*/
+#define CHECKSUM_CHECK_TCP 1
+#define CHECKSUM_GEN_ICMP  1
+#endif
+
+/*
+   ---------------------------------
+   ---------- OS options ----------
+   ---------------------------------
+*/
+#define TCPIP_THREAD_STACKSIZE   1000
+#define DEFAULT_THREAD_STACKSIZE 512
+#define LWIP_COMPAT_MUTEX        1
+#define TCPIP_THREAD_PRIO        5
+#define DEFAULT_THREAD_PRIO      2
+
+#endif /* LWIPOPTS_H */

+ 36 - 36
User/conf/lwip/port/arch/bpstruct.h → Project/conf/lwip/port/arch/bpstruct.h

@@ -1,36 +1,36 @@
-/*
- * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <[email protected]>
- *
- */
-
-#if defined(__IAR_SYSTEMS_ICC__)
-#pragma pack(1)
-#endif
-
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <[email protected]>
+ *
+ */
+
+#if defined(__IAR_SYSTEMS_ICC__)
+#pragma pack(1)
+#endif
+

+ 82 - 82
User/conf/lwip/port/arch/cc.h → Project/conf/lwip/port/arch/cc.h

@@ -1,82 +1,82 @@
-/*
- * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <[email protected]>
- *
- */
-#ifndef __CC_H__
-#define __CC_H__
-
-#include "cpu.h"
-#include <sys/time.h>
-
-#define U16_F "hu"
-#define S16_F "d"
-#define X16_F "hx"
-#define U32_F "u"
-#define S32_F "d"
-#define X32_F "x"
-#define SZT_F "uz"
-
-typedef int sys_prot_t;
-
-/* define compiler specific symbols */
-#if defined(__ICCARM__)
-
-#define PACK_STRUCT_BEGIN
-#define PACK_STRUCT_STRUCT
-#define PACK_STRUCT_END
-#define PACK_STRUCT_FIELD(x) x
-#define PACK_STRUCT_USE_INCLUDES
-
-#elif defined(__CC_ARM)
-
-#define PACK_STRUCT_BEGIN __packed
-#define PACK_STRUCT_STRUCT
-#define PACK_STRUCT_END
-#define PACK_STRUCT_FIELD(x) x
-
-#elif defined(__GNUC__)
-
-#define PACK_STRUCT_BEGIN
-#define PACK_STRUCT_STRUCT __attribute__((__packed__))
-#define PACK_STRUCT_END
-#define PACK_STRUCT_FIELD(x) x
-
-#elif defined(__TASKING__)
-
-#define PACK_STRUCT_BEGIN
-#define PACK_STRUCT_STRUCT
-#define PACK_STRUCT_END
-#define PACK_STRUCT_FIELD(x) x
-
-#endif
-
-#define LWIP_PLATFORM_ASSERT(x) // do { if(!(x)) while(1); } while(0)
-
-#endif /* __CC_H__ */
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <[email protected]>
+ *
+ */
+#ifndef __CC_H__
+#define __CC_H__
+
+#include "cpu.h"
+#include <sys/time.h>
+
+#define U16_F "hu"
+#define S16_F "d"
+#define X16_F "hx"
+#define U32_F "u"
+#define S32_F "d"
+#define X32_F "x"
+#define SZT_F "uz"
+
+typedef int sys_prot_t;
+
+/* define compiler specific symbols */
+#if defined(__ICCARM__)
+
+#define PACK_STRUCT_BEGIN
+#define PACK_STRUCT_STRUCT
+#define PACK_STRUCT_END
+#define PACK_STRUCT_FIELD(x) x
+#define PACK_STRUCT_USE_INCLUDES
+
+#elif defined(__CC_ARM)
+
+#define PACK_STRUCT_BEGIN __packed
+#define PACK_STRUCT_STRUCT
+#define PACK_STRUCT_END
+#define PACK_STRUCT_FIELD(x) x
+
+#elif defined(__GNUC__)
+
+#define PACK_STRUCT_BEGIN
+#define PACK_STRUCT_STRUCT __attribute__((__packed__))
+#define PACK_STRUCT_END
+#define PACK_STRUCT_FIELD(x) x
+
+#elif defined(__TASKING__)
+
+#define PACK_STRUCT_BEGIN
+#define PACK_STRUCT_STRUCT
+#define PACK_STRUCT_END
+#define PACK_STRUCT_FIELD(x) x
+
+#endif
+
+#define LWIP_PLATFORM_ASSERT(x) // do { if(!(x)) while(1); } while(0)
+
+#endif /* __CC_H__ */

+ 36 - 36
User/conf/lwip/port/arch/epstruct.h → Project/conf/lwip/port/arch/epstruct.h

@@ -1,36 +1,36 @@
-/*
- * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <[email protected]>
- *
- */
-
-#if defined(__IAR_SYSTEMS_ICC__)
-#pragma pack()
-#endif
-
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <[email protected]>
+ *
+ */
+
+#if defined(__IAR_SYSTEMS_ICC__)
+#pragma pack()
+#endif
+

+ 44 - 44
User/conf/lwip/port/arch/init.h → Project/conf/lwip/port/arch/init.h

@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <[email protected]>
- *
- */
-#ifndef __ARCH_INIT_H__
-#define __ARCH_INIT_H__
-
-#define TCPIP_INIT_DONE(arg)  tcpip_init_done(arg)
-
-void tcpip_init_done(void *);
-int wait_for_tcpip_init(void);
-
-#endif /* __ARCH_INIT_H__ */
-
-
-
-
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <[email protected]>
+ *
+ */
+#ifndef __ARCH_INIT_H__
+#define __ARCH_INIT_H__
+
+#define TCPIP_INIT_DONE(arg)  tcpip_init_done(arg)
+
+void tcpip_init_done(void *);
+int wait_for_tcpip_init(void);
+
+#endif /* __ARCH_INIT_H__ */
+
+
+
+

+ 38 - 38
User/conf/lwip/port/arch/lib.h → Project/conf/lwip/port/arch/lib.h

@@ -1,38 +1,38 @@
-/*
- * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <[email protected]>
- *
- */
-#ifndef __LIB_H__
-#define __LIB_H__
-
-#include <string.h>
-
-
-#endif /* __LIB_H__ */
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <[email protected]>
+ *
+ */
+#ifndef __LIB_H__
+#define __LIB_H__
+
+#include <string.h>
+
+
+#endif /* __LIB_H__ */

+ 37 - 37
User/conf/lwip/port/arch/lwip_cpu.h → Project/conf/lwip/port/arch/lwip_cpu.h

@@ -1,37 +1,37 @@
-/*
- * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <[email protected]>
- *
- */
-#ifndef __LWIP_CPU_H__
-#define __LWIP_CPU_H__
-
-#define BYTE_ORDER LITTLE_ENDIAN
-
-#endif /* __LWIP_CPU_H__ */
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <[email protected]>
+ *
+ */
+#ifndef __LWIP_CPU_H__
+#define __LWIP_CPU_H__
+
+#define BYTE_ORDER LITTLE_ENDIAN
+
+#endif /* __LWIP_CPU_H__ */

+ 38 - 38
User/conf/lwip/port/arch/perf.h → Project/conf/lwip/port/arch/perf.h

@@ -1,38 +1,38 @@
-/*
- * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * All rights reserved. 
- * 
- * Redistribution and use in source and binary forms, with or without modification, 
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- * 
- * Author: Adam Dunkels <[email protected]>
- *
- */
-#ifndef __PERF_H__
-#define __PERF_H__
-
-#define PERF_START    /* null definition */
-#define PERF_STOP(x)  /* null definition */
-
-#endif /* __PERF_H__ */
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved. 
+ * 
+ * Redistribution and use in source and binary forms, with or without modification, 
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <[email protected]>
+ *
+ */
+#ifndef __PERF_H__
+#define __PERF_H__
+
+#define PERF_START    /* null definition */
+#define PERF_STOP(x)  /* null definition */
+
+#endif /* __PERF_H__ */

+ 512 - 512
User/conf/lwip/port/arch/sys_arch.c → Project/conf/lwip/port/arch/sys_arch.c

@@ -1,512 +1,512 @@
-/*
- * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <[email protected]>
- *
- */
-/*  Porting by Michael Vysotsky <[email protected]> August 2011   */
-
-#define SYS_ARCH_GLOBALS
-
-/* lwIP includes. */
-#include "sys_arch.h"
-#include "lwip/debug.h"
-#include "lwip/def.h"
-#include "lwip/mem.h"
-#include "lwip/sys.h"
-#include "string.h"
-
-/*----------------------------------------------------------------------------*/
-/*                      VARIABLES                                             */
-/*----------------------------------------------------------------------------*/
-static OS_MEM *pQueueMem, *pStackMem;
-
-const void *const pvNullPointer = (mem_ptr_t *)0xffffffff;
-
-#if defined(__GNUC__) /*!< GCC compiler */
-__attribute__((aligned(4)))
-INT8U                              pcQueueMemoryPool[MAX_QUEUES * sizeof(TQ_DESCR)];
-__attribute__((aligned(4))) OS_STK LwIP_Task_Stk[LWIP_TASK_MAX * LWIP_STK_SIZE];
-
-#elif defined(__CC_ARM) /*!< ARM compiler */
-__align(4) INT8U pcQueueMemoryPool[MAX_QUEUES * sizeof(TQ_DESCR)];
-__align(4) OS_STK LwIP_Task_Stk[LWIP_TASK_MAX * LWIP_STK_SIZE];
-
-#elif defined(__ICCARM__) /*!< IAR compiler */
-#pragma data_alignment = 4
-INT8U  pcQueueMemoryPool[MAX_QUEUES * sizeof(TQ_DESCR)];
-#pragma data_alignment = 4
-OS_STK LwIP_Task_Stk[LWIP_TASK_MAX * LWIP_STK_SIZE];
-
-#endif /* __CC_ARM */
-
-INT8U LwIP_task_priopity_stask[LWIP_TASK_MAX];
-
-#define OS_MS_PER_TICK (1000 / OS_TICKS_PER_SEC)
-
-u32_t sys_now(void)
-{
-    return (OSTimeGet() * OS_MS_PER_TICK);
-}
-
-/*----------------------------------------------------------------------------*/
-/*                      PROTOTYPES                                            */
-/*----------------------------------------------------------------------------*/
-/*--------------------Creates an empty mailbox.-------------------------------*/
-
-err_t sys_mbox_new(sys_mbox_t *mbox, int size)
-{
-    /* prarmeter "size" can be ignored in your implementation. */
-    u8_t     ucErr;
-    PQ_DESCR pQDesc;
-    pQDesc = OSMemGet(pQueueMem, &ucErr);
-
-    LWIP_ASSERT("OSMemGet ", ucErr == OS_ERR_NONE);
-    if (ucErr == OS_ERR_NONE)
-    {
-        if (size > MAX_QUEUE_ENTRIES)
-        {
-            size = MAX_QUEUE_ENTRIES;
-        }
-        pQDesc->pQ = OSQCreate(&(pQDesc->pvQEntries[0]), size);
-        LWIP_ASSERT("OSQCreate ", pQDesc->pQ != NULL);
-
-        if (pQDesc->pQ != NULL)
-        {
-            *mbox = pQDesc;
-            return 0;
-        }
-        else
-        {
-            ucErr = OSMemPut(pQueueMem, pQDesc);
-            *mbox = NULL;
-            return ucErr;
-        }
-    }
-    else
-    {
-        return -1;
-    }
-}
-
-/*-----------------------------------------------------------------------------------*/
-/*
-  Deallocates a mailbox. If there are messages still present in the
-  mailbox when the mailbox is deallocated, it is an indication of a
-  programming error in lwIP and the developer should be notified.
-*/
-void sys_mbox_free(sys_mbox_t *mbox)
-{
-    u8_t       ucErr;
-    sys_mbox_t m_box = *mbox;
-    LWIP_ASSERT("sys_mbox_free ", m_box != SYS_MBOX_NULL);
-
-    OSQFlush(m_box->pQ);
-
-    (void)OSQDel(m_box->pQ, OS_DEL_NO_PEND, &ucErr);
-    LWIP_ASSERT("OSQDel ", ucErr == OS_ERR_NONE);
-
-    ucErr = OSMemPut(pQueueMem, m_box);
-    LWIP_ASSERT("OSMemPut ", ucErr == OS_ERR_NONE);
-    *mbox = NULL;
-}
-
-/*-----------------------------------------------------------------------------------*/
-//   Posts the "msg" to the mailbox.
-void sys_mbox_post(sys_mbox_t *mbox, void *msg)
-{
-    u8_t       i     = 0;
-    sys_mbox_t m_box = *mbox;
-    if (msg == NULL)
-        msg = (void *)&pvNullPointer;
-    /* try 10 times */
-    while ((i < 10) && ((OSQPost(m_box->pQ, msg)) != OS_ERR_NONE))
-    {
-        i++;
-        OSTimeDly(5);
-    }
-    LWIP_ASSERT("sys_mbox_post error!\n", i != 10);
-}
-
-/* Try to post the "msg" to the mailbox. */
-err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
-{
-    sys_mbox_t m_box = *mbox;
-    if (msg == NULL)
-        msg = (void *)&pvNullPointer;
-
-    if ((OSQPost(m_box->pQ, msg)) != OS_ERR_NONE)
-    {
-        return ERR_MEM;
-    }
-    return ERR_OK;
-}
-
-/*-----------------------------------------------------------------------------------*/
-/*
-  Blocks the thread until a message arrives in the mailbox, but does
-  not block the thread longer than "timeout" milliseconds (similar to
-  the sys_arch_sem_wait() function). The "msg" argument is a result
-  parameter that is set by the function (i.e., by doing "*msg =
-  ptr"). The "msg" parameter maybe NULL to indicate that the message
-  should be dropped.
-
-  The return values are the same as for the sys_arch_sem_wait() function:
-  Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a
-  timeout.
-
-  Note that a function with a similar name, sys_mbox_fetch(), is
-  implemented by lwIP.
-*/
-u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
-{
-    u8_t       ucErr;
-    u32_t      ucos_timeout, timeout_new;
-    void      *temp;
-    sys_mbox_t m_box = *mbox;
-    /* convert to timetick */
-    if (timeout != 0)
-    {
-        ucos_timeout = (timeout * OS_TICKS_PER_SEC) / 1000;
-        if (ucos_timeout < 1)
-        {
-            ucos_timeout = 1;
-        }
-        else if (ucos_timeout > 65535) /* ucOS only support u16_t timeout */
-        {
-            ucos_timeout = 65535;
-        }
-    }
-    else
-        ucos_timeout = 0;
-
-    timeout = OSTimeGet();
-
-    temp = OSQPend(m_box->pQ, (u16_t)ucos_timeout, &ucErr);
-
-    if (msg != NULL)
-    {
-        if (temp == (void *)&pvNullPointer)
-            *msg = NULL;
-        else
-            *msg = temp;
-    }
-
-    if (ucErr == OS_ERR_TIMEOUT)
-        timeout = SYS_ARCH_TIMEOUT;
-    else
-    {
-        LWIP_ASSERT("OSQPend ", ucErr == OS_ERR_NONE);
-
-        timeout_new = OSTimeGet();
-        if (timeout_new > timeout)
-            timeout_new = timeout_new - timeout;
-        else
-            timeout_new = 0xffffffff - timeout + timeout_new;
-        /* convert to millisecond */
-        timeout = timeout_new * 1000 / OS_TICKS_PER_SEC + 1;
-    }
-    return timeout;
-}
-/**
- * Check if an mbox is valid/allocated:
- * @param sys_mbox_t *mbox pointer mail box
- * @return 1 for valid, 0 for invalid
- */
-int sys_mbox_valid(sys_mbox_t *mbox)
-{
-    sys_mbox_t m_box = *mbox;
-    u8_t       ucErr;
-    int        ret;
-    OS_Q_DATA  q_data;
-    memset(&q_data, 0, sizeof(OS_Q_DATA));
-    ucErr = OSQQuery(m_box->pQ, &q_data);
-    ret   = (ucErr < 2 && (q_data.OSNMsgs < q_data.OSQSize)) ? 1 : 0;
-    return ret;
-}
-/**
- * Set an mbox invalid so that sys_mbox_valid returns 0
- */
-void sys_mbox_set_invalid(sys_mbox_t *mbox) {}
-/*
- *  Creates and returns a new semaphore. The "count" argument specifies
- *  the initial state of the semaphore. TBD finish and test
- */
-
-err_t sys_sem_new(sys_sem_t *sem, u8_t count)
-{
-    u8_t err;
-
-    *sem = OSSemCreate((u16_t)count);
-    if (*sem == NULL)
-    {
-        return -1;
-    }
-
-    OSEventNameSet(*sem, "LWIP Sem", &err);
-    LWIP_ASSERT("OSSemCreate ", *sem != NULL);
-    return 0;
-}
-/*
-  Blocks the thread while waiting for the semaphore to be
-  signaled. If the "timeout" argument is non-zero, the thread should
-  only be blocked for the specified time (measured in
-  milliseconds).
-
-  If the timeout argument is non-zero, the return value is the number of
-  milliseconds spent waiting for the semaphore to be signaled. If the
-  semaphore wasn't signaled within the specified time, the return value is
-  SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
-  (i.e., it was already signaled), the function may return zero.
-
-  Notice that lwIP implements a function with a similar name,
-  sys_sem_wait(), that uses the sys_arch_sem_wait() function.
-*/
-u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
-{
-    u8_t  ucErr;
-    u32_t ucos_timeout, timeout_new;
-
-    if (timeout != 0)
-    {
-        ucos_timeout =
-            (timeout * OS_TICKS_PER_SEC) / 1000; // convert to timetick
-        if (ucos_timeout < 1)
-        {
-            ucos_timeout = 1;
-        }
-        else if (ucos_timeout > 65536) /* uC/OS only support u16_t pend */
-        {
-            ucos_timeout = 65535;
-        }
-    }
-    else
-        ucos_timeout = 0;
-
-    timeout = OSTimeGet();
-
-    OSSemPend(*sem, (u16_t)ucos_timeout, (u8_t *)&ucErr);
-    /*  only when timeout! */
-    if (ucErr == OS_ERR_TIMEOUT)
-        timeout = SYS_ARCH_TIMEOUT;
-    else
-    {
-
-        /* for pbuf_free, may be called from an ISR */
-        timeout_new = OSTimeGet();
-        if (timeout_new >= timeout)
-            timeout_new = timeout_new - timeout;
-        else
-            timeout_new = 0xffffffff - timeout + timeout_new;
-        /* convert to milisecond */
-        timeout = (timeout_new * 1000 / OS_TICKS_PER_SEC + 1);
-    }
-    return timeout;
-}
-
-/*
- *       Signals a semaphore
- */
-
-void sys_sem_signal(sys_sem_t *sem) { OSSemPost(*sem); }
-
-/*
- *      Deallocates a semaphore
- */
-void sys_sem_free(sys_sem_t *sem)
-{
-    u8_t ucErr;
-    (void)OSSemDel(*sem, OS_DEL_ALWAYS, &ucErr);
-    LWIP_ASSERT("OSSemDel ", ucErr == OS_ERR_NONE);
-    *sem = NULL;
-}
-int sys_sem_valid(sys_sem_t *sem)
-{
-    OS_SEM_DATA sem_data;
-    return (OSSemQuery(*sem, &sem_data) == OS_ERR_NONE) ? 1 : 0;
-}
-
-/** Set a semaphore invalid so that sys_sem_valid returns 0 */
-void sys_sem_set_invalid(sys_sem_t *sem) {}
-
-/*
- * Initialize sys arch
- */
-void sys_init(void)
-{
-    u8_t ucErr;
-    memset(LwIP_task_priopity_stask, 0, sizeof(LwIP_task_priopity_stask));
-    /* init mem used by sys_mbox_t, use ucosII functions */
-    pQueueMem = OSMemCreate((void *)pcQueueMemoryPool, MAX_QUEUES,
-                            sizeof(TQ_DESCR), &ucErr);
-    OSMemNameSet(pQueueMem, "LWIP mem", &ucErr);
-    LWIP_ASSERT("sys_init: failed OSMemCreate Q", ucErr == OS_ERR_NONE);
-    pStackMem = OSMemCreate((void *)LwIP_Task_Stk, LWIP_TASK_MAX,
-                            LWIP_STK_SIZE * sizeof(OS_STK), &ucErr);
-    OSMemNameSet(pQueueMem, "LWIP TASK STK", &ucErr);
-    LWIP_ASSERT("sys_init: failed OSMemCreate STK", ucErr == OS_ERR_NONE);
-}
-
-/*-----------------------------------------------------------------------------------*/
-/*-----------------------------------------------------------------------------------*/
-// TBD
-/*-----------------------------------------------------------------------------------*/
-/*
-  Starts a new thread with priority "prio" that will begin its execution in the
-  function "thread()". The "arg" argument will be passed as an argument to the
-  thread() function. The id of the new thread is returned. Both the id and
-  the priority are system dependent.
-*/
-sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg,
-                            int stacksize, int prio)
-{
-    u8_t    ubPrio = LWIP_TASK_START_PRIO;
-    u8_t    ucErr;
-    int     i;
-    OS_STK *task_stk;
-    INT16U  task_id;
-
-    arg = arg;
-
-    if (prio)
-    {
-        ubPrio += (prio - 1);
-        for (i = 0; i < LWIP_TASK_MAX; ++i)
-        {
-            if (LwIP_task_priopity_stask[i] == ubPrio)
-                break;
-        }
-
-        if (i == LWIP_TASK_MAX)
-        {
-            for (i = 0; i < LWIP_TASK_MAX; ++i)
-            {
-                if (LwIP_task_priopity_stask[i] == 0)
-                {
-                    LwIP_task_priopity_stask[i] = ubPrio;
-                    break;
-                }
-            }
-            if (i == LWIP_TASK_MAX)
-            {
-                LWIP_ASSERT("sys_thread_new: there is no space for priority",
-                            0);
-                return (-1);
-            }
-        }
-        else
-        {
-            prio = 0;
-        }
-    }
-    else
-    {
-        LWIP_ASSERT("priority is invalid \r\n", 0);
-        return (-1);
-    }
-    /* Search for a suitable priority */
-    if (!prio)
-    {
-        ubPrio = LWIP_TASK_START_PRIO;
-        while (ubPrio < (LWIP_TASK_START_PRIO + LWIP_TASK_MAX))
-        {
-            for (i = 0; i < LWIP_TASK_MAX; ++i)
-                if (LwIP_task_priopity_stask[i] == ubPrio)
-                {
-                    ++ubPrio;
-                    break;
-                }
-            if (i == LWIP_TASK_MAX)
-                break;
-        }
-        if (ubPrio < (LWIP_TASK_START_PRIO + LWIP_TASK_MAX))
-            for (i = 0; i < LWIP_TASK_MAX; ++i)
-                if (LwIP_task_priopity_stask[i] == 0)
-                {
-                    LwIP_task_priopity_stask[i] = ubPrio;
-                    break;
-                }
-        if (ubPrio >= (LWIP_TASK_START_PRIO + LWIP_TASK_MAX) ||
-            i == LWIP_TASK_MAX)
-        {
-            LWIP_ASSERT("sys_thread_new: there is no free priority", 0);
-            return (-1);
-        }
-    }
-    if (stacksize > LWIP_STK_SIZE || !stacksize)
-        stacksize = LWIP_STK_SIZE;
-    /* get Stack from pool */
-    task_stk = OSMemGet(pStackMem, &ucErr);
-    if (ucErr != OS_ERR_NONE)
-    {
-        LWIP_ASSERT("sys_thread_new: impossible to get a stack", 0);
-        return (-1);
-    }
-    task_id = ubPrio - LWIP_TASK_START_PRIO + 4; // LWIP_TSK_ID;
-#if (OS_TASK_STAT_EN == 0)
-    OSTaskCreate(thread, (void *)arg, &task_stk[stacksize - 1], ubPrio);
-#else
-    OSTaskCreateExt(thread, (void *)arg, &task_stk[stacksize - 1], ubPrio,
-                    task_id, &task_stk[0], stacksize, (void *)0,
-                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR |
-                        OS_TASK_OPT_SAVE_FP);
-#endif
-    OSTaskNameSet(ubPrio, (u8_t *)name, &ucErr);
-
-    return ubPrio;
-}
-
-/*
-  This optional function does a "fast" critical region protection and returns
-  the previous protection level. This function is only called during very short
-  critical regions. An embedded system which supports ISR-based drivers might
-  want to implement this function by disabling interrupts. Task-based systems
-  might want to implement this by using a mutex or disabling tasking. This
-  function should support recursive calls from the same task or interrupt. In
-  other words, sys_arch_protect() could be called while already protected. In
-  that case the return value indicates that it is already protected.
-
-  sys_arch_protect() is only required if your port is supporting an operating
-  system.
-*/
-sys_prot_t sys_arch_protect(void)
-{
-    sys_prot_t cpu_sr;
-
-    cpu_sr = CPU_SR_Save();
-
-    return cpu_sr;
-}
-
-/*
-  This optional function does a "fast" set of critical region protection to the
-  value specified by pval. See the documentation for sys_arch_protect() for
-  more information. This function is only required if your port is supporting
-  an operating system.
-*/
-void sys_arch_unprotect(sys_prot_t pval) { CPU_SR_Restore(pval); }
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+ * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <[email protected]>
+ *
+ */
+/*  Porting by Michael Vysotsky <[email protected]> August 2011   */
+
+#define SYS_ARCH_GLOBALS
+
+/* lwIP includes. */
+#include "sys_arch.h"
+#include "lwip/debug.h"
+#include "lwip/def.h"
+#include "lwip/mem.h"
+#include "lwip/sys.h"
+#include "string.h"
+
+/*----------------------------------------------------------------------------*/
+/*                      VARIABLES                                             */
+/*----------------------------------------------------------------------------*/
+static OS_MEM *pQueueMem, *pStackMem;
+
+const void *const pvNullPointer = (mem_ptr_t *)0xffffffff;
+
+#if defined(__GNUC__) /*!< GCC compiler */
+__attribute__((aligned(4)))
+INT8U                              pcQueueMemoryPool[MAX_QUEUES * sizeof(TQ_DESCR)];
+__attribute__((aligned(4))) OS_STK LwIP_Task_Stk[LWIP_TASK_MAX * LWIP_STK_SIZE];
+
+#elif defined(__CC_ARM) /*!< ARM compiler */
+__align(4) INT8U pcQueueMemoryPool[MAX_QUEUES * sizeof(TQ_DESCR)];
+__align(4) OS_STK LwIP_Task_Stk[LWIP_TASK_MAX * LWIP_STK_SIZE];
+
+#elif defined(__ICCARM__) /*!< IAR compiler */
+#pragma data_alignment = 4
+INT8U  pcQueueMemoryPool[MAX_QUEUES * sizeof(TQ_DESCR)];
+#pragma data_alignment = 4
+OS_STK LwIP_Task_Stk[LWIP_TASK_MAX * LWIP_STK_SIZE];
+
+#endif /* __CC_ARM */
+
+INT8U LwIP_task_priopity_stask[LWIP_TASK_MAX];
+
+#define OS_MS_PER_TICK (1000 / OS_TICKS_PER_SEC)
+
+u32_t sys_now(void)
+{
+    return (OSTimeGet() * OS_MS_PER_TICK);
+}
+
+/*----------------------------------------------------------------------------*/
+/*                      PROTOTYPES                                            */
+/*----------------------------------------------------------------------------*/
+/*--------------------Creates an empty mailbox.-------------------------------*/
+
+err_t sys_mbox_new(sys_mbox_t *mbox, int size)
+{
+    /* prarmeter "size" can be ignored in your implementation. */
+    u8_t     ucErr;
+    PQ_DESCR pQDesc;
+    pQDesc = OSMemGet(pQueueMem, &ucErr);
+
+    LWIP_ASSERT("OSMemGet ", ucErr == OS_ERR_NONE);
+    if (ucErr == OS_ERR_NONE)
+    {
+        if (size > MAX_QUEUE_ENTRIES)
+        {
+            size = MAX_QUEUE_ENTRIES;
+        }
+        pQDesc->pQ = OSQCreate(&(pQDesc->pvQEntries[0]), size);
+        LWIP_ASSERT("OSQCreate ", pQDesc->pQ != NULL);
+
+        if (pQDesc->pQ != NULL)
+        {
+            *mbox = pQDesc;
+            return 0;
+        }
+        else
+        {
+            ucErr = OSMemPut(pQueueMem, pQDesc);
+            *mbox = NULL;
+            return ucErr;
+        }
+    }
+    else
+    {
+        return -1;
+    }
+}
+
+/*-----------------------------------------------------------------------------------*/
+/*
+  Deallocates a mailbox. If there are messages still present in the
+  mailbox when the mailbox is deallocated, it is an indication of a
+  programming error in lwIP and the developer should be notified.
+*/
+void sys_mbox_free(sys_mbox_t *mbox)
+{
+    u8_t       ucErr;
+    sys_mbox_t m_box = *mbox;
+    LWIP_ASSERT("sys_mbox_free ", m_box != SYS_MBOX_NULL);
+
+    OSQFlush(m_box->pQ);
+
+    (void)OSQDel(m_box->pQ, OS_DEL_NO_PEND, &ucErr);
+    LWIP_ASSERT("OSQDel ", ucErr == OS_ERR_NONE);
+
+    ucErr = OSMemPut(pQueueMem, m_box);
+    LWIP_ASSERT("OSMemPut ", ucErr == OS_ERR_NONE);
+    *mbox = NULL;
+}
+
+/*-----------------------------------------------------------------------------------*/
+//   Posts the "msg" to the mailbox.
+void sys_mbox_post(sys_mbox_t *mbox, void *msg)
+{
+    u8_t       i     = 0;
+    sys_mbox_t m_box = *mbox;
+    if (msg == NULL)
+        msg = (void *)&pvNullPointer;
+    /* try 10 times */
+    while ((i < 10) && ((OSQPost(m_box->pQ, msg)) != OS_ERR_NONE))
+    {
+        i++;
+        OSTimeDly(5);
+    }
+    LWIP_ASSERT("sys_mbox_post error!\n", i != 10);
+}
+
+/* Try to post the "msg" to the mailbox. */
+err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
+{
+    sys_mbox_t m_box = *mbox;
+    if (msg == NULL)
+        msg = (void *)&pvNullPointer;
+
+    if ((OSQPost(m_box->pQ, msg)) != OS_ERR_NONE)
+    {
+        return ERR_MEM;
+    }
+    return ERR_OK;
+}
+
+/*-----------------------------------------------------------------------------------*/
+/*
+  Blocks the thread until a message arrives in the mailbox, but does
+  not block the thread longer than "timeout" milliseconds (similar to
+  the sys_arch_sem_wait() function). The "msg" argument is a result
+  parameter that is set by the function (i.e., by doing "*msg =
+  ptr"). The "msg" parameter maybe NULL to indicate that the message
+  should be dropped.
+
+  The return values are the same as for the sys_arch_sem_wait() function:
+  Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a
+  timeout.
+
+  Note that a function with a similar name, sys_mbox_fetch(), is
+  implemented by lwIP.
+*/
+u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
+{
+    u8_t       ucErr;
+    u32_t      ucos_timeout, timeout_new;
+    void      *temp;
+    sys_mbox_t m_box = *mbox;
+    /* convert to timetick */
+    if (timeout != 0)
+    {
+        ucos_timeout = (timeout * OS_TICKS_PER_SEC) / 1000;
+        if (ucos_timeout < 1)
+        {
+            ucos_timeout = 1;
+        }
+        else if (ucos_timeout > 65535) /* ucOS only support u16_t timeout */
+        {
+            ucos_timeout = 65535;
+        }
+    }
+    else
+        ucos_timeout = 0;
+
+    timeout = OSTimeGet();
+
+    temp = OSQPend(m_box->pQ, (u16_t)ucos_timeout, &ucErr);
+
+    if (msg != NULL)
+    {
+        if (temp == (void *)&pvNullPointer)
+            *msg = NULL;
+        else
+            *msg = temp;
+    }
+
+    if (ucErr == OS_ERR_TIMEOUT)
+        timeout = SYS_ARCH_TIMEOUT;
+    else
+    {
+        LWIP_ASSERT("OSQPend ", ucErr == OS_ERR_NONE);
+
+        timeout_new = OSTimeGet();
+        if (timeout_new > timeout)
+            timeout_new = timeout_new - timeout;
+        else
+            timeout_new = 0xffffffff - timeout + timeout_new;
+        /* convert to millisecond */
+        timeout = timeout_new * 1000 / OS_TICKS_PER_SEC + 1;
+    }
+    return timeout;
+}
+/**
+ * Check if an mbox is valid/allocated:
+ * @param sys_mbox_t *mbox pointer mail box
+ * @return 1 for valid, 0 for invalid
+ */
+int sys_mbox_valid(sys_mbox_t *mbox)
+{
+    sys_mbox_t m_box = *mbox;
+    u8_t       ucErr;
+    int        ret;
+    OS_Q_DATA  q_data;
+    memset(&q_data, 0, sizeof(OS_Q_DATA));
+    ucErr = OSQQuery(m_box->pQ, &q_data);
+    ret   = (ucErr < 2 && (q_data.OSNMsgs < q_data.OSQSize)) ? 1 : 0;
+    return ret;
+}
+/**
+ * Set an mbox invalid so that sys_mbox_valid returns 0
+ */
+void sys_mbox_set_invalid(sys_mbox_t *mbox) {}
+/*
+ *  Creates and returns a new semaphore. The "count" argument specifies
+ *  the initial state of the semaphore. TBD finish and test
+ */
+
+err_t sys_sem_new(sys_sem_t *sem, u8_t count)
+{
+    u8_t err;
+
+    *sem = OSSemCreate((u16_t)count);
+    if (*sem == NULL)
+    {
+        return -1;
+    }
+
+    OSEventNameSet(*sem, "LWIP Sem", &err);
+    LWIP_ASSERT("OSSemCreate ", *sem != NULL);
+    return 0;
+}
+/*
+  Blocks the thread while waiting for the semaphore to be
+  signaled. If the "timeout" argument is non-zero, the thread should
+  only be blocked for the specified time (measured in
+  milliseconds).
+
+  If the timeout argument is non-zero, the return value is the number of
+  milliseconds spent waiting for the semaphore to be signaled. If the
+  semaphore wasn't signaled within the specified time, the return value is
+  SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
+  (i.e., it was already signaled), the function may return zero.
+
+  Notice that lwIP implements a function with a similar name,
+  sys_sem_wait(), that uses the sys_arch_sem_wait() function.
+*/
+u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
+{
+    u8_t  ucErr;
+    u32_t ucos_timeout, timeout_new;
+
+    if (timeout != 0)
+    {
+        ucos_timeout =
+            (timeout * OS_TICKS_PER_SEC) / 1000; // convert to timetick
+        if (ucos_timeout < 1)
+        {
+            ucos_timeout = 1;
+        }
+        else if (ucos_timeout > 65536) /* uC/OS only support u16_t pend */
+        {
+            ucos_timeout = 65535;
+        }
+    }
+    else
+        ucos_timeout = 0;
+
+    timeout = OSTimeGet();
+
+    OSSemPend(*sem, (u16_t)ucos_timeout, (u8_t *)&ucErr);
+    /*  only when timeout! */
+    if (ucErr == OS_ERR_TIMEOUT)
+        timeout = SYS_ARCH_TIMEOUT;
+    else
+    {
+
+        /* for pbuf_free, may be called from an ISR */
+        timeout_new = OSTimeGet();
+        if (timeout_new >= timeout)
+            timeout_new = timeout_new - timeout;
+        else
+            timeout_new = 0xffffffff - timeout + timeout_new;
+        /* convert to milisecond */
+        timeout = (timeout_new * 1000 / OS_TICKS_PER_SEC + 1);
+    }
+    return timeout;
+}
+
+/*
+ *       Signals a semaphore
+ */
+
+void sys_sem_signal(sys_sem_t *sem) { OSSemPost(*sem); }
+
+/*
+ *      Deallocates a semaphore
+ */
+void sys_sem_free(sys_sem_t *sem)
+{
+    u8_t ucErr;
+    (void)OSSemDel(*sem, OS_DEL_ALWAYS, &ucErr);
+    LWIP_ASSERT("OSSemDel ", ucErr == OS_ERR_NONE);
+    *sem = NULL;
+}
+int sys_sem_valid(sys_sem_t *sem)
+{
+    OS_SEM_DATA sem_data;
+    return (OSSemQuery(*sem, &sem_data) == OS_ERR_NONE) ? 1 : 0;
+}
+
+/** Set a semaphore invalid so that sys_sem_valid returns 0 */
+void sys_sem_set_invalid(sys_sem_t *sem) {}
+
+/*
+ * Initialize sys arch
+ */
+void sys_init(void)
+{
+    u8_t ucErr;
+    memset(LwIP_task_priopity_stask, 0, sizeof(LwIP_task_priopity_stask));
+    /* init mem used by sys_mbox_t, use ucosII functions */
+    pQueueMem = OSMemCreate((void *)pcQueueMemoryPool, MAX_QUEUES,
+                            sizeof(TQ_DESCR), &ucErr);
+    OSMemNameSet(pQueueMem, "LWIP mem", &ucErr);
+    LWIP_ASSERT("sys_init: failed OSMemCreate Q", ucErr == OS_ERR_NONE);
+    pStackMem = OSMemCreate((void *)LwIP_Task_Stk, LWIP_TASK_MAX,
+                            LWIP_STK_SIZE * sizeof(OS_STK), &ucErr);
+    OSMemNameSet(pQueueMem, "LWIP TASK STK", &ucErr);
+    LWIP_ASSERT("sys_init: failed OSMemCreate STK", ucErr == OS_ERR_NONE);
+}
+
+/*-----------------------------------------------------------------------------------*/
+/*-----------------------------------------------------------------------------------*/
+// TBD
+/*-----------------------------------------------------------------------------------*/
+/*
+  Starts a new thread with priority "prio" that will begin its execution in the
+  function "thread()". The "arg" argument will be passed as an argument to the
+  thread() function. The id of the new thread is returned. Both the id and
+  the priority are system dependent.
+*/
+sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg,
+                            int stacksize, int prio)
+{
+    u8_t    ubPrio = LWIP_TASK_START_PRIO;
+    u8_t    ucErr;
+    int     i;
+    OS_STK *task_stk;
+    INT16U  task_id;
+
+    arg = arg;
+
+    if (prio)
+    {
+        ubPrio += (prio - 1);
+        for (i = 0; i < LWIP_TASK_MAX; ++i)
+        {
+            if (LwIP_task_priopity_stask[i] == ubPrio)
+                break;
+        }
+
+        if (i == LWIP_TASK_MAX)
+        {
+            for (i = 0; i < LWIP_TASK_MAX; ++i)
+            {
+                if (LwIP_task_priopity_stask[i] == 0)
+                {
+                    LwIP_task_priopity_stask[i] = ubPrio;
+                    break;
+                }
+            }
+            if (i == LWIP_TASK_MAX)
+            {
+                LWIP_ASSERT("sys_thread_new: there is no space for priority",
+                            0);
+                return (-1);
+            }
+        }
+        else
+        {
+            prio = 0;
+        }
+    }
+    else
+    {
+        LWIP_ASSERT("priority is invalid \r\n", 0);
+        return (-1);
+    }
+    /* Search for a suitable priority */
+    if (!prio)
+    {
+        ubPrio = LWIP_TASK_START_PRIO;
+        while (ubPrio < (LWIP_TASK_START_PRIO + LWIP_TASK_MAX))
+        {
+            for (i = 0; i < LWIP_TASK_MAX; ++i)
+                if (LwIP_task_priopity_stask[i] == ubPrio)
+                {
+                    ++ubPrio;
+                    break;
+                }
+            if (i == LWIP_TASK_MAX)
+                break;
+        }
+        if (ubPrio < (LWIP_TASK_START_PRIO + LWIP_TASK_MAX))
+            for (i = 0; i < LWIP_TASK_MAX; ++i)
+                if (LwIP_task_priopity_stask[i] == 0)
+                {
+                    LwIP_task_priopity_stask[i] = ubPrio;
+                    break;
+                }
+        if (ubPrio >= (LWIP_TASK_START_PRIO + LWIP_TASK_MAX) ||
+            i == LWIP_TASK_MAX)
+        {
+            LWIP_ASSERT("sys_thread_new: there is no free priority", 0);
+            return (-1);
+        }
+    }
+    if (stacksize > LWIP_STK_SIZE || !stacksize)
+        stacksize = LWIP_STK_SIZE;
+    /* get Stack from pool */
+    task_stk = OSMemGet(pStackMem, &ucErr);
+    if (ucErr != OS_ERR_NONE)
+    {
+        LWIP_ASSERT("sys_thread_new: impossible to get a stack", 0);
+        return (-1);
+    }
+    task_id = ubPrio - LWIP_TASK_START_PRIO + 4; // LWIP_TSK_ID;
+#if (OS_TASK_STAT_EN == 0)
+    OSTaskCreate(thread, (void *)arg, &task_stk[stacksize - 1], ubPrio);
+#else
+    OSTaskCreateExt(thread, (void *)arg, &task_stk[stacksize - 1], ubPrio,
+                    task_id, &task_stk[0], stacksize, (void *)0,
+                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR |
+                        OS_TASK_OPT_SAVE_FP);
+#endif
+    OSTaskNameSet(ubPrio, (u8_t *)name, &ucErr);
+
+    return ubPrio;
+}
+
+/*
+  This optional function does a "fast" critical region protection and returns
+  the previous protection level. This function is only called during very short
+  critical regions. An embedded system which supports ISR-based drivers might
+  want to implement this function by disabling interrupts. Task-based systems
+  might want to implement this by using a mutex or disabling tasking. This
+  function should support recursive calls from the same task or interrupt. In
+  other words, sys_arch_protect() could be called while already protected. In
+  that case the return value indicates that it is already protected.
+
+  sys_arch_protect() is only required if your port is supporting an operating
+  system.
+*/
+sys_prot_t sys_arch_protect(void)
+{
+    sys_prot_t cpu_sr;
+
+    cpu_sr = CPU_SR_Save();
+
+    return cpu_sr;
+}
+
+/*
+  This optional function does a "fast" set of critical region protection to the
+  value specified by pval. See the documentation for sys_arch_protect() for
+  more information. This function is only required if your port is supporting
+  an operating system.
+*/
+void sys_arch_unprotect(sys_prot_t pval) { CPU_SR_Restore(pval); }

+ 77 - 77
User/conf/lwip/port/arch/sys_arch.h → Project/conf/lwip/port/arch/sys_arch.h

@@ -1,77 +1,77 @@
-/*
- * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <[email protected]>
- *
- */
-#ifndef __ARCH_SYS_ARCH_H__
-#define __ARCH_SYS_ARCH_H__
-
-#include "includes.h"
-#include "arch/cc.h"
-
-#ifdef SYS_ARCH_GLOBALS
-#define SYS_ARCH_EXT
-#else
-#define SYS_ARCH_EXT extern
-#endif
-
-#define MAX_QUEUES 10
-#define MAX_QUEUE_ENTRIES 20
-
-/*-----------------macros-----------------------------------------------------*/
-#define LWIP_STK_SIZE 1024
-#define LWIP_TASK_MAX 2
-/* The user can change this priority level.
- * It is important that there was no crossing with other levels.
- */
-#define LWIP_TSK_PRIO 2
-#define LWIP_TASK_START_PRIO LWIP_TSK_PRIO
-#define LWIP_TASK_END_PRIO LWIP_TSK_PRIO + LWIP_TASK_MAX
-
-#define SYS_MBOX_NULL (void *)0
-#define SYS_SEM_NULL (void *)0
-
-#define sys_arch_mbox_tryfetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 1)
-
-/*-----------------type define------------------------------------------------*/
-
-/** struct of LwIP mailbox */
-typedef struct
-{
-	OS_EVENT *pQ;
-	void *pvQEntries[MAX_QUEUE_ENTRIES];
-} TQ_DESCR, *PQ_DESCR;
-
-typedef OS_EVENT *sys_sem_t;	  // type of semiphores
-typedef PQ_DESCR sys_mbox_t;	  // type of mailboxes
-typedef signed char sys_thread_t; // type of id of the new thread
-
-#endif
-
-/* __SYS_RTXC_H__ */
+/*
+ * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <[email protected]>
+ *
+ */
+#ifndef __ARCH_SYS_ARCH_H__
+#define __ARCH_SYS_ARCH_H__
+
+#include "includes.h"
+#include "arch/cc.h"
+
+#ifdef SYS_ARCH_GLOBALS
+#define SYS_ARCH_EXT
+#else
+#define SYS_ARCH_EXT extern
+#endif
+
+#define MAX_QUEUES 10
+#define MAX_QUEUE_ENTRIES 20
+
+/*-----------------macros-----------------------------------------------------*/
+#define LWIP_STK_SIZE 1024
+#define LWIP_TASK_MAX 2
+/* The user can change this priority level.
+ * It is important that there was no crossing with other levels.
+ */
+#define LWIP_TSK_PRIO 2
+#define LWIP_TASK_START_PRIO LWIP_TSK_PRIO
+#define LWIP_TASK_END_PRIO LWIP_TSK_PRIO + LWIP_TASK_MAX
+
+#define SYS_MBOX_NULL (void *)0
+#define SYS_SEM_NULL (void *)0
+
+#define sys_arch_mbox_tryfetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 1)
+
+/*-----------------type define------------------------------------------------*/
+
+/** struct of LwIP mailbox */
+typedef struct
+{
+	OS_EVENT *pQ;
+	void *pvQEntries[MAX_QUEUE_ENTRIES];
+} TQ_DESCR, *PQ_DESCR;
+
+typedef OS_EVENT *sys_sem_t;	  // type of semiphores
+typedef PQ_DESCR sys_mbox_t;	  // type of mailboxes
+typedef signed char sys_thread_t; // type of id of the new thread
+
+#endif
+
+/* __SYS_RTXC_H__ */

+ 398 - 398
User/conf/lwip/port/ethernetif_dm9k.c → Project/conf/lwip/port/ethernetif_dm9k.c

@@ -1,398 +1,398 @@
-/* Includes ------------------------------------------------------------------*/
-#include "ethernetif_dm9k.h"
-#include "dm9k.h"
-#include "lwip/tcpip.h"
-#include "lwip/timeouts.h"
-#include "lwip_dm9k.h"
-#include "memory_manager.h"
-#include "netif/etharp.h"
-#include "netif/ethernet.h"
-// #include "snmp.h"
-#include "lwip_init.h"
-#include "string.h"
-
-#define DM9K_RX_TASK_PRIO     4
-#define DM9K_RX_TASK_STK_SIZE 2048
-CPU_STK dm9k_rx_task_stk[DM9K_RX_TASK_STK_SIZE];
-
-/* Define those to better describe your network interface. */
-#define IFNAME0 'D'
-#define IFNAME1 '2'
-
-#define DM9K_RX_DESC_CNT 4
-#define DM9K_RX_Lenth    1536UL
-
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-static uint8_t            *Rx_Buff[DM9K_RX_DESC_CNT]     = {0}; /* Ethernet Rx Buffer */
-uint8_t                    current_pbuf_idx              = 0;   /* Zero-copy RX PBUF pool */
-static struct pbuf_custom *custom_pbuf[DM9K_RX_DESC_CNT] = {0};
-/* Private function prototypes -----------------------------------------------*/
-static void pbuf_free_custom(struct pbuf *p);
-static void ethernetif_input(void *pvParameters);
-// static void ethernet_link_check_state(struct netif *netif);
-
-static OS_EVENT     *g_dm9k_rx_sem = NULL;
-static OS_EVENT     *dm9k_mutex    = NULL;
-static struct netif *low_netif     = NULL;
-/*
-*********************************************************************************************************
-*	函 数 名: VariableMemInit
-*	功能说明: 申请串口相关的变量内存
-*	形    参: 无
-*	返 回 值: 无
-*********************************************************************************************************
-*/
-static void VariableMemInit(void)
-{
-    uint16_t idx = 0;
-
-    for (idx = 0; idx < DM9K_RX_DESC_CNT; idx++)
-    {
-        if (Rx_Buff[idx] == 0)
-            Rx_Buff[idx] = pMemoryMalloc(&SRAM0, DM9K_RX_Lenth); // 因为不释放,避免重复申请
-        if (custom_pbuf[idx] == 0)
-            custom_pbuf[idx] = pMemoryMalloc(&SRAM0, sizeof(struct pbuf_custom)); // 因为不释放,避免重复申请
-    }
-}
-static void low_level_init(struct netif *netif)
-{
-    INT32U idx = 0;
-    VariableMemInit();
-    INT8U err;
-    /* set MAC hardware address length */
-    netif->hwaddr_len = ETHARP_HWADDR_LEN;
-
-    /* set MAC hardware address */ /* 网卡的 MAC 修改2 */
-    netif->hwaddr[0] = dm9kdev.mac[0];
-    netif->hwaddr[1] = dm9kdev.mac[1];
-    netif->hwaddr[2] = dm9kdev.mac[2];
-    netif->hwaddr[3] = dm9kdev.mac[3];
-    netif->hwaddr[4] = dm9kdev.mac[4];
-    netif->hwaddr[5] = dm9kdev.mac[5];
-
-    /* maximum transfer unit */
-    netif->mtu = 1500;
-
-    /* device capabilities */
-    /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
-    netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
-
-    low_netif = netif;
-
-    for (idx = 0; idx < DM9K_RX_DESC_CNT; idx++)
-    {
-        custom_pbuf[idx]->custom_free_function = pbuf_free_custom;
-    }
-
-    if (NULL == dm9k_mutex)
-    {
-        dm9k_mutex = OSMutexCreate(1, &err);
-    }
-
-    /* create binary semaphore used for informing ethernetif of frame reception */
-    if (NULL == g_dm9k_rx_sem)
-    {
-        g_dm9k_rx_sem = OSSemCreate(0);
-    }
-
-    OSTaskCreateExt((void (*)(void *))ethernetif_input,
-                    (void *)0,
-                    (OS_STK *)&dm9k_rx_task_stk[DM9K_RX_TASK_STK_SIZE - 1],
-                    (INT8U)DM9K_RX_TASK_PRIO,
-                    (INT16U)DM9K_RX_TASK_PRIO,
-                    (OS_STK *)&dm9k_rx_task_stk[0],
-                    (INT32U)DM9K_RX_TASK_STK_SIZE,
-                    (void *)0,
-                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
-    // ethernet_link_check_state(netif);
-}
-
-/**
- * @brief This function should do the actual transmission of the packet. The packet is
- * contained in the pbuf that is passed to the function. This pbuf
- * might be chained.
- *
- * @param netif the lwip network interface structure for this ethernetif
- * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
- * @return ERR_OK if the packet could be sent
- *         an err_t value if the packet couldn't be sent
- *
- * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
- *       strange results. You might consider waiting for space in the DMA queue
- *       to become available since the stack doesn't retry to send a packet
- *       dropped because of memory failure (except for the TCP timers).
- */
-static err_t low_level_output(struct netif *netif, struct pbuf *p)
-{
-
-    INT8U        err;
-    err_t        errval = ERR_OK;
-    uint32_t     i = 0, framelen = 0, calc_len = 0;
-    struct pbuf *q;
-
-    SYS_ARCH_DECL_PROTECT(sr);
-
-    OSMutexPend(dm9k_mutex, 1000, &err);
-    SYS_ARCH_PROTECT(sr);
-
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF); /* 关闭 dm9kA 中断 */
-
-    NET_REG_ADDR = DM9K_REG_MWCMD;
-
-    for (q = p; q != NULL; q = q->next)
-    {
-        framelen = framelen + q->len;
-        calc_len = (q->len + 1) >> 1;
-
-        for (i = 0; i < calc_len; i++)
-        {
-            NET_REG_DATA = ((uint16_t *)q->payload)[i];
-        }
-    }
-
-    dm9k_WriteReg(DM9K_REG_TXPLH, (framelen >> 8) & 0xff); /* 设置传送封包的长度 */
-    dm9k_WriteReg(DM9K_REG_TXPLL, framelen & 0xff);
-
-    dm9k_WriteReg(DM9K_REG_TCR, DM9K_TCR_SET); /* 进行传送 */
-
-    while ((dm9k_ReadReg(DM9K_REG_ISR) & 0x02) == 0)
-        ;                                      /* 等待发送完成	 */
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* 开启 dm9kA 中断 */
-
-    SYS_ARCH_UNPROTECT(sr);
-
-    OSMutexPost(dm9k_mutex);
-    return errval;
-}
-
-static struct pbuf *low_level_input(struct netif *netif)
-{
-    struct pbuf *p        = NULL;
-    uint32_t     framelen = 0;
-
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF); /* 关闭 DM9000A 中断 */
-    framelen = etherdev_read(Rx_Buff[current_pbuf_idx]);
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* 开启 DM9000A 中断 */
-    if (framelen)
-    {
-
-        // p = pbuf_alloc(PBUF_RAW, framelen, PBUF_POOL);
-        p = pbuf_alloced_custom(PBUF_RAW, framelen, PBUF_REF, custom_pbuf[current_pbuf_idx], Rx_Buff[current_pbuf_idx], Max_Ethernet_Lenth);
-        if (current_pbuf_idx < (DM9K_RX_DESC_CNT - 1))
-        {
-            current_pbuf_idx++;
-        }
-        else
-        {
-            current_pbuf_idx = 0;
-        }
-    }
-    return p;
-}
-
-#if 1
-void ethernetif_input(void *pvParameters)
-{
-    struct pbuf *p;
-    INT8U        err;
-
-    SYS_ARCH_DECL_PROTECT(sr);
-
-    for (;;)
-    {
-
-        OSSemPend(g_dm9k_rx_sem, 100, &err);
-
-TRY_GET_NEXT_FRAME:
-        SYS_ARCH_PROTECT(sr);
-        p = low_level_input(low_netif);
-        SYS_ARCH_UNPROTECT(sr);
-
-        if (p != NULL)
-        {
-            if (ERR_OK != low_netif->input(p, low_netif))
-            {
-                pbuf_free(p);
-            }
-            else
-            {
-                goto TRY_GET_NEXT_FRAME;
-            }
-        }
-    }
-}
-#else
-void ethernetif_input(void *argument)
-{
-    struct pbuf *p;
-    // struct netif *netif = (struct netif *)argument;
-    INT8U err;
-    for (;;)
-    {
-        OSSemPend(g_dm9k_rx_sem, 0, &err);
-        // if (err == OS)
-        // {
-        if (err == ERR_OK)
-        {
-            do
-            {
-                LOCK_TCPIP_CORE();
-
-                p = low_level_input(low_netif);
-                if (p != NULL)
-                {
-                    err = low_netif->input(p, low_netif);
-                    if (err != ERR_OK)
-                    {
-                        LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
-                        pbuf_free(p);
-                    }
-                }
-
-                UNLOCK_TCPIP_CORE();
-
-            } while (p != NULL);
-        }
-
-        // }
-    }
-}
-#endif
-err_t ethernetif_dm9k_init(struct netif *netif)
-{
-    LWIP_ASSERT("netif != NULL", (netif != NULL));
-
-#if LWIP_NETIF_HOSTNAME
-    /* Initialize interface hostname */
-    netif->hostname = "DM9000";
-#endif /* LWIP_NETIF_HOSTNAME */
-
-    /*
-     * Initialize the snmp variables and counters inside the struct netif.
-     * The last argument should be replaced with your link speed, in units
-     * of bits per second.
-     */
-    // MIB2_INIT_NETIF(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
-    netif->name[0] = IFNAME0;
-    netif->name[1] = IFNAME1;
-
-    /* We directly use etharp_output() here to save a function call.
-     * You can instead declare your own function an call etharp_output()
-     * from it if you have to do some checks before sending (e.g. if link
-     * is available...) */
-    netif->output     = etharp_output;
-    netif->linkoutput = low_level_output;
-
-    /* initialize the hardware */
-    low_level_init(netif);
-
-    return ERR_OK;
-}
-
-/**
- * @brief  Custom Rx pbuf free callback
- * @param  pbuf: pbuf to be freed
- * @retval None
- */
-static void pbuf_free_custom(struct pbuf *p)
-{
-    if (p != NULL)
-    {
-        memset(p, 0, sizeof(struct pbuf));
-    }
-}
-void dm9k_interrupt(void)
-{
-    uint8_t  save_reg;
-    uint16_t isr_status;
-
-    save_reg = NET_REG_ADDR; /* 暂存所使用的位置 */
-
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF); /* 关闭 DM9KA 中断 */
-    isr_status = dm9k_ReadReg(DM9K_REG_ISR);   /* 取得中断产生值 */
-    // isr_status = isr_status & DM9K_RX_INTR;
-    if (isr_status & DM9K_RX_INTR)
-    { /* 检查是否为接收中断 */
-        OSSemPost(g_dm9k_rx_sem);
-        // dm9k_receive_packet();							/* 执行接收处理程序 */
-    }
-
-    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* 开启 DM9KA 中断 */
-    NET_REG_ADDR = save_reg;                   /* 回复所使用的位置 */
-}
-
-/**
- * @brief  Ethernet Rx Transfer completed callback
- * @param  heth: ETH handle
- * @retval None
- */
-void BSP_GPIO15_EXTI_Callback(void)
-{
-    uint8_t save_reg;
-    uint8_t isr_status;
-
-    save_reg = NET_REG_ADDR; /* 暂存所使用的位置 */
-
-    isr_status = dm9k_ReadReg(DM9K_REG_ISR); /* 取得中断产生值 */
-    dm9k_WriteReg(DM9K_REG_ISR, isr_status); /* 清除中断产生值 */
-    // isr_status = isr_status & DM9K_RX_INTR;
-
-    if (isr_status & DM9K_RX_INTR) /* 检查是否为接收中断 */
-    {
-        OSSemPost(g_dm9k_rx_sem); /* 执行接收处理程序 */
-    }
-
-    NET_REG_ADDR = save_reg; /* 回复所使用的位置 */
-}
-
-//中断处理函数,注意不是中断服函数,需要在中断服务函数中调用
-void DMA9K_ISRHandler(void)
-{
-    u16 int_status;
-    u16 last_io;
-    last_io    = NET_REG_ADDR;
-    int_status = dm9k_ReadReg(DM9K_REG_ISR);
-    dm9k_WriteReg(DM9K_REG_ISR, int_status); //清除中断标志位
-
-    if (int_status & DM9K_RX_INTR) //接收中断
-    {
-        OSSemPost(g_dm9k_rx_sem);
-        //接收完成中断,用户自己添加代码
-    }
-    if (int_status & DM9K_TX_INTR) //发送中断
-    {
-        // OSSemPost(g_dm9k_tx_sem);
-        //发送完成中断,用户自己添加代码
-    }
-    NET_REG_ADDR = last_io;
-}
-
-void EXTI15_10_IRQHandler(void)
-{
-    OSIntEnter();
-    EXTI_ClearITPendingBit(EXTI_Line15); /* 清除中断标志位 */
-    if (EXTI_GetITStatus(EXTI_Line15) != RESET)
-    {
-        BSP_GPIO15_EXTI_Callback();
-    }
-    OSIntExit();
-}
-
-void ethernet_link_check_state(struct netif *netif)
-{
-    uint8_t linkchanged = 0;
-
-    linkchanged = dm9k_linkstat();
-
-    if (netif_is_link_up(netif) && (linkchanged == 0))
-    {
-        netif_set_down(netif);
-        netif_set_link_down(netif);
-    }
-    else if (!netif_is_link_up(netif) && (linkchanged == 1))
-    {
-        netif_set_up(netif);
-        netif_set_link_up(netif);
-    }
-}
+/* Includes ------------------------------------------------------------------*/
+#include "ethernetif_dm9k.h"
+#include "dm9k.h"
+#include "lwip/tcpip.h"
+#include "lwip/timeouts.h"
+#include "lwip_dm9k.h"
+#include "memory_manager.h"
+#include "netif/etharp.h"
+#include "netif/ethernet.h"
+// #include "snmp.h"
+#include "lwip_init.h"
+#include "string.h"
+
+#define DM9K_RX_TASK_PRIO     4
+#define DM9K_RX_TASK_STK_SIZE 2048
+CPU_STK dm9k_rx_task_stk[DM9K_RX_TASK_STK_SIZE];
+
+/* Define those to better describe your network interface. */
+#define IFNAME0 'D'
+#define IFNAME1 '2'
+
+#define DM9K_RX_DESC_CNT 4
+#define DM9K_RX_Lenth    1536UL
+
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+static uint8_t            *Rx_Buff[DM9K_RX_DESC_CNT]     = {0}; /* Ethernet Rx Buffer */
+uint8_t                    current_pbuf_idx              = 0;   /* Zero-copy RX PBUF pool */
+static struct pbuf_custom *custom_pbuf[DM9K_RX_DESC_CNT] = {0};
+/* Private function prototypes -----------------------------------------------*/
+static void pbuf_free_custom(struct pbuf *p);
+static void ethernetif_input(void *pvParameters);
+// static void ethernet_link_check_state(struct netif *netif);
+
+static OS_EVENT     *g_dm9k_rx_sem = NULL;
+static OS_EVENT     *dm9k_mutex    = NULL;
+static struct netif *low_netif     = NULL;
+/*
+*********************************************************************************************************
+*	函 数 名: VariableMemInit
+*	功能说明: 申请串口相关的变量内存
+*	形    参: 无
+*	返 回 值: 无
+*********************************************************************************************************
+*/
+static void VariableMemInit(void)
+{
+    uint16_t idx = 0;
+
+    for (idx = 0; idx < DM9K_RX_DESC_CNT; idx++)
+    {
+        if (Rx_Buff[idx] == 0)
+            Rx_Buff[idx] = pMemoryMalloc(&SRAM0, DM9K_RX_Lenth); // 因为不释放,避免重复申请
+        if (custom_pbuf[idx] == 0)
+            custom_pbuf[idx] = pMemoryMalloc(&SRAM0, sizeof(struct pbuf_custom)); // 因为不释放,避免重复申请
+    }
+}
+static void low_level_init(struct netif *netif)
+{
+    INT32U idx = 0;
+    VariableMemInit();
+    INT8U err;
+    /* set MAC hardware address length */
+    netif->hwaddr_len = ETHARP_HWADDR_LEN;
+
+    /* set MAC hardware address */ /* 网卡的 MAC 修改2 */
+    netif->hwaddr[0] = dm9kdev.mac[0];
+    netif->hwaddr[1] = dm9kdev.mac[1];
+    netif->hwaddr[2] = dm9kdev.mac[2];
+    netif->hwaddr[3] = dm9kdev.mac[3];
+    netif->hwaddr[4] = dm9kdev.mac[4];
+    netif->hwaddr[5] = dm9kdev.mac[5];
+
+    /* maximum transfer unit */
+    netif->mtu = 1500;
+
+    /* device capabilities */
+    /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
+    netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
+
+    low_netif = netif;
+
+    for (idx = 0; idx < DM9K_RX_DESC_CNT; idx++)
+    {
+        custom_pbuf[idx]->custom_free_function = pbuf_free_custom;
+    }
+
+    if (NULL == dm9k_mutex)
+    {
+        dm9k_mutex = OSMutexCreate(1, &err);
+    }
+
+    /* create binary semaphore used for informing ethernetif of frame reception */
+    if (NULL == g_dm9k_rx_sem)
+    {
+        g_dm9k_rx_sem = OSSemCreate(0);
+    }
+
+    OSTaskCreateExt((void (*)(void *))ethernetif_input,
+                    (void *)0,
+                    (OS_STK *)&dm9k_rx_task_stk[DM9K_RX_TASK_STK_SIZE - 1],
+                    (INT8U)DM9K_RX_TASK_PRIO,
+                    (INT16U)DM9K_RX_TASK_PRIO,
+                    (OS_STK *)&dm9k_rx_task_stk[0],
+                    (INT32U)DM9K_RX_TASK_STK_SIZE,
+                    (void *)0,
+                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
+    // ethernet_link_check_state(netif);
+}
+
+/**
+ * @brief This function should do the actual transmission of the packet. The packet is
+ * contained in the pbuf that is passed to the function. This pbuf
+ * might be chained.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
+ * @return ERR_OK if the packet could be sent
+ *         an err_t value if the packet couldn't be sent
+ *
+ * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
+ *       strange results. You might consider waiting for space in the DMA queue
+ *       to become available since the stack doesn't retry to send a packet
+ *       dropped because of memory failure (except for the TCP timers).
+ */
+static err_t low_level_output(struct netif *netif, struct pbuf *p)
+{
+
+    INT8U        err;
+    err_t        errval = ERR_OK;
+    uint32_t     i = 0, framelen = 0, calc_len = 0;
+    struct pbuf *q;
+
+    SYS_ARCH_DECL_PROTECT(sr);
+
+    OSMutexPend(dm9k_mutex, 1000, &err);
+    SYS_ARCH_PROTECT(sr);
+
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF); /* 关闭 dm9kA 中断 */
+
+    NET_REG_ADDR = DM9K_REG_MWCMD;
+
+    for (q = p; q != NULL; q = q->next)
+    {
+        framelen = framelen + q->len;
+        calc_len = (q->len + 1) >> 1;
+
+        for (i = 0; i < calc_len; i++)
+        {
+            NET_REG_DATA = ((uint16_t *)q->payload)[i];
+        }
+    }
+
+    dm9k_WriteReg(DM9K_REG_TXPLH, (framelen >> 8) & 0xff); /* 设置传送封包的长度 */
+    dm9k_WriteReg(DM9K_REG_TXPLL, framelen & 0xff);
+
+    dm9k_WriteReg(DM9K_REG_TCR, DM9K_TCR_SET); /* 进行传送 */
+
+    while ((dm9k_ReadReg(DM9K_REG_ISR) & 0x02) == 0)
+        ;                                      /* 等待发送完成	 */
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* 开启 dm9kA 中断 */
+
+    SYS_ARCH_UNPROTECT(sr);
+
+    OSMutexPost(dm9k_mutex);
+    return errval;
+}
+
+static struct pbuf *low_level_input(struct netif *netif)
+{
+    struct pbuf *p        = NULL;
+    uint32_t     framelen = 0;
+
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF); /* 关闭 DM9000A 中断 */
+    framelen = etherdev_read(Rx_Buff[current_pbuf_idx]);
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* 开启 DM9000A 中断 */
+    if (framelen)
+    {
+
+        // p = pbuf_alloc(PBUF_RAW, framelen, PBUF_POOL);
+        p = pbuf_alloced_custom(PBUF_RAW, framelen, PBUF_REF, custom_pbuf[current_pbuf_idx], Rx_Buff[current_pbuf_idx], Max_Ethernet_Lenth);
+        if (current_pbuf_idx < (DM9K_RX_DESC_CNT - 1))
+        {
+            current_pbuf_idx++;
+        }
+        else
+        {
+            current_pbuf_idx = 0;
+        }
+    }
+    return p;
+}
+
+#if 1
+void ethernetif_input(void *pvParameters)
+{
+    struct pbuf *p;
+    INT8U        err;
+
+    SYS_ARCH_DECL_PROTECT(sr);
+
+    for (;;)
+    {
+
+        OSSemPend(g_dm9k_rx_sem, 100, &err);
+
+TRY_GET_NEXT_FRAME:
+        SYS_ARCH_PROTECT(sr);
+        p = low_level_input(low_netif);
+        SYS_ARCH_UNPROTECT(sr);
+
+        if (p != NULL)
+        {
+            if (ERR_OK != low_netif->input(p, low_netif))
+            {
+                pbuf_free(p);
+            }
+            else
+            {
+                goto TRY_GET_NEXT_FRAME;
+            }
+        }
+    }
+}
+#else
+void ethernetif_input(void *argument)
+{
+    struct pbuf *p;
+    // struct netif *netif = (struct netif *)argument;
+    INT8U err;
+    for (;;)
+    {
+        OSSemPend(g_dm9k_rx_sem, 0, &err);
+        // if (err == OS)
+        // {
+        if (err == ERR_OK)
+        {
+            do
+            {
+                LOCK_TCPIP_CORE();
+
+                p = low_level_input(low_netif);
+                if (p != NULL)
+                {
+                    err = low_netif->input(p, low_netif);
+                    if (err != ERR_OK)
+                    {
+                        LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
+                        pbuf_free(p);
+                    }
+                }
+
+                UNLOCK_TCPIP_CORE();
+
+            } while (p != NULL);
+        }
+
+        // }
+    }
+}
+#endif
+err_t ethernetif_dm9k_init(struct netif *netif)
+{
+    LWIP_ASSERT("netif != NULL", (netif != NULL));
+
+#if LWIP_NETIF_HOSTNAME
+    /* Initialize interface hostname */
+    netif->hostname = "DM9000";
+#endif /* LWIP_NETIF_HOSTNAME */
+
+    /*
+     * Initialize the snmp variables and counters inside the struct netif.
+     * The last argument should be replaced with your link speed, in units
+     * of bits per second.
+     */
+    // MIB2_INIT_NETIF(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
+    netif->name[0] = IFNAME0;
+    netif->name[1] = IFNAME1;
+
+    /* We directly use etharp_output() here to save a function call.
+     * You can instead declare your own function an call etharp_output()
+     * from it if you have to do some checks before sending (e.g. if link
+     * is available...) */
+    netif->output     = etharp_output;
+    netif->linkoutput = low_level_output;
+
+    /* initialize the hardware */
+    low_level_init(netif);
+
+    return ERR_OK;
+}
+
+/**
+ * @brief  Custom Rx pbuf free callback
+ * @param  pbuf: pbuf to be freed
+ * @retval None
+ */
+static void pbuf_free_custom(struct pbuf *p)
+{
+    if (p != NULL)
+    {
+        memset(p, 0, sizeof(struct pbuf));
+    }
+}
+void dm9k_interrupt(void)
+{
+    uint8_t  save_reg;
+    uint16_t isr_status;
+
+    save_reg = NET_REG_ADDR; /* 暂存所使用的位置 */
+
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_OFF); /* 关闭 DM9KA 中断 */
+    isr_status = dm9k_ReadReg(DM9K_REG_ISR);   /* 取得中断产生值 */
+    // isr_status = isr_status & DM9K_RX_INTR;
+    if (isr_status & DM9K_RX_INTR)
+    { /* 检查是否为接收中断 */
+        OSSemPost(g_dm9k_rx_sem);
+        // dm9k_receive_packet();							/* 执行接收处理程序 */
+    }
+
+    dm9k_WriteReg(DM9K_REG_IMR, DM9K_IMR_SET); /* 开启 DM9KA 中断 */
+    NET_REG_ADDR = save_reg;                   /* 回复所使用的位置 */
+}
+
+/**
+ * @brief  Ethernet Rx Transfer completed callback
+ * @param  heth: ETH handle
+ * @retval None
+ */
+void BSP_GPIO15_EXTI_Callback(void)
+{
+    uint8_t save_reg;
+    uint8_t isr_status;
+
+    save_reg = NET_REG_ADDR; /* 暂存所使用的位置 */
+
+    isr_status = dm9k_ReadReg(DM9K_REG_ISR); /* 取得中断产生值 */
+    dm9k_WriteReg(DM9K_REG_ISR, isr_status); /* 清除中断产生值 */
+    // isr_status = isr_status & DM9K_RX_INTR;
+
+    if (isr_status & DM9K_RX_INTR) /* 检查是否为接收中断 */
+    {
+        OSSemPost(g_dm9k_rx_sem); /* 执行接收处理程序 */
+    }
+
+    NET_REG_ADDR = save_reg; /* 回复所使用的位置 */
+}
+
+//中断处理函数,注意不是中断服函数,需要在中断服务函数中调用
+void DMA9K_ISRHandler(void)
+{
+    u16 int_status;
+    u16 last_io;
+    last_io    = NET_REG_ADDR;
+    int_status = dm9k_ReadReg(DM9K_REG_ISR);
+    dm9k_WriteReg(DM9K_REG_ISR, int_status); //清除中断标志位
+
+    if (int_status & DM9K_RX_INTR) //接收中断
+    {
+        OSSemPost(g_dm9k_rx_sem);
+        //接收完成中断,用户自己添加代码
+    }
+    if (int_status & DM9K_TX_INTR) //发送中断
+    {
+        // OSSemPost(g_dm9k_tx_sem);
+        //发送完成中断,用户自己添加代码
+    }
+    NET_REG_ADDR = last_io;
+}
+
+void EXTI15_10_IRQHandler(void)
+{
+    OSIntEnter();
+    EXTI_ClearITPendingBit(EXTI_Line15); /* 清除中断标志位 */
+    if (EXTI_GetITStatus(EXTI_Line15) != RESET)
+    {
+        BSP_GPIO15_EXTI_Callback();
+    }
+    OSIntExit();
+}
+
+void ethernet_link_check_state(struct netif *netif)
+{
+    uint8_t linkchanged = 0;
+
+    linkchanged = dm9k_linkstat();
+
+    if (netif_is_link_up(netif) && (linkchanged == 0))
+    {
+        netif_set_down(netif);
+        netif_set_link_down(netif);
+    }
+    else if (!netif_is_link_up(netif) && (linkchanged == 1))
+    {
+        netif_set_up(netif);
+        netif_set_link_up(netif);
+    }
+}

+ 10 - 10
User/conf/lwip/port/ethernetif_dm9k.h → Project/conf/lwip/port/ethernetif_dm9k.h

@@ -1,10 +1,10 @@
-#ifndef __ETHERNETIF_DM9K_H__
-#define __ETHERNETIF_DM9K_H__
-
-#include "lwip/err.h"
-#include "lwip/netif.h"
-
-err_t ethernetif_dm9k_init(struct netif *netif);
-void  ethernet_link_check_state(struct netif *netif);
-void  BSP_GPIO15_EXTI_Callback(void);
-#endif
+#ifndef __ETHERNETIF_DM9K_H__
+#define __ETHERNETIF_DM9K_H__
+
+#include "lwip/err.h"
+#include "lwip/netif.h"
+
+err_t ethernetif_dm9k_init(struct netif *netif);
+void  ethernet_link_check_state(struct netif *netif);
+void  BSP_GPIO15_EXTI_Callback(void);
+#endif

+ 414 - 413
User/conf/lwip/port/ethernetif_eth.c → Project/conf/lwip/port/ethernetif_eth.c

@@ -1,414 +1,415 @@
-/**
- * @file
- * Ethernet Interface for standalone applications (without RTOS) - works only for
- * ethernet polling mode (polling for ethernet frame reception)
- *
- */
-
-/*
- * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * This file is part of the lwIP TCP/IP stack.
- *
- * Author: Adam Dunkels <[email protected]>
- *
- */
-
-#include "ethernetif_eth.h"
-#include "lwip/def.h"
-#include "lwip/err.h"
-#include "lwip/mem.h"
-#include "lwip/opt.h"
-#include "lwip/pbuf.h"
-#include "lwip/timeouts.h"
-#include "lwip_init.h"
-#include "main.h"
-#include "netif/etharp.h"
-#include "stm32f4x7_eth.h"
-#include <string.h>
-
-#define ENET_RX_TASK_PRIO     (4)
-#define ENET_RX_TASK_STK_SIZE (2048)
-CPU_STK enet_rx_task_stk[ENET_RX_TASK_STK_SIZE];
-
-/* Network interface name */
-#define IFNAME0 's'
-#define IFNAME1 't'
-
-/* Ethernet Rx & Tx DMA Descriptors */
-extern ETH_DMADESCTypeDef DMARxDscrTab[ETH_RXBUFNB], DMATxDscrTab[ETH_TXBUFNB];
-
-/* Ethernet Driver Receive buffers  */
-extern uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE];
-
-/* Ethernet Driver Transmit buffers */
-extern uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE];
-
-/* Global pointers to track current transmit and receive descriptors */
-extern ETH_DMADESCTypeDef *DMATxDescToSet;
-extern ETH_DMADESCTypeDef *DMARxDescToGet;
-
-/* Global pointer for last received frame infos */
-extern ETH_DMA_Rx_Frame_infos *DMA_RX_FRAME_infos;
-
-static struct netif *low_netif     = NULL;
-OS_EVENT            *g_enet_rx_sem = NULL;
-
-static void ethernetif_input(void *pvParameters);
-/**
- * In this function, the hardware should be initialized.
- * Called from ethernetif_init().
- *
- * @param netif the already initialized lwip network interface structure
- *        for this ethernetif
- */
-static void low_level_init(struct netif *netif)
-{
-#ifdef CHECKSUM_BY_HARDWARE
-    int i;
-#endif
-    /* set MAC hardware address length */
-    netif->hwaddr_len = ETHARP_HWADDR_LEN;
-
-    /* set MAC hardware address */ /* 网卡的 MAC 修改2 */
-    netif->hwaddr[0] = ethdev.mac[0];
-    netif->hwaddr[1] = ethdev.mac[1];
-    netif->hwaddr[2] = ethdev.mac[2];
-    netif->hwaddr[3] = ethdev.mac[3];
-    netif->hwaddr[4] = ethdev.mac[4];
-    netif->hwaddr[5] = ethdev.mac[5];
-
-    /* initialize MAC address in ethernet MAC */
-    ETH_MACAddressConfig(ETH_MAC_Address0, netif->hwaddr);
-
-    /* maximum transfer unit */
-    netif->mtu = 1500;
-
-    /* device capabilities */
-    /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
-    netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
-
-    low_netif = netif;
-
-    /* create binary semaphore used for informing ethernetif of frame reception */
-    if (NULL == g_enet_rx_sem)
-    {
-        g_enet_rx_sem = OSSemCreate(0);
-    }
-
-    /* Initialize Tx Descriptors list: Chain Mode */
-    ETH_DMATxDescChainInit(DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
-    /* Initialize Rx Descriptors list: Chain Mode  */
-    ETH_DMARxDescChainInit(DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
-
-    /* Enable Ethernet Rx interrrupt */
-    for (i = 0; i < ETH_RXBUFNB; i++)
-    {
-        ETH_DMARxDescReceiveITConfig(&DMARxDscrTab[i], ENABLE);
-    }
-
-#ifdef CHECKSUM_BY_HARDWARE
-    /* Enable the TCP, UDP and ICMP checksum insertion for the Tx frames */
-    for (i = 0; i < ETH_TXBUFNB; i++)
-    {
-        ETH_DMATxDescChecksumInsertionConfig(&DMATxDscrTab[i], ETH_DMATxDesc_ChecksumTCPUDPICMPFull);
-    }
-#endif
-
-    /* Note: TCP, UDP, ICMP checksum checking for received frame are enabled in DMA config */
-
-    /* create the task that handles the ENET RX */
-    OSTaskCreateExt((void (*)(void *))ethernetif_input,
-                    (void *)0,
-                    (OS_STK *)&enet_rx_task_stk[ENET_RX_TASK_STK_SIZE - 1],
-                    (INT8U)ENET_RX_TASK_PRIO,
-                    (INT16U)ENET_RX_TASK_PRIO,
-                    (OS_STK *)&enet_rx_task_stk[0],
-                    (INT32U)ENET_RX_TASK_STK_SIZE,
-                    (void *)0,
-                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
-
-    /* Enable MAC and DMA transmission and reception */
-    ETH_Start();
-}
-
-/**
- * This function should do the actual transmission of the packet. The packet is
- * contained in the pbuf that is passed to the function. This pbuf
- * might be chained.
- *
- * @param netif the lwip network interface structure for this ethernetif
- * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
- * @return ERR_OK if the packet could be sent
- *         an err_t value if the packet couldn't be sent
- *
- * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
- *       strange results. You might consider waiting for space in the DMA queue
- *       to become availale since the stack doesn't retry to send a packet
- *       dropped because of memory failure (except for the TCP timers).
- */
-
-static err_t low_level_output(struct netif *netif, struct pbuf *p)
-{
-    static OS_EVENT         *p_enet_tx_sem = NULL;
-    INT8U                    err;
-    struct pbuf             *q;
-    u8                      *buffer;
-    __IO ETH_DMADESCTypeDef *DmaTxDesc;
-    uint16_t                 framelength     = 0;
-    uint32_t                 bufferoffset    = 0;
-    uint32_t                 byteslefttocopy = 0;
-    uint32_t                 payloadoffset   = 0;
-
-    SYS_ARCH_DECL_PROTECT(sr);
-
-    if (NULL == p_enet_tx_sem)
-    {
-        p_enet_tx_sem = OSSemCreate(1);
-    }
-
-    OSSemPend(p_enet_tx_sem, 0, &err);
-
-    SYS_ARCH_PROTECT(sr);
-
-    DmaTxDesc    = DMATxDescToSet;
-    buffer       = (u8 *)(DmaTxDesc->Buffer1Addr);
-    bufferoffset = 0;
-
-    for (q = p; q != NULL; q = q->next)
-    {
-        if ((DmaTxDesc->Status & ETH_DMATxDesc_OWN) != (u32)RESET)
-        {
-            goto error;
-        }
-
-        /* Get bytes in current lwIP buffer  */
-        byteslefttocopy = q->len;
-        payloadoffset   = 0;
-
-        /* Check if the length of data to copy is bigger than Tx buffer size*/
-        while ((byteslefttocopy + bufferoffset) > ETH_TX_BUF_SIZE)
-        {
-            /* Copy data to Tx buffer*/
-            memcpy((u8_t *)((u8_t *)buffer + bufferoffset), (u8_t *)((u8_t *)q->payload + payloadoffset), (ETH_TX_BUF_SIZE - bufferoffset));
-
-            /* Point to next descriptor */
-            DmaTxDesc = (ETH_DMADESCTypeDef *)(DmaTxDesc->Buffer2NextDescAddr);
-
-            /* Check if the buffer is available */
-            if ((DmaTxDesc->Status & ETH_DMATxDesc_OWN) != (u32)RESET)
-            {
-                goto error;
-            }
-
-            buffer = (u8 *)(DmaTxDesc->Buffer1Addr);
-
-            byteslefttocopy = byteslefttocopy - (ETH_TX_BUF_SIZE - bufferoffset);
-            payloadoffset   = payloadoffset + (ETH_TX_BUF_SIZE - bufferoffset);
-            framelength     = framelength + (ETH_TX_BUF_SIZE - bufferoffset);
-            bufferoffset    = 0;
-        }
-
-        /* Copy the remaining bytes */
-        memcpy((u8_t *)((u8_t *)buffer + bufferoffset), (u8_t *)((u8_t *)q->payload + payloadoffset), byteslefttocopy);
-        bufferoffset = bufferoffset + byteslefttocopy;
-        framelength  = framelength + byteslefttocopy;
-    }
-
-    /* Prepare transmit descriptors to give to DMA*/
-    ETH_Prepare_Transmit_Descriptors(framelength);
-
-/* Give semaphore and exit */
-error:
-
-    /* give semaphore and exit */
-    OSSemPost(p_enet_tx_sem);
-
-    SYS_ARCH_UNPROTECT(sr);
-
-    return ERR_OK;
-}
-
-/**
- * Should allocate a pbuf and transfer the bytes of the incoming
- * packet from the interface into the pbuf.
- *
- * @param netif the lwip network interface structure for this ethernetif
- * @return a pbuf filled with the received packet (including MAC header)
- *         NULL on memory error
- */
-static struct pbuf *low_level_input(struct netif *netif)
-{
-    struct pbuf             *p = NULL, *q;
-    u32_t                    len;
-    FrameTypeDef             frame;
-    u8                      *buffer;
-    __IO ETH_DMADESCTypeDef *DMARxDesc;
-    uint32_t                 bufferoffset    = 0;
-    uint32_t                 payloadoffset   = 0;
-    uint32_t                 byteslefttocopy = 0;
-    uint32_t                 i               = 0;
-
-    /* get received frame */
-    frame = ETH_Get_Received_Frame_interrupt();
-
-    /* Obtain the size of the packet and put it into the "len" variable. */
-    len    = frame.length;
-    buffer = (u8 *)frame.buffer;
-
-    if (len > 0)
-    {
-        /* We allocate a pbuf chain of pbufs from the Lwip buffer pool */
-        p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
-    }
-
-    if (p != NULL)
-    {
-        DMARxDesc    = frame.descriptor;
-        bufferoffset = 0;
-        for (q = p; q != NULL; q = q->next)
-        {
-            byteslefttocopy = q->len;
-            payloadoffset   = 0;
-
-            /* Check if the length of bytes to copy in current pbuf is bigger than Rx buffer size*/
-            while ((byteslefttocopy + bufferoffset) > ETH_RX_BUF_SIZE)
-            {
-                /* Copy data to pbuf*/
-                memcpy((u8_t *)((u8_t *)q->payload + payloadoffset), (u8_t *)((u8_t *)buffer + bufferoffset), (ETH_RX_BUF_SIZE - bufferoffset));
-
-                /* Point to next descriptor */
-                DMARxDesc = (ETH_DMADESCTypeDef *)(DMARxDesc->Buffer2NextDescAddr);
-                buffer    = (unsigned char *)(DMARxDesc->Buffer1Addr);
-
-                byteslefttocopy = byteslefttocopy - (ETH_RX_BUF_SIZE - bufferoffset);
-                payloadoffset   = payloadoffset + (ETH_RX_BUF_SIZE - bufferoffset);
-                bufferoffset    = 0;
-            }
-
-            /* Copy remaining data in pbuf */
-            memcpy((u8_t *)((u8_t *)q->payload + payloadoffset), (u8_t *)((u8_t *)buffer + bufferoffset), byteslefttocopy);
-            bufferoffset = bufferoffset + byteslefttocopy;
-        }
-
-        /* Release descriptors to DMA */
-        DMARxDesc = frame.descriptor;
-
-        /* Set Own bit in Rx descriptors: gives the buffers back to DMA */
-        for (i = 0; i < DMA_RX_FRAME_infos->Seg_Count; i++)
-        {
-            DMARxDesc->Status = ETH_DMARxDesc_OWN;
-            DMARxDesc         = (ETH_DMADESCTypeDef *)(DMARxDesc->Buffer2NextDescAddr);
-        }
-
-        /* Clear Segment_Count */
-        DMA_RX_FRAME_infos->Seg_Count = 0;
-        /* added for test*/
-    }
-
-    /* When Rx Buffer unavailable flag is set: clear it and resume reception */
-    if ((ETH->DMASR & ETH_DMASR_RBUS) != (u32)RESET)
-    {
-        /* Clear RBUS ETHERNET DMA flag */
-        ETH->DMASR = ETH_DMASR_RBUS;
-        /* Resume DMA reception */
-        ETH->DMARPDR = 0;
-    }
-    return p;
-}
-
-/**
- * This function should be called when a packet is ready to be read
- * from the interface. It uses the function low_level_input() that
- * should handle the actual reception of bytes from the network
- * interface. Then the type of the received packet is determined and
- * the appropriate input function is called.
- *
- * @param netif the lwip network interface structure for this ethernetif
- */
-void ethernetif_input(void *pvParameters)
-{
-    struct pbuf *p;
-    INT8U        err;
-
-    SYS_ARCH_DECL_PROTECT(sr);
-
-    for (;;)
-    {
-
-        OSSemPend(g_enet_rx_sem, 0, &err);
-
-TRY_GET_NEXT_FRAME:
-        SYS_ARCH_PROTECT(sr);
-        p = low_level_input(low_netif);
-        SYS_ARCH_UNPROTECT(sr);
-
-        if (p != NULL)
-        {
-            if (ERR_OK != low_netif->input(p, low_netif))
-            {
-                pbuf_free(p);
-            }
-            else
-            {
-                goto TRY_GET_NEXT_FRAME;
-            }
-        }
-    }
-}
-
-/**
- * Should be called at the beginning of the program to set up the
- * network interface. It calls the function low_level_init() to do the
- * actual setup of the hardware.
- *
- * This function should be passed as a parameter to netif_add().
- *
- * @param netif the lwip network interface structure for this ethernetif
- * @return ERR_OK if the loopif is initialized
- *         ERR_MEM if private data couldn't be allocated
- *         any other err_t on error
- */
-err_t ethernetif_eth_init(struct netif *netif)
-{
-    LWIP_ASSERT("netif != NULL", (netif != NULL));
-
-#if LWIP_NETIF_HOSTNAME
-    /* Initialize interface hostname */
-    netif->hostname = "lwip";
-#endif /* LWIP_NETIF_HOSTNAME */
-
-    netif->name[0] = IFNAME0;
-    netif->name[1] = IFNAME1;
-
-    netif->output     = etharp_output;
-    netif->linkoutput = low_level_output;
-
-    /* initialize the hardware */
-    low_level_init(netif);
-
-    return ERR_OK;
+/**
+ * @file
+ * Ethernet Interface for standalone applications (without RTOS) - works only for
+ * ethernet polling mode (polling for ethernet frame reception)
+ *
+ */
+
+/*
+ * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ *
+ * Author: Adam Dunkels <[email protected]>
+ *
+ */
+
+#include "ethernetif_eth.h"
+#include "lwip/def.h"
+#include "lwip/err.h"
+#include "lwip/mem.h"
+#include "lwip/opt.h"
+#include "lwip/pbuf.h"
+#include "lwip/timeouts.h"
+#include "lwip_init.h"
+#include "main.h"
+#include "netif/etharp.h"
+#include "stm32f4x7_eth.h"
+#include <string.h>
+
+#define ENET_RX_TASK_PRIO     (4)
+#define ENET_RX_TASK_STK_SIZE (2048)
+CPU_STK enet_rx_task_stk[ENET_RX_TASK_STK_SIZE];
+
+/* Network interface name */
+#define IFNAME0 's'
+#define IFNAME1 't'
+
+/* Ethernet Rx & Tx DMA Descriptors */
+extern ETH_DMADESCTypeDef DMARxDscrTab[ETH_RXBUFNB], DMATxDscrTab[ETH_TXBUFNB];
+
+/* Ethernet Driver Receive buffers  */
+extern uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE];
+
+/* Ethernet Driver Transmit buffers */
+extern uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE];
+
+/* Global pointers to track current transmit and receive descriptors */
+extern ETH_DMADESCTypeDef *DMATxDescToSet;
+extern ETH_DMADESCTypeDef *DMARxDescToGet;
+
+/* Global pointer for last received frame infos */
+extern ETH_DMA_Rx_Frame_infos *DMA_RX_FRAME_infos;
+
+static struct netif *low_netif     = NULL;
+OS_EVENT            *g_enet_rx_sem = NULL;
+
+static void ethernetif_input(void *pvParameters);
+/**
+ * In this function, the hardware should be initialized.
+ * Called from ethernetif_init().
+ *
+ * @param netif the already initialized lwip network interface structure
+ *        for this ethernetif
+ */
+static void low_level_init(struct netif *netif)
+{
+#ifdef CHECKSUM_BY_HARDWARE
+    int i;
+#endif
+    /* set MAC hardware address length */
+    netif->hwaddr_len = ETHARP_HWADDR_LEN;
+
+    /* set MAC hardware address */ /* 网卡的 MAC 修改2 */
+    netif->hwaddr[0] = ethdev.mac[0];
+    netif->hwaddr[1] = ethdev.mac[1];
+    netif->hwaddr[2] = ethdev.mac[2];
+    netif->hwaddr[3] = ethdev.mac[3];
+    netif->hwaddr[4] = ethdev.mac[4];
+    netif->hwaddr[5] = ethdev.mac[5];
+
+    /* initialize MAC address in ethernet MAC */
+    ETH_MACAddressConfig(ETH_MAC_Address0, netif->hwaddr);
+
+    /* maximum transfer unit */
+    netif->mtu = 1500;
+
+    /* device capabilities */
+    /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
+    netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
+
+    low_netif = netif;
+
+    /* create binary semaphore used for informing ethernetif of frame reception */
+    if (NULL == g_enet_rx_sem)
+    {
+        g_enet_rx_sem = OSSemCreate(0);
+    }
+
+    /* Initialize Tx Descriptors list: Chain Mode */
+    ETH_DMATxDescChainInit(DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
+    /* Initialize Rx Descriptors list: Chain Mode  */
+    ETH_DMARxDescChainInit(DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
+
+    /* Enable Ethernet Rx interrrupt */
+    for (i = 0; i < ETH_RXBUFNB; i++)
+    {
+        ETH_DMARxDescReceiveITConfig(&DMARxDscrTab[i], ENABLE);
+    }
+
+#ifdef CHECKSUM_BY_HARDWARE
+    /* Enable the TCP, UDP and ICMP checksum insertion for the Tx frames */
+    for (i = 0; i < ETH_TXBUFNB; i++)
+    {
+        ETH_DMATxDescChecksumInsertionConfig(&DMATxDscrTab[i], ETH_DMATxDesc_ChecksumTCPUDPICMPFull);
+    }
+#endif
+
+    /* Note: TCP, UDP, ICMP checksum checking for received frame are enabled in DMA config */
+
+    /* create the task that handles the ENET RX */
+    OSTaskCreateExt((void (*)(void *))ethernetif_input,
+                    (void *)0,
+                    (OS_STK *)&enet_rx_task_stk[ENET_RX_TASK_STK_SIZE - 1],
+                    (INT8U)ENET_RX_TASK_PRIO,
+                    (INT16U)ENET_RX_TASK_PRIO,
+                    (OS_STK *)&enet_rx_task_stk[0],
+                    (INT32U)ENET_RX_TASK_STK_SIZE,
+                    (void *)0,
+                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
+
+    /* Enable MAC and DMA transmission and reception */
+    ETH_Start();
+}
+
+/**
+ * This function should do the actual transmission of the packet. The packet is
+ * contained in the pbuf that is passed to the function. This pbuf
+ * might be chained.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
+ * @return ERR_OK if the packet could be sent
+ *         an err_t value if the packet couldn't be sent
+ *
+ * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
+ *       strange results. You might consider waiting for space in the DMA queue
+ *       to become availale since the stack doesn't retry to send a packet
+ *       dropped because of memory failure (except for the TCP timers).
+ */
+
+static err_t low_level_output(struct netif *netif, struct pbuf *p)
+{
+    static OS_EVENT         *p_enet_tx_sem = NULL;
+    INT8U                    err;
+    struct pbuf             *q;
+    u8                      *buffer;
+    __IO ETH_DMADESCTypeDef *DmaTxDesc;
+    uint16_t                 framelength     = 0;
+    uint32_t                 bufferoffset    = 0;
+    uint32_t                 byteslefttocopy = 0;
+    uint32_t                 payloadoffset   = 0;
+
+    SYS_ARCH_DECL_PROTECT(sr);
+
+    if (NULL == p_enet_tx_sem)
+    {
+        p_enet_tx_sem = OSSemCreate(1);
+    }
+
+    OSSemPend(p_enet_tx_sem, 0, &err);
+
+    SYS_ARCH_PROTECT(sr);
+
+    DmaTxDesc    = DMATxDescToSet;
+    buffer       = (u8 *)(DmaTxDesc->Buffer1Addr);
+    bufferoffset = 0;
+
+    for (q = p; q != NULL; q = q->next)
+    {
+        if ((DmaTxDesc->Status & ETH_DMATxDesc_OWN) != (u32)RESET)
+        {
+            goto error;
+        }
+
+        /* Get bytes in current lwIP buffer  */
+        byteslefttocopy = q->len;
+        payloadoffset   = 0;
+
+        /* Check if the length of data to copy is bigger than Tx buffer size*/
+        while ((byteslefttocopy + bufferoffset) > ETH_TX_BUF_SIZE)
+        {
+            /* Copy data to Tx buffer*/
+            memcpy((u8_t *)((u8_t *)buffer + bufferoffset), (u8_t *)((u8_t *)q->payload + payloadoffset), (ETH_TX_BUF_SIZE - bufferoffset));
+
+            /* Point to next descriptor */
+            DmaTxDesc = (ETH_DMADESCTypeDef *)(DmaTxDesc->Buffer2NextDescAddr);
+
+            /* Check if the buffer is available */
+            if ((DmaTxDesc->Status & ETH_DMATxDesc_OWN) != (u32)RESET)
+            {
+                goto error;
+            }
+
+            buffer = (u8 *)(DmaTxDesc->Buffer1Addr);
+
+            byteslefttocopy = byteslefttocopy - (ETH_TX_BUF_SIZE - bufferoffset);
+            payloadoffset   = payloadoffset + (ETH_TX_BUF_SIZE - bufferoffset);
+            framelength     = framelength + (ETH_TX_BUF_SIZE - bufferoffset);
+            bufferoffset    = 0;
+        }
+
+        /* Copy the remaining bytes */
+        memcpy((u8_t *)((u8_t *)buffer + bufferoffset), (u8_t *)((u8_t *)q->payload + payloadoffset), byteslefttocopy);
+        bufferoffset = bufferoffset + byteslefttocopy;
+        framelength  = framelength + byteslefttocopy;
+    }
+
+    /* Prepare transmit descriptors to give to DMA*/
+    ETH_Prepare_Transmit_Descriptors(framelength);
+
+/* Give semaphore and exit */
+error:
+
+    /* give semaphore and exit */
+    OSSemPost(p_enet_tx_sem);
+
+    SYS_ARCH_UNPROTECT(sr);
+
+    return ERR_OK;
+}
+
+/**
+ * Should allocate a pbuf and transfer the bytes of the incoming
+ * packet from the interface into the pbuf.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @return a pbuf filled with the received packet (including MAC header)
+ *         NULL on memory error
+ */
+static struct pbuf *low_level_input(struct netif *netif)
+{
+    struct pbuf             *p = NULL, *q;
+    u32_t                    len;
+    FrameTypeDef             frame;
+    u8                      *buffer;
+    __IO ETH_DMADESCTypeDef *DMARxDesc;
+    uint32_t                 bufferoffset    = 0;
+    uint32_t                 payloadoffset   = 0;
+    uint32_t                 byteslefttocopy = 0;
+    uint32_t                 i               = 0;
+
+    /* get received frame */
+    frame = ETH_Get_Received_Frame_interrupt();
+
+    /* Obtain the size of the packet and put it into the "len" variable. */
+    len    = frame.length;
+    buffer = (u8 *)frame.buffer;
+
+    if (len > 0)
+    {
+        /* We allocate a pbuf chain of pbufs from the Lwip buffer pool */
+        p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
+    }
+
+    if (p != NULL)
+    {
+        DMARxDesc    = frame.descriptor;
+        bufferoffset = 0;
+        for (q = p; q != NULL; q = q->next)
+        {
+            byteslefttocopy = q->len;
+            payloadoffset   = 0;
+
+            /* Check if the length of bytes to copy in current pbuf is bigger than Rx buffer size*/
+            while ((byteslefttocopy + bufferoffset) > ETH_RX_BUF_SIZE)
+            {
+                /* Copy data to pbuf*/
+                memcpy((u8_t *)((u8_t *)q->payload + payloadoffset), (u8_t *)((u8_t *)buffer + bufferoffset), (ETH_RX_BUF_SIZE - bufferoffset));
+
+                /* Point to next descriptor */
+                DMARxDesc = (ETH_DMADESCTypeDef *)(DMARxDesc->Buffer2NextDescAddr);
+                buffer    = (unsigned char *)(DMARxDesc->Buffer1Addr);
+
+                byteslefttocopy = byteslefttocopy - (ETH_RX_BUF_SIZE - bufferoffset);
+                payloadoffset   = payloadoffset + (ETH_RX_BUF_SIZE - bufferoffset);
+                bufferoffset    = 0;
+            }
+
+            /* Copy remaining data in pbuf */
+            memcpy((u8_t *)((u8_t *)q->payload + payloadoffset), (u8_t *)((u8_t *)buffer + bufferoffset), byteslefttocopy);
+            bufferoffset = bufferoffset + byteslefttocopy;
+        }
+
+        /* Release descriptors to DMA */
+        DMARxDesc = frame.descriptor;
+
+        /* Set Own bit in Rx descriptors: gives the buffers back to DMA */
+        for (i = 0; i < DMA_RX_FRAME_infos->Seg_Count; i++)
+        {
+            DMARxDesc->Status = ETH_DMARxDesc_OWN;
+            DMARxDesc         = (ETH_DMADESCTypeDef *)(DMARxDesc->Buffer2NextDescAddr);
+        }
+
+        /* Clear Segment_Count */
+        DMA_RX_FRAME_infos->Seg_Count = 0;
+        /* added for test*/
+    }
+
+    /* When Rx Buffer unavailable flag is set: clear it and resume reception */
+    if ((ETH->DMASR & ETH_DMASR_RBUS) != (u32)RESET)
+    {
+        /* Clear RBUS ETHERNET DMA flag */
+        ETH->DMASR = ETH_DMASR_RBUS;
+        /* Resume DMA reception */
+        ETH->DMARPDR = 0;
+    }
+    return p;
+}
+
+/**
+ * This function should be called when a packet is ready to be read
+ * from the interface. It uses the function low_level_input() that
+ * should handle the actual reception of bytes from the network
+ * interface. Then the type of the received packet is determined and
+ * the appropriate input function is called.
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ */
+void ethernetif_input(void *pvParameters)
+{
+    struct pbuf *p;
+    INT8U        err;
+    INT8U       *pv;
+    pv = pvParameters;
+    SYS_ARCH_DECL_PROTECT(sr);
+
+    for (;;)
+    {
+
+        OSSemPend(g_enet_rx_sem, 0, &err);
+
+TRY_GET_NEXT_FRAME:
+        SYS_ARCH_PROTECT(sr);
+        p = low_level_input(low_netif);
+        SYS_ARCH_UNPROTECT(sr);
+
+        if (p != NULL)
+        {
+            if (ERR_OK != low_netif->input(p, low_netif))
+            {
+                pbuf_free(p);
+            }
+            else
+            {
+                goto TRY_GET_NEXT_FRAME;
+            }
+        }
+    }
+}
+
+/**
+ * Should be called at the beginning of the program to set up the
+ * network interface. It calls the function low_level_init() to do the
+ * actual setup of the hardware.
+ *
+ * This function should be passed as a parameter to netif_add().
+ *
+ * @param netif the lwip network interface structure for this ethernetif
+ * @return ERR_OK if the loopif is initialized
+ *         ERR_MEM if private data couldn't be allocated
+ *         any other err_t on error
+ */
+err_t ethernetif_eth_init(struct netif *netif)
+{
+    LWIP_ASSERT("netif != NULL", (netif != NULL));
+
+#if LWIP_NETIF_HOSTNAME
+    /* Initialize interface hostname */
+    netif->hostname = "lwip";
+#endif /* LWIP_NETIF_HOSTNAME */
+
+    netif->name[0] = IFNAME0;
+    netif->name[1] = IFNAME1;
+
+    netif->output     = etharp_output;
+    netif->linkoutput = low_level_output;
+
+    /* initialize the hardware */
+    low_level_init(netif);
+
+    return ERR_OK;
 }

+ 9 - 9
User/conf/lwip/port/ethernetif_eth.h → Project/conf/lwip/port/ethernetif_eth.h

@@ -1,9 +1,9 @@
-#ifndef __ETHERNETIF_ETH_H__
-#define __ETHERNETIF_ETH_H__
-
-#include "lwip/err.h"
-#include "lwip/netif.h"
-
-err_t ethernetif_eth_init(struct netif *netif);
-
-#endif
+#ifndef __ETHERNETIF_ETH_H__
+#define __ETHERNETIF_ETH_H__
+
+#include "lwip/err.h"
+#include "lwip/netif.h"
+
+err_t ethernetif_eth_init(struct netif *netif);
+
+#endif

+ 252 - 252
User/conf/ucos/app_hooks.c → Project/conf/ucos/app_hooks.c

@@ -1,252 +1,252 @@
-/*
-*********************************************************************************************************
-*                                            EXAMPLE CODE
-*
-*               This file is provided as an example on how to use Micrium products.
-*
-*               Please feel free to use any application code labeled as 'EXAMPLE CODE' in
-*               your application products.  Example code may be used as is, in whole or in
-*               part, or may be used as a reference only. This file can be modified as
-*               required to meet the end-product requirements.
-*
-*               Please help us continue to provide the Embedded community with the finest
-*               software available.  Your honesty is greatly appreciated.
-*
-*               You can find our product's user manual, API reference, release notes and
-*               more information at https://doc.micrium.com.
-*               You can contact us at www.micrium.com.
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*
-*                                             uC/OS-II
-*                                         Application Hooks
-*
-* Filename      : app_hooks.c
-* Version       : V1.00
-* Programmer(s) : FT
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*                                             INCLUDE FILES
-*********************************************************************************************************
-*/
-
-#include <includes.h>
-
-/*
-*********************************************************************************************************
-*                                       EXTERN  GLOBAL VARIABLES
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*                                           LOCAL CONSTANTS
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*                                          LOCAL DATA TYPES
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*                                            LOCAL TABLES
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*                                       LOCAL GLOBAL VARIABLES
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*                                      LOCAL FUNCTION PROTOTYPES
-*********************************************************************************************************
-*/
-
-/*
-**********************************************************************************************************
-**********************************************************************************************************
-**                                        GLOBAL FUNCTIONS
-**********************************************************************************************************
-**********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*********************************************************************************************************
-**                                         uC/OS-II APP HOOKS
-*********************************************************************************************************
-*********************************************************************************************************
-*/
-
-#if (OS_APP_HOOKS_EN > 0)
-
-/*
-*********************************************************************************************************
-*                                      TASK CREATION HOOK (APPLICATION)
-*
-* Description : This function is called when a task is created.
-*
-* Argument(s) : ptcb   is a pointer to the task control block of the task being created.
-*
-* Note(s)     : (1) Interrupts are disabled during this call.
-*********************************************************************************************************
-*/
-
-void App_TaskCreateHook(OS_TCB *ptcb)
-{
-#if (APP_CFG_PROBE_OS_PLUGIN_EN == DEF_ENABLED) && (OS_PROBE_HOOKS_EN > 0)
-    OSProbe_TaskCreateHook(ptcb);
-#endif
-}
-
-/*
-*********************************************************************************************************
-*                                    TASK DELETION HOOK (APPLICATION)
-*
-* Description : This function is called when a task is deleted.
-*
-* Argument(s) : ptcb   is a pointer to the task control block of the task being deleted.
-*
-* Note(s)     : (1) Interrupts are disabled during this call.
-*********************************************************************************************************
-*/
-
-void App_TaskDelHook(OS_TCB *ptcb)
-{
-    (void)ptcb;
-}
-
-/*
-*********************************************************************************************************
-*                                      IDLE TASK HOOK (APPLICATION)
-*
-* Description : This function is called by OSTaskIdleHook(), which is called by the idle task.  This hook
-*               has been added to allow you to do such things as STOP the CPU to conserve power.
-*
-* Argument(s) : none.
-*
-* Note(s)     : (1) Interrupts are enabled during this call.
-*********************************************************************************************************
-*/
-
-#if OS_VERSION >= 251
-void App_TaskIdleHook(void)
-{
-}
-#endif
-
-/*
-*********************************************************************************************************
-*                                        STATISTIC TASK HOOK (APPLICATION)
-*
-* Description : This function is called by OSTaskStatHook(), which is called every second by uC/OS-II's
-*               statistics task.  This allows your application to add functionality to the statistics task.
-*
-* Argument(s) : none.
-*********************************************************************************************************
-*/
-
-void App_TaskStatHook(void)
-{
-}
-
-/*
-*********************************************************************************************************
-*                                            TASK RETURN HOOK (APPLICATION)
-*
-* Description: This function is called if a task accidentally returns.  In other words, a task should
-*              either be an infinite loop or delete itself when done.
-*
-* Arguments  : ptcb      is a pointer to the task control block of the task that is returning.
-*
-* Note(s)    : none
-*********************************************************************************************************
-*/
-
-#if OS_VERSION >= 289
-void App_TaskReturnHook(OS_TCB *ptcb)
-{
-    (void)ptcb;
-}
-#endif
-
-/*
-*********************************************************************************************************
-*                                        TASK SWITCH HOOK (APPLICATION)
-*
-* Description : This function is called when a task switch is performed.  This allows you to perform other
-*               operations during a context switch.
-*
-* Argument(s) : none.
-*
-* Note(s)     : (1) Interrupts are disabled during this call.
-*
-*               (2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
-*                   will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
-*                  task being switched out (i.e. the preempted task).
-*********************************************************************************************************
-*/
-
-#if OS_TASK_SW_HOOK_EN > 0
-void App_TaskSwHook(void)
-{
-#if (APP_CFG_PROBE_OS_PLUGIN_EN > 0) && (OS_PROBE_HOOKS_EN > 0)
-    OSProbe_TaskSwHook();
-#endif
-}
-#endif
-
-/*
-*********************************************************************************************************
-*                                     OS_TCBInit() HOOK (APPLICATION)
-*
-* Description : This function is called by OSTCBInitHook(), which is called by OS_TCBInit() after setting
-*               up most of the TCB.
-*
-* Argument(s) : ptcb    is a pointer to the TCB of the task being created.
-*
-* Note(s)     : (1) Interrupts may or may not be ENABLED during this call.
-*********************************************************************************************************
-*/
-
-#if OS_VERSION >= 204
-void App_TCBInitHook(OS_TCB *ptcb)
-{
-    (void)ptcb;
-}
-#endif
-
-/*
-*********************************************************************************************************
-*                                        TICK HOOK (APPLICATION)
-*
-* Description : This function is called every tick.
-*
-* Argument(s) : none.
-*
-* Note(s)     : (1) Interrupts may or may not be ENABLED during this call.
-*********************************************************************************************************
-*/
-
-#if OS_TIME_TICK_HOOK_EN > 0
-void App_TimeTickHook(void)
-{
-#if (APP_CFG_PROBE_OS_PLUGIN_EN == DEF_ENABLED) && (OS_PROBE_HOOKS_EN > 0)
-    OSProbe_TickHook();
-#endif
-    HAL_IncTick(); /* STM32CubeF4 library function call.                   */
-}
-#endif
-#endif
+/*
+*********************************************************************************************************
+*                                            EXAMPLE CODE
+*
+*               This file is provided as an example on how to use Micrium products.
+*
+*               Please feel free to use any application code labeled as 'EXAMPLE CODE' in
+*               your application products.  Example code may be used as is, in whole or in
+*               part, or may be used as a reference only. This file can be modified as
+*               required to meet the end-product requirements.
+*
+*               Please help us continue to provide the Embedded community with the finest
+*               software available.  Your honesty is greatly appreciated.
+*
+*               You can find our product's user manual, API reference, release notes and
+*               more information at https://doc.micrium.com.
+*               You can contact us at www.micrium.com.
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*
+*                                             uC/OS-II
+*                                         Application Hooks
+*
+* Filename      : app_hooks.c
+* Version       : V1.00
+* Programmer(s) : FT
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*                                             INCLUDE FILES
+*********************************************************************************************************
+*/
+
+#include <includes.h>
+
+/*
+*********************************************************************************************************
+*                                       EXTERN  GLOBAL VARIABLES
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*                                           LOCAL CONSTANTS
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*                                          LOCAL DATA TYPES
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*                                            LOCAL TABLES
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*                                       LOCAL GLOBAL VARIABLES
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*                                      LOCAL FUNCTION PROTOTYPES
+*********************************************************************************************************
+*/
+
+/*
+**********************************************************************************************************
+**********************************************************************************************************
+**                                        GLOBAL FUNCTIONS
+**********************************************************************************************************
+**********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*********************************************************************************************************
+**                                         uC/OS-II APP HOOKS
+*********************************************************************************************************
+*********************************************************************************************************
+*/
+
+#if (OS_APP_HOOKS_EN > 0)
+
+/*
+*********************************************************************************************************
+*                                      TASK CREATION HOOK (APPLICATION)
+*
+* Description : This function is called when a task is created.
+*
+* Argument(s) : ptcb   is a pointer to the task control block of the task being created.
+*
+* Note(s)     : (1) Interrupts are disabled during this call.
+*********************************************************************************************************
+*/
+
+void App_TaskCreateHook(OS_TCB *ptcb)
+{
+#if (APP_CFG_PROBE_OS_PLUGIN_EN == DEF_ENABLED) && (OS_PROBE_HOOKS_EN > 0)
+    OSProbe_TaskCreateHook(ptcb);
+#endif
+}
+
+/*
+*********************************************************************************************************
+*                                    TASK DELETION HOOK (APPLICATION)
+*
+* Description : This function is called when a task is deleted.
+*
+* Argument(s) : ptcb   is a pointer to the task control block of the task being deleted.
+*
+* Note(s)     : (1) Interrupts are disabled during this call.
+*********************************************************************************************************
+*/
+
+void App_TaskDelHook(OS_TCB *ptcb)
+{
+    (void)ptcb;
+}
+
+/*
+*********************************************************************************************************
+*                                      IDLE TASK HOOK (APPLICATION)
+*
+* Description : This function is called by OSTaskIdleHook(), which is called by the idle task.  This hook
+*               has been added to allow you to do such things as STOP the CPU to conserve power.
+*
+* Argument(s) : none.
+*
+* Note(s)     : (1) Interrupts are enabled during this call.
+*********************************************************************************************************
+*/
+
+#if OS_VERSION >= 251
+void App_TaskIdleHook(void)
+{
+}
+#endif
+
+/*
+*********************************************************************************************************
+*                                        STATISTIC TASK HOOK (APPLICATION)
+*
+* Description : This function is called by OSTaskStatHook(), which is called every second by uC/OS-II's
+*               statistics task.  This allows your application to add functionality to the statistics task.
+*
+* Argument(s) : none.
+*********************************************************************************************************
+*/
+
+void App_TaskStatHook(void)
+{
+}
+
+/*
+*********************************************************************************************************
+*                                            TASK RETURN HOOK (APPLICATION)
+*
+* Description: This function is called if a task accidentally returns.  In other words, a task should
+*              either be an infinite loop or delete itself when done.
+*
+* Arguments  : ptcb      is a pointer to the task control block of the task that is returning.
+*
+* Note(s)    : none
+*********************************************************************************************************
+*/
+
+#if OS_VERSION >= 289
+void App_TaskReturnHook(OS_TCB *ptcb)
+{
+    (void)ptcb;
+}
+#endif
+
+/*
+*********************************************************************************************************
+*                                        TASK SWITCH HOOK (APPLICATION)
+*
+* Description : This function is called when a task switch is performed.  This allows you to perform other
+*               operations during a context switch.
+*
+* Argument(s) : none.
+*
+* Note(s)     : (1) Interrupts are disabled during this call.
+*
+*               (2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
+*                   will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
+*                  task being switched out (i.e. the preempted task).
+*********************************************************************************************************
+*/
+
+#if OS_TASK_SW_HOOK_EN > 0
+void App_TaskSwHook(void)
+{
+#if (APP_CFG_PROBE_OS_PLUGIN_EN > 0) && (OS_PROBE_HOOKS_EN > 0)
+    OSProbe_TaskSwHook();
+#endif
+}
+#endif
+
+/*
+*********************************************************************************************************
+*                                     OS_TCBInit() HOOK (APPLICATION)
+*
+* Description : This function is called by OSTCBInitHook(), which is called by OS_TCBInit() after setting
+*               up most of the TCB.
+*
+* Argument(s) : ptcb    is a pointer to the TCB of the task being created.
+*
+* Note(s)     : (1) Interrupts may or may not be ENABLED during this call.
+*********************************************************************************************************
+*/
+
+#if OS_VERSION >= 204
+void App_TCBInitHook(OS_TCB *ptcb)
+{
+    (void)ptcb;
+}
+#endif
+
+/*
+*********************************************************************************************************
+*                                        TICK HOOK (APPLICATION)
+*
+* Description : This function is called every tick.
+*
+* Argument(s) : none.
+*
+* Note(s)     : (1) Interrupts may or may not be ENABLED during this call.
+*********************************************************************************************************
+*/
+
+#if OS_TIME_TICK_HOOK_EN > 0
+void App_TimeTickHook(void)
+{
+#if (APP_CFG_PROBE_OS_PLUGIN_EN == DEF_ENABLED) && (OS_PROBE_HOOKS_EN > 0)
+    OSProbe_TickHook();
+#endif
+    HAL_IncTick(); /* STM32CubeF4 library function call.                   */
+}
+#endif
+#endif

+ 215 - 215
User/conf/ucos/cpu_cfg.h → Project/conf/ucos/cpu_cfg.h

@@ -1,215 +1,215 @@
-/*
-*********************************************************************************************************
-*                                                uC/CPU
-*                                    CPU CONFIGURATION & PORT LAYER
-*
-*                          (c) Copyright 2004-2015; Micrium, Inc.; Weston, FL
-*
-*               All rights reserved.  Protected by international copyright laws.
-*
-*               uC/CPU is provided in source form to registered licensees ONLY.  It is 
-*               illegal to distribute this source code to any third party unless you receive 
-*               written permission by an authorized Micrium representative.  Knowledge of 
-*               the source code may NOT be used to develop a similar product.
-*
-*               Please help us continue to provide the Embedded community with the finest 
-*               software available.  Your honesty is greatly appreciated.
-*
-*               You can find our product's user manual, API reference, release notes and
-*               more information at https://doc.micrium.com.
-*               You can contact us at www.micrium.com.
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*
-*                                       CPU CONFIGURATION FILE
-*
-*                                              TEMPLATE
-*
-* Filename      : cpu_cfg.h
-* Version       : V1.30.02
-* Programmer(s) : SR
-*                 ITJ
-*                 JBL
-*********************************************************************************************************
-*/
-
-
-/*
-*********************************************************************************************************
-*                                               MODULE
-*********************************************************************************************************
-*/
-
-#ifndef  CPU_CFG_MODULE_PRESENT
-#define  CPU_CFG_MODULE_PRESENT
-
-
-/*
-*********************************************************************************************************
-*                                       CPU NAME CONFIGURATION
-*
-* Note(s) : (1) Configure CPU_CFG_NAME_EN to enable/disable CPU host name feature :
-*
-*               (a) CPU host name storage
-*               (b) CPU host name API functions
-*
-*           (2) Configure CPU_CFG_NAME_SIZE with the desired ASCII string size of the CPU host name, 
-*               including the terminating NULL character.
-*
-*               See also 'cpu_core.h  GLOBAL VARIABLES  Note #1'.
-*********************************************************************************************************
-*/
-
-                                                                /* Configure CPU host name feature (see Note #1) :      */
-#define  CPU_CFG_NAME_EN                        DEF_ENABLED
-                                                                /*   DEF_DISABLED  CPU host name DISABLED               */
-                                                                /*   DEF_ENABLED   CPU host name ENABLED                */
-
-                                                                /* Configure CPU host name ASCII string size ...        */
-#define  CPU_CFG_NAME_SIZE                                16    /* ... (see Note #2).                                   */
-
-
-/*
-*********************************************************************************************************
-*                                     CPU TIMESTAMP CONFIGURATION
-*
-* Note(s) : (1) Configure CPU_CFG_TS_xx_EN to enable/disable CPU timestamp features :
-*
-*               (a) CPU_CFG_TS_32_EN   enable/disable 32-bit CPU timestamp feature
-*               (b) CPU_CFG_TS_64_EN   enable/disable 64-bit CPU timestamp feature
-*
-*           (2) (a) Configure CPU_CFG_TS_TMR_SIZE with the CPU timestamp timer's word size :
-*
-*                       CPU_WORD_SIZE_08         8-bit word size
-*                       CPU_WORD_SIZE_16        16-bit word size
-*                       CPU_WORD_SIZE_32        32-bit word size
-*                       CPU_WORD_SIZE_64        64-bit word size
-*
-*               (b) If the size of the CPU timestamp timer is not a binary multiple of 8-bit octets 
-*                   (e.g. 20-bits or even 24-bits), then the next lower, binary-multiple octet word 
-*                   size SHOULD be configured (e.g. to 16-bits).  However, the minimum supported word 
-*                   size for CPU timestamp timers is 8-bits.
-*
-*                   See also 'cpu_core.h  FUNCTION PROTOTYPES  CPU_TS_TmrRd()  Note #2a'.
-*********************************************************************************************************
-*/
-
-                                                                /* Configure CPU timestamp features (see Note #1) :     */
-#define  CPU_CFG_TS_32_EN                       DEF_ENABLED
-#define  CPU_CFG_TS_64_EN                       DEF_DISABLED
-                                                                /*   DEF_DISABLED  CPU timestamps DISABLED              */
-                                                                /*   DEF_ENABLED   CPU timestamps ENABLED               */
-
-                                                                /* Configure CPU timestamp timer word size ...          */
-                                                                /* ... (see Note #2) :                                  */
-#define  CPU_CFG_TS_TMR_SIZE                    CPU_WORD_SIZE_32
-
-
-/*
-*********************************************************************************************************
-*                        CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION
-*
-* Note(s) : (1) (a) Configure CPU_CFG_INT_DIS_MEAS_EN to enable/disable measuring CPU's interrupts 
-*                   disabled time :
-*
-*                   (a)  Enabled,       if CPU_CFG_INT_DIS_MEAS_EN      #define'd in 'cpu_cfg.h'
-*
-*                   (b) Disabled,       if CPU_CFG_INT_DIS_MEAS_EN  NOT #define'd in 'cpu_cfg.h'
-*
-*                   See also 'cpu_core.h  FUNCTION PROTOTYPES  Note #1'.
-*
-*               (b) Configure CPU_CFG_INT_DIS_MEAS_OVRHD_NBR with the number of times to measure & 
-*                   average the interrupts disabled time measurements overhead.
-*
-*                   See also 'cpu_core.c  CPU_IntDisMeasInit()  Note #3a'.
-*********************************************************************************************************
-*/
-
-#if 1                                                           /* Configure CPU interrupts disabled time ...           */
-#define  CPU_CFG_INT_DIS_MEAS_EN                                /* ... measurements feature (see Note #1a).             */
-#endif
-
-                                                                /* Configure number of interrupts disabled overhead ... */
-#define  CPU_CFG_INT_DIS_MEAS_OVRHD_NBR                    1u   /* ... time measurements (see Note #1b).                */
-
-
-/*
-*********************************************************************************************************
-*                                    CPU COUNT ZEROS CONFIGURATION
-*
-* Note(s) : (1) (a) Configure CPU_CFG_LEAD_ZEROS_ASM_PRESENT  to define count leading  zeros bits 
-*                   function(s) in :
-*
-*                   (1) 'cpu_a.asm',  if CPU_CFG_LEAD_ZEROS_ASM_PRESENT       #define'd in 'cpu.h'/
-*                                         'cpu_cfg.h' to enable assembly-optimized function(s)
-*
-*                   (2) 'cpu_core.c', if CPU_CFG_LEAD_ZEROS_ASM_PRESENT   NOT #define'd in 'cpu.h'/
-*                                         'cpu_cfg.h' to enable C-source-optimized function(s) otherwise
-*
-*               (b) Configure CPU_CFG_TRAIL_ZEROS_ASM_PRESENT to define count trailing zeros bits 
-*                   function(s) in :
-*
-*                   (1) 'cpu_a.asm',  if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT      #define'd in 'cpu.h'/
-*                                         'cpu_cfg.h' to enable assembly-optimized function(s)
-*
-*                   (2) 'cpu_core.c', if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT  NOT #define'd in 'cpu.h'/
-*                                         'cpu_cfg.h' to enable C-source-optimized function(s) otherwise
-*********************************************************************************************************
-*/
-
-#if 1                                                           /* Configure CPU count leading  zeros bits ...          */
-#define  CPU_CFG_LEAD_ZEROS_ASM_PRESENT                         /* ... assembly-version (see Note #1a).                 */
-#endif
-
-#if 0                                                           /* Configure CPU count trailing zeros bits ...          */
-#define  CPU_CFG_TRAIL_ZEROS_ASM_PRESENT                        /* ... assembly-version (see Note #1b).                 */
-#endif
-
-
-/*
-*********************************************************************************************************
-*                                      CPU ENDIAN TYPE OVERRIDE
-*
-* Note(s) : (1) Configure CPU_CFG_ENDIAN_TYPE to override the default CPU endian type defined in cpu.h.
-*
-*               (a) CPU_ENDIAN_TYPE_BIG         Big-   endian word order (CPU words' most  significant
-*                                                                         octet @ lowest memory address)
-*               (b) CPU_ENDIAN_TYPE_LITTLE      Little-endian word order (CPU words' least significant
-*                                                                         octet @ lowest memory address)
-*
-*           (2) Defining CPU_CFG_ENDIAN_TYPE here is only valid for supported bi-endian architectures.
-*               See  'cpu.h  CPU WORD CONFIGURATION  Note #3' for details
-*********************************************************************************************************
-*/
-
-#if 0
-#define  CPU_CFG_ENDIAN_TYPE            CPU_ENDIAN_TYPE_BIG     /* Defines CPU data    word-memory order (see Note #2). */
-#endif
-
-
-/*
-*********************************************************************************************************
-*                                          CACHE MANAGEMENT
-*
-* Note(s) : (1) Configure CPU_CFG_CACHE_MGMT_EN to enable the cache managment API.
-
-*
-*           (2) Defining CPU_CFG_CACHE_MGMT_EN to DEF_ENABLED only enable the cache management function.
-*               Cache are assumed to be configured and enabled by the time CPU_init() is called.
-*********************************************************************************************************
-*/
-
-#define  CPU_CFG_CACHE_MGMT_EN            DEF_DISABLED          /* Defines CPU data    word-memory order (see Note #1). */
-
-
-/*
-*********************************************************************************************************
-*                                             MODULE END
-*********************************************************************************************************
-*/
-
-#endif                                                          /* End of CPU cfg module include.                       */
-
+/*
+*********************************************************************************************************
+*                                                uC/CPU
+*                                    CPU CONFIGURATION & PORT LAYER
+*
+*                          (c) Copyright 2004-2015; Micrium, Inc.; Weston, FL
+*
+*               All rights reserved.  Protected by international copyright laws.
+*
+*               uC/CPU is provided in source form to registered licensees ONLY.  It is 
+*               illegal to distribute this source code to any third party unless you receive 
+*               written permission by an authorized Micrium representative.  Knowledge of 
+*               the source code may NOT be used to develop a similar product.
+*
+*               Please help us continue to provide the Embedded community with the finest 
+*               software available.  Your honesty is greatly appreciated.
+*
+*               You can find our product's user manual, API reference, release notes and
+*               more information at https://doc.micrium.com.
+*               You can contact us at www.micrium.com.
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*
+*                                       CPU CONFIGURATION FILE
+*
+*                                              TEMPLATE
+*
+* Filename      : cpu_cfg.h
+* Version       : V1.30.02
+* Programmer(s) : SR
+*                 ITJ
+*                 JBL
+*********************************************************************************************************
+*/
+
+
+/*
+*********************************************************************************************************
+*                                               MODULE
+*********************************************************************************************************
+*/
+
+#ifndef  CPU_CFG_MODULE_PRESENT
+#define  CPU_CFG_MODULE_PRESENT
+
+
+/*
+*********************************************************************************************************
+*                                       CPU NAME CONFIGURATION
+*
+* Note(s) : (1) Configure CPU_CFG_NAME_EN to enable/disable CPU host name feature :
+*
+*               (a) CPU host name storage
+*               (b) CPU host name API functions
+*
+*           (2) Configure CPU_CFG_NAME_SIZE with the desired ASCII string size of the CPU host name, 
+*               including the terminating NULL character.
+*
+*               See also 'cpu_core.h  GLOBAL VARIABLES  Note #1'.
+*********************************************************************************************************
+*/
+
+                                                                /* Configure CPU host name feature (see Note #1) :      */
+#define  CPU_CFG_NAME_EN                        DEF_ENABLED
+                                                                /*   DEF_DISABLED  CPU host name DISABLED               */
+                                                                /*   DEF_ENABLED   CPU host name ENABLED                */
+
+                                                                /* Configure CPU host name ASCII string size ...        */
+#define  CPU_CFG_NAME_SIZE                                16    /* ... (see Note #2).                                   */
+
+
+/*
+*********************************************************************************************************
+*                                     CPU TIMESTAMP CONFIGURATION
+*
+* Note(s) : (1) Configure CPU_CFG_TS_xx_EN to enable/disable CPU timestamp features :
+*
+*               (a) CPU_CFG_TS_32_EN   enable/disable 32-bit CPU timestamp feature
+*               (b) CPU_CFG_TS_64_EN   enable/disable 64-bit CPU timestamp feature
+*
+*           (2) (a) Configure CPU_CFG_TS_TMR_SIZE with the CPU timestamp timer's word size :
+*
+*                       CPU_WORD_SIZE_08         8-bit word size
+*                       CPU_WORD_SIZE_16        16-bit word size
+*                       CPU_WORD_SIZE_32        32-bit word size
+*                       CPU_WORD_SIZE_64        64-bit word size
+*
+*               (b) If the size of the CPU timestamp timer is not a binary multiple of 8-bit octets 
+*                   (e.g. 20-bits or even 24-bits), then the next lower, binary-multiple octet word 
+*                   size SHOULD be configured (e.g. to 16-bits).  However, the minimum supported word 
+*                   size for CPU timestamp timers is 8-bits.
+*
+*                   See also 'cpu_core.h  FUNCTION PROTOTYPES  CPU_TS_TmrRd()  Note #2a'.
+*********************************************************************************************************
+*/
+
+                                                                /* Configure CPU timestamp features (see Note #1) :     */
+#define  CPU_CFG_TS_32_EN                       DEF_ENABLED
+#define  CPU_CFG_TS_64_EN                       DEF_DISABLED
+                                                                /*   DEF_DISABLED  CPU timestamps DISABLED              */
+                                                                /*   DEF_ENABLED   CPU timestamps ENABLED               */
+
+                                                                /* Configure CPU timestamp timer word size ...          */
+                                                                /* ... (see Note #2) :                                  */
+#define  CPU_CFG_TS_TMR_SIZE                    CPU_WORD_SIZE_32
+
+
+/*
+*********************************************************************************************************
+*                        CPU INTERRUPTS DISABLED TIME MEASUREMENT CONFIGURATION
+*
+* Note(s) : (1) (a) Configure CPU_CFG_INT_DIS_MEAS_EN to enable/disable measuring CPU's interrupts 
+*                   disabled time :
+*
+*                   (a)  Enabled,       if CPU_CFG_INT_DIS_MEAS_EN      #define'd in 'cpu_cfg.h'
+*
+*                   (b) Disabled,       if CPU_CFG_INT_DIS_MEAS_EN  NOT #define'd in 'cpu_cfg.h'
+*
+*                   See also 'cpu_core.h  FUNCTION PROTOTYPES  Note #1'.
+*
+*               (b) Configure CPU_CFG_INT_DIS_MEAS_OVRHD_NBR with the number of times to measure & 
+*                   average the interrupts disabled time measurements overhead.
+*
+*                   See also 'cpu_core.c  CPU_IntDisMeasInit()  Note #3a'.
+*********************************************************************************************************
+*/
+
+#if 1                                                           /* Configure CPU interrupts disabled time ...           */
+#define  CPU_CFG_INT_DIS_MEAS_EN                                /* ... measurements feature (see Note #1a).             */
+#endif
+
+                                                                /* Configure number of interrupts disabled overhead ... */
+#define  CPU_CFG_INT_DIS_MEAS_OVRHD_NBR                    1u   /* ... time measurements (see Note #1b).                */
+
+
+/*
+*********************************************************************************************************
+*                                    CPU COUNT ZEROS CONFIGURATION
+*
+* Note(s) : (1) (a) Configure CPU_CFG_LEAD_ZEROS_ASM_PRESENT  to define count leading  zeros bits 
+*                   function(s) in :
+*
+*                   (1) 'cpu_a.asm',  if CPU_CFG_LEAD_ZEROS_ASM_PRESENT       #define'd in 'cpu.h'/
+*                                         'cpu_cfg.h' to enable assembly-optimized function(s)
+*
+*                   (2) 'cpu_core.c', if CPU_CFG_LEAD_ZEROS_ASM_PRESENT   NOT #define'd in 'cpu.h'/
+*                                         'cpu_cfg.h' to enable C-source-optimized function(s) otherwise
+*
+*               (b) Configure CPU_CFG_TRAIL_ZEROS_ASM_PRESENT to define count trailing zeros bits 
+*                   function(s) in :
+*
+*                   (1) 'cpu_a.asm',  if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT      #define'd in 'cpu.h'/
+*                                         'cpu_cfg.h' to enable assembly-optimized function(s)
+*
+*                   (2) 'cpu_core.c', if CPU_CFG_TRAIL_ZEROS_ASM_PRESENT  NOT #define'd in 'cpu.h'/
+*                                         'cpu_cfg.h' to enable C-source-optimized function(s) otherwise
+*********************************************************************************************************
+*/
+
+#if 1                                                           /* Configure CPU count leading  zeros bits ...          */
+#define  CPU_CFG_LEAD_ZEROS_ASM_PRESENT                         /* ... assembly-version (see Note #1a).                 */
+#endif
+
+#if 0                                                           /* Configure CPU count trailing zeros bits ...          */
+#define  CPU_CFG_TRAIL_ZEROS_ASM_PRESENT                        /* ... assembly-version (see Note #1b).                 */
+#endif
+
+
+/*
+*********************************************************************************************************
+*                                      CPU ENDIAN TYPE OVERRIDE
+*
+* Note(s) : (1) Configure CPU_CFG_ENDIAN_TYPE to override the default CPU endian type defined in cpu.h.
+*
+*               (a) CPU_ENDIAN_TYPE_BIG         Big-   endian word order (CPU words' most  significant
+*                                                                         octet @ lowest memory address)
+*               (b) CPU_ENDIAN_TYPE_LITTLE      Little-endian word order (CPU words' least significant
+*                                                                         octet @ lowest memory address)
+*
+*           (2) Defining CPU_CFG_ENDIAN_TYPE here is only valid for supported bi-endian architectures.
+*               See  'cpu.h  CPU WORD CONFIGURATION  Note #3' for details
+*********************************************************************************************************
+*/
+
+#if 0
+#define  CPU_CFG_ENDIAN_TYPE            CPU_ENDIAN_TYPE_BIG     /* Defines CPU data    word-memory order (see Note #2). */
+#endif
+
+
+/*
+*********************************************************************************************************
+*                                          CACHE MANAGEMENT
+*
+* Note(s) : (1) Configure CPU_CFG_CACHE_MGMT_EN to enable the cache managment API.
+
+*
+*           (2) Defining CPU_CFG_CACHE_MGMT_EN to DEF_ENABLED only enable the cache management function.
+*               Cache are assumed to be configured and enabled by the time CPU_init() is called.
+*********************************************************************************************************
+*/
+
+#define  CPU_CFG_CACHE_MGMT_EN            DEF_DISABLED          /* Defines CPU data    word-memory order (see Note #1). */
+
+
+/*
+*********************************************************************************************************
+*                                             MODULE END
+*********************************************************************************************************
+*/
+
+#endif                                                          /* End of CPU cfg module include.                       */
+

+ 59 - 59
User/conf/ucos/includes.h → Project/conf/ucos/includes.h

@@ -1,59 +1,59 @@
-/*
-*********************************************************************************************************
-*                                              EXAMPLE CODE
-*
-*                          (c) Copyright 2003-2013; Micrium, Inc.; Weston, FL
-*
-*               All rights reserved.  Protected by international copyright laws.
-*               Knowledge of the source code may NOT be used to develop a similar product.
-*               Please help us continue to provide the Embedded community with the finest
-*               software available.  Your honesty is greatly appreciated.
-*********************************************************************************************************
-*/
-#ifndef __INCLUDES_H__
-#define __INCLUDES_H__
-
-/*
-*********************************************************************************************************
-*                                         STANDARD LIBRARIES
-*********************************************************************************************************
-*/
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-
-/*
-*********************************************************************************************************
-*                                              LIBRARIES
-*********************************************************************************************************
-*/
-
-#include <cpu.h>
-#include <lib_def.h>
-#include <lib_ascii.h>
-#include <lib_math.h>
-#include <lib_mem.h>
-#include <lib_str.h>
-
-/*
-*********************************************************************************************************
-*                                              APP / BSP
-*********************************************************************************************************
-*/
-
-#include <bsp.h>
-
-/*
-*********************************************************************************************************
-*                                                 OS
-*********************************************************************************************************
-*/
-
-#include <ucos_ii.h>
-
-#define TRUE 1
-#define FALSE 0
-
-#endif
+/*
+*********************************************************************************************************
+*                                              EXAMPLE CODE
+*
+*                          (c) Copyright 2003-2013; Micrium, Inc.; Weston, FL
+*
+*               All rights reserved.  Protected by international copyright laws.
+*               Knowledge of the source code may NOT be used to develop a similar product.
+*               Please help us continue to provide the Embedded community with the finest
+*               software available.  Your honesty is greatly appreciated.
+*********************************************************************************************************
+*/
+#ifndef __INCLUDES_H__
+#define __INCLUDES_H__
+
+/*
+*********************************************************************************************************
+*                                         STANDARD LIBRARIES
+*********************************************************************************************************
+*/
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+/*
+*********************************************************************************************************
+*                                              LIBRARIES
+*********************************************************************************************************
+*/
+
+#include <cpu.h>
+#include <lib_def.h>
+#include <lib_ascii.h>
+#include <lib_math.h>
+#include <lib_mem.h>
+#include <lib_str.h>
+
+/*
+*********************************************************************************************************
+*                                              APP / BSP
+*********************************************************************************************************
+*/
+
+#include <bsp.h>
+
+/*
+*********************************************************************************************************
+*                                                 OS
+*********************************************************************************************************
+*/
+
+#include <ucos_ii.h>
+
+#define TRUE 1
+#define FALSE 0
+
+#endif

+ 171 - 171
User/conf/ucos/lib_cfg.h → Project/conf/ucos/lib_cfg.h

@@ -1,171 +1,171 @@
-/*
-*********************************************************************************************************
-*                                            EXAMPLE CODE
-*
-*               This file is provided as an example on how to use Micrium products.
-*
-*               Please feel free to use any application code labeled as 'EXAMPLE CODE' in
-*               your application products.  Example code may be used as is, in whole or in
-*               part, or may be used as a reference only. This file can be modified as
-*               required to meet the end-product requirements.
-*
-*               Please help us continue to provide the Embedded community with the finest
-*               software available.  Your honesty is greatly appreciated.
-*
-*               You can find information about uC/LIB by visiting doc.micrium.com.
-*               You can contact us at: http://www.micrium.com
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*
-*                                  CUSTOM LIBRARY CONFIGURATION FILE
-*
-*                                              TEMPLATE
-*
-* Filename      : lib_cfg.h
-* Version       : V1.38.01.00
-* Programmer(s) : FBJ
-*                 JFD
-*********************************************************************************************************
-*/
-
-
-/*
-*********************************************************************************************************
-*                                               MODULE
-*********************************************************************************************************
-*/
-
-#ifndef  LIB_CFG_MODULE_PRESENT
-#define  LIB_CFG_MODULE_PRESENT
-
-
-/*
-*********************************************************************************************************
-*********************************************************************************************************
-*                                    MEMORY LIBRARY CONFIGURATION
-*********************************************************************************************************
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*                             MEMORY LIBRARY ARGUMENT CHECK CONFIGURATION
-*
-* Note(s) : (1) Configure LIB_MEM_CFG_ARG_CHK_EXT_EN to enable/disable the memory library suite external
-*               argument check feature :
-*
-*               (a) When ENABLED,     arguments received from any port interface provided by the developer
-*                   or application are checked/validated.
-*
-*               (b) When DISABLED, NO arguments received from any port interface provided by the developer
-*                   or application are checked/validated.
-*********************************************************************************************************
-*/
-
-                                                                /* External argument check.                             */
-                                                                /* Indicates if arguments received from any port ...    */
-                                                                /* ... interface provided by the developer or ...       */
-                                                                /* ... application are checked/validated.               */
-#define  LIB_MEM_CFG_ARG_CHK_EXT_EN         DEF_DISABLED
-
-
-/*
-*********************************************************************************************************
-*                         MEMORY LIBRARY ASSEMBLY OPTIMIZATION CONFIGURATION
-*
-* Note(s) : (1) Configure LIB_MEM_CFG_OPTIMIZE_ASM_EN to enable/disable assembly-optimized memory function(s).
-*********************************************************************************************************
-*/
-
-                                                                /* Assembly-optimized function(s).                      */
-                                                                /* Enable/disable assembly-optimized memory ...         */
-                                                                /* ... function(s). [see Note #1]                       */
-#define  LIB_MEM_CFG_OPTIMIZE_ASM_EN        DEF_ENABLED
-
-
-/*
-*********************************************************************************************************
-*                                   MEMORY ALLOCATION CONFIGURATION
-*
-* Note(s) : (1) Configure LIB_MEM_CFG_DBG_INFO_EN to enable/disable memory allocation usage tracking
-*               that associates a name with each segment or dynamic pool allocated.
-*
-*           (2) (a) Configure LIB_MEM_CFG_HEAP_SIZE with the desired size of heap memory (in octets).
-*
-*               (b) Configure LIB_MEM_CFG_HEAP_BASE_ADDR to specify a base address for heap memory :
-*
-*                   (1) Heap initialized to specified application memory, if LIB_MEM_CFG_HEAP_BASE_ADDR
-*                                                                                #define'd in 'lib_cfg.h';
-*                                                                         CANNOT #define to address 0x0
-*
-*                   (2) Heap declared to Mem_Heap[] in 'lib_mem.c',       if LIB_MEM_CFG_HEAP_BASE_ADDR
-*                                                                            NOT #define'd in 'lib_cfg.h'
-*********************************************************************************************************
-*/
-
-                                                                /* Allocation debugging information.                    */
-                                                                /* Enable/disable allocation of debug information ...   */
-                                                                /* ... associated to each memory allocation.            */
-#define  LIB_MEM_CFG_DBG_INFO_EN            DEF_DISABLED
-
-
-                                                                /* Heap memory size (in bytes).                         */
-                                                                /* Configure the desired size of the heap memory. ...   */
-                                                                /* ... Set to 0 to disable heap allocation features.    */
-#define  LIB_MEM_CFG_HEAP_SIZE             (1u * 1024u)
-
-
-                                                                /* Heap memory padding alignment (in bytes).            */
-                                                                /* Configure the desired size of padding alignment ...  */
-                                                                /* ... of each buffer allocated from the heap.          */
-#define  LIB_MEM_CFG_HEAP_PADDING_ALIGN     LIB_MEM_PADDING_ALIGN_NONE
-
-#if 0                                                           /* Remove this to have heap alloc at specified addr.    */
-#define  LIB_MEM_CFG_HEAP_BASE_ADDR         0x00000000          /* Configure heap memory base address (see Note #2b).   */
-#endif
-
-
-/*
-*********************************************************************************************************
-*********************************************************************************************************
-*                                    STRING LIBRARY CONFIGURATION
-*********************************************************************************************************
-*********************************************************************************************************
-*/
-
-/*
-*********************************************************************************************************
-*                                 STRING FLOATING POINT CONFIGURATION
-*
-* Note(s) : (1) Configure LIB_STR_CFG_FP_EN to enable/disable floating point string function(s).
-*
-*           (2) Configure LIB_STR_CFG_FP_MAX_NBR_DIG_SIG to configure the maximum number of significant
-*               digits to calculate &/or display for floating point string function(s).
-*
-*               See also 'lib_str.h  STRING FLOATING POINT DEFINES  Note #1'.
-*********************************************************************************************************
-*/
-
-                                                                /* Floating point feature(s).                           */
-                                                                /* Enable/disable floating point to string functions.   */
-#define  LIB_STR_CFG_FP_EN                      DEF_DISABLED
-
-
-                                                                /* Floating point number of significant digits.         */
-                                                                /* Configure the maximum number of significant ...      */
-                                                                /* ... digits to calculate &/or display for ...         */
-                                                                /* ... floating point string function(s).               */
-#define  LIB_STR_CFG_FP_MAX_NBR_DIG_SIG         LIB_STR_FP_MAX_NBR_DIG_SIG_DFLT
-
-
-/*
-*********************************************************************************************************
-*                                             MODULE END
-*********************************************************************************************************
-*/
-
-#endif                                                          /* End of lib cfg module include.                       */
-
+/*
+*********************************************************************************************************
+*                                            EXAMPLE CODE
+*
+*               This file is provided as an example on how to use Micrium products.
+*
+*               Please feel free to use any application code labeled as 'EXAMPLE CODE' in
+*               your application products.  Example code may be used as is, in whole or in
+*               part, or may be used as a reference only. This file can be modified as
+*               required to meet the end-product requirements.
+*
+*               Please help us continue to provide the Embedded community with the finest
+*               software available.  Your honesty is greatly appreciated.
+*
+*               You can find information about uC/LIB by visiting doc.micrium.com.
+*               You can contact us at: http://www.micrium.com
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*
+*                                  CUSTOM LIBRARY CONFIGURATION FILE
+*
+*                                              TEMPLATE
+*
+* Filename      : lib_cfg.h
+* Version       : V1.38.01.00
+* Programmer(s) : FBJ
+*                 JFD
+*********************************************************************************************************
+*/
+
+
+/*
+*********************************************************************************************************
+*                                               MODULE
+*********************************************************************************************************
+*/
+
+#ifndef  LIB_CFG_MODULE_PRESENT
+#define  LIB_CFG_MODULE_PRESENT
+
+
+/*
+*********************************************************************************************************
+*********************************************************************************************************
+*                                    MEMORY LIBRARY CONFIGURATION
+*********************************************************************************************************
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*                             MEMORY LIBRARY ARGUMENT CHECK CONFIGURATION
+*
+* Note(s) : (1) Configure LIB_MEM_CFG_ARG_CHK_EXT_EN to enable/disable the memory library suite external
+*               argument check feature :
+*
+*               (a) When ENABLED,     arguments received from any port interface provided by the developer
+*                   or application are checked/validated.
+*
+*               (b) When DISABLED, NO arguments received from any port interface provided by the developer
+*                   or application are checked/validated.
+*********************************************************************************************************
+*/
+
+                                                                /* External argument check.                             */
+                                                                /* Indicates if arguments received from any port ...    */
+                                                                /* ... interface provided by the developer or ...       */
+                                                                /* ... application are checked/validated.               */
+#define  LIB_MEM_CFG_ARG_CHK_EXT_EN         DEF_DISABLED
+
+
+/*
+*********************************************************************************************************
+*                         MEMORY LIBRARY ASSEMBLY OPTIMIZATION CONFIGURATION
+*
+* Note(s) : (1) Configure LIB_MEM_CFG_OPTIMIZE_ASM_EN to enable/disable assembly-optimized memory function(s).
+*********************************************************************************************************
+*/
+
+                                                                /* Assembly-optimized function(s).                      */
+                                                                /* Enable/disable assembly-optimized memory ...         */
+                                                                /* ... function(s). [see Note #1]                       */
+#define  LIB_MEM_CFG_OPTIMIZE_ASM_EN        DEF_ENABLED
+
+
+/*
+*********************************************************************************************************
+*                                   MEMORY ALLOCATION CONFIGURATION
+*
+* Note(s) : (1) Configure LIB_MEM_CFG_DBG_INFO_EN to enable/disable memory allocation usage tracking
+*               that associates a name with each segment or dynamic pool allocated.
+*
+*           (2) (a) Configure LIB_MEM_CFG_HEAP_SIZE with the desired size of heap memory (in octets).
+*
+*               (b) Configure LIB_MEM_CFG_HEAP_BASE_ADDR to specify a base address for heap memory :
+*
+*                   (1) Heap initialized to specified application memory, if LIB_MEM_CFG_HEAP_BASE_ADDR
+*                                                                                #define'd in 'lib_cfg.h';
+*                                                                         CANNOT #define to address 0x0
+*
+*                   (2) Heap declared to Mem_Heap[] in 'lib_mem.c',       if LIB_MEM_CFG_HEAP_BASE_ADDR
+*                                                                            NOT #define'd in 'lib_cfg.h'
+*********************************************************************************************************
+*/
+
+                                                                /* Allocation debugging information.                    */
+                                                                /* Enable/disable allocation of debug information ...   */
+                                                                /* ... associated to each memory allocation.            */
+#define  LIB_MEM_CFG_DBG_INFO_EN            DEF_DISABLED
+
+
+                                                                /* Heap memory size (in bytes).                         */
+                                                                /* Configure the desired size of the heap memory. ...   */
+                                                                /* ... Set to 0 to disable heap allocation features.    */
+#define  LIB_MEM_CFG_HEAP_SIZE             (1u * 1024u)
+
+
+                                                                /* Heap memory padding alignment (in bytes).            */
+                                                                /* Configure the desired size of padding alignment ...  */
+                                                                /* ... of each buffer allocated from the heap.          */
+#define  LIB_MEM_CFG_HEAP_PADDING_ALIGN     LIB_MEM_PADDING_ALIGN_NONE
+
+#if 0                                                           /* Remove this to have heap alloc at specified addr.    */
+#define  LIB_MEM_CFG_HEAP_BASE_ADDR         0x00000000          /* Configure heap memory base address (see Note #2b).   */
+#endif
+
+
+/*
+*********************************************************************************************************
+*********************************************************************************************************
+*                                    STRING LIBRARY CONFIGURATION
+*********************************************************************************************************
+*********************************************************************************************************
+*/
+
+/*
+*********************************************************************************************************
+*                                 STRING FLOATING POINT CONFIGURATION
+*
+* Note(s) : (1) Configure LIB_STR_CFG_FP_EN to enable/disable floating point string function(s).
+*
+*           (2) Configure LIB_STR_CFG_FP_MAX_NBR_DIG_SIG to configure the maximum number of significant
+*               digits to calculate &/or display for floating point string function(s).
+*
+*               See also 'lib_str.h  STRING FLOATING POINT DEFINES  Note #1'.
+*********************************************************************************************************
+*/
+
+                                                                /* Floating point feature(s).                           */
+                                                                /* Enable/disable floating point to string functions.   */
+#define  LIB_STR_CFG_FP_EN                      DEF_DISABLED
+
+
+                                                                /* Floating point number of significant digits.         */
+                                                                /* Configure the maximum number of significant ...      */
+                                                                /* ... digits to calculate &/or display for ...         */
+                                                                /* ... floating point string function(s).               */
+#define  LIB_STR_CFG_FP_MAX_NBR_DIG_SIG         LIB_STR_FP_MAX_NBR_DIG_SIG_DFLT
+
+
+/*
+*********************************************************************************************************
+*                                             MODULE END
+*********************************************************************************************************
+*/
+
+#endif                                                          /* End of lib cfg module include.                       */
+

+ 141 - 141
User/conf/ucos/os_cfg.h → Project/conf/ucos/os_cfg.h

@@ -1,141 +1,141 @@
-/*
-*********************************************************************************************************
-*                                                uC/OS-II
-*                                          The Real-Time Kernel
-*                                  uC/OS-II Configuration File for V2.8x
-*
-*                               (c) Copyright 2005-2009, Micrium, Weston, FL
-*                                          All Rights Reserved
-*
-*
-* File    : OS_CFG.H
-* By      : Jean J. Labrosse
-* Version : V2.88
-*
-* LICENSING TERMS:
-* ---------------
-*   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.
-* If you plan on using  uC/OS-II  in a commercial product you need to contact Micriµm to properly license
-* its use in your product. We provide ALL the source code for your convenience and to help you experience
-* uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a
-* licensing fee.
-*********************************************************************************************************
-*/
-
-#ifndef OS_CFG_H
-#define OS_CFG_H
-
-
-                                       /* ---------------------- MISCELLANEOUS ----------------------- */
-#define OS_APP_HOOKS_EN           0    /* Application-defined hooks are called from the uC/OS-II hooks */
-#define OS_ARG_CHK_EN             0    /* Enable (1) or Disable (0) argument checking                  */
-#define OS_CPU_HOOKS_EN           1    /* uC/OS-II hooks are found in the processor port files         */
-
-#define OS_DEBUG_EN               1    /* Enable(1) debug variables                                    */
-
-#define OS_EVENT_MULTI_EN         1    /* Include code for OSEventPendMulti()                          */
-#define OS_EVENT_NAME_EN          1    /* Enable names for Sem, Mutex, Mbox and Q                      */
-
-#define OS_LOWEST_PRIO           63    /* Defines the lowest priority that can be assigned ...         */
-                                       /* ... MUST NEVER be higher than 254!                           */
-
-#define OS_MAX_EVENTS            40    /* Max. number of event control blocks in your application      */
-#define OS_MAX_FLAGS              5    /* Max. number of Event Flag Groups    in your application      */
-#define OS_MAX_MEM_PART           5    /* Max. number of memory partitions                             */
-#define OS_MAX_QS                 8    /* Max. number of queue control blocks in your application      */
-#define OS_MAX_TASKS             20    /* Max. number of tasks in your application, MUST be >= 2       */
-
-#define OS_SCHED_LOCK_EN          1    /* Include code for OSSchedLock() and OSSchedUnlock()           */
-
-#define OS_TICK_STEP_EN           1    /* Enable tick stepping feature for uC/OS-View                  */
-#define OS_TICKS_PER_SEC        1000//200    /* Set the number of ticks in one second                        */     
-                                       /* --------------------- TASK STACK SIZE ---------------------- */
-#define OS_TASK_TMR_STK_SIZE    128    /* Timer      task stack size (# of OS_STK wide entries)        */
-#define OS_TASK_STAT_STK_SIZE   128    /* Statistics task stack size (# of OS_STK wide entries)        */
-#define OS_TASK_IDLE_STK_SIZE   128    /* Idle       task stack size (# of OS_STK wide entries)        */
-
-
-                                       /* --------------------- TASK MANAGEMENT ---------------------- */
-#define OS_TASK_CHANGE_PRIO_EN    1    /*     Include code for OSTaskChangePrio()                      */
-#define OS_TASK_CREATE_EN         1    /*     Include code for OSTaskCreate()                          */
-#define OS_TASK_CREATE_EXT_EN     1    /*     Include code for OSTaskCreateExt()                       */
-#define OS_TASK_DEL_EN            1    /*     Include code for OSTaskDel()                             */
-#define OS_TASK_NAME_EN           1    /*     Enable task names                                        */
-#define OS_TASK_PROFILE_EN        1    /*     Include variables in OS_TCB for profiling                */
-#define OS_TASK_QUERY_EN          1    /*     Include code for OSTaskQuery()                           */
-#define OS_TASK_STAT_EN           1    /*     Enable (1) or Disable(0) the statistics task             */
-#define OS_TASK_STAT_STK_CHK_EN   1    /*     Check task stacks from statistic task                    */
-#define OS_TASK_SUSPEND_EN        1    /*     Include code for OSTaskSuspend() and OSTaskResume()      */
-#define OS_TASK_SW_HOOK_EN        1    /*     Include code for OSTaskSwHook()                          */
-#define OS_TASK_REG_TBL_SIZE      1    /*     Size of task variables array (#of INT32U entries)        */
-
-
-                                       /* ----------------------- EVENT FLAGS ------------------------ */
-#define OS_FLAG_EN                1    /* Enable (1) or Disable (0) code generation for EVENT FLAGS    */
-#define OS_FLAG_ACCEPT_EN         1    /*     Include code for OSFlagAccept()                          */
-#define OS_FLAG_DEL_EN            1    /*     Include code for OSFlagDel()                             */
-#define OS_FLAG_NAME_EN           1    /*     Enable names for event flag group                        */
-#define OS_FLAG_QUERY_EN          1    /*     Include code for OSFlagQuery()                           */
-#define OS_FLAG_WAIT_CLR_EN       1    /* Include code for Wait on Clear EVENT FLAGS                   */
-#define OS_FLAGS_NBITS           16    /* Size in #bits of OS_FLAGS data type (8, 16 or 32)            */
-
-
-                                       /* -------------------- MESSAGE MAILBOXES --------------------- */
-#define OS_MBOX_EN                1    /* Enable (1) or Disable (0) code generation for MAILBOXES      */
-#define OS_MBOX_ACCEPT_EN         1    /*     Include code for OSMboxAccept()                          */
-#define OS_MBOX_DEL_EN            1    /*     Include code for OSMboxDel()                             */
-#define OS_MBOX_PEND_ABORT_EN     1    /*     Include code for OSMboxPendAbort()                       */
-#define OS_MBOX_POST_EN           1    /*     Include code for OSMboxPost()                            */
-#define OS_MBOX_POST_OPT_EN       1    /*     Include code for OSMboxPostOpt()                         */
-#define OS_MBOX_QUERY_EN          1    /*     Include code for OSMboxQuery()                           */
-
-
-                                       /* --------------------- MEMORY MANAGEMENT -------------------- */
-#define OS_MEM_EN                 1    /* Enable (1) or Disable (0) code generation for MEMORY MANAGER */
-#define OS_MEM_NAME_EN            1    /*     Enable memory partition names                            */
-#define OS_MEM_QUERY_EN           1    /*     Include code for OSMemQuery()                            */
-
-
-                                       /* ---------------- MUTUAL EXCLUSION SEMAPHORES --------------- */
-#define OS_MUTEX_EN               1    /* Enable (1) or Disable (0) code generation for MUTEX          */
-#define OS_MUTEX_ACCEPT_EN        1    /*     Include code for OSMutexAccept()                         */
-#define OS_MUTEX_DEL_EN           1    /*     Include code for OSMutexDel()                            */
-#define OS_MUTEX_QUERY_EN         1    /*     Include code for OSMutexQuery()                          */
-
-
-                                       /* ---------------------- MESSAGE QUEUES ---------------------- */
-#define OS_Q_EN                   1    /* Enable (1) or Disable (0) code generation for QUEUES         */
-#define OS_Q_ACCEPT_EN            1    /*     Include code for OSQAccept()                             */
-#define OS_Q_DEL_EN               1    /*     Include code for OSQDel()                                */
-#define OS_Q_FLUSH_EN             1    /*     Include code for OSQFlush()                              */
-#define OS_Q_PEND_ABORT_EN        1    /*     Include code for OSQPendAbort()                          */
-#define OS_Q_POST_EN              1    /*     Include code for OSQPost()                               */
-#define OS_Q_POST_FRONT_EN        1    /*     Include code for OSQPostFront()                          */
-#define OS_Q_POST_OPT_EN          1    /*     Include code for OSQPostOpt()                            */
-#define OS_Q_QUERY_EN             1    /*     Include code for OSQQuery()                              */
-
-
-                                       /* ------------------------ SEMAPHORES ------------------------ */
-#define OS_SEM_EN                 1    /* Enable (1) or Disable (0) code generation for SEMAPHORES     */
-#define OS_SEM_ACCEPT_EN          1    /*    Include code for OSSemAccept()                            */
-#define OS_SEM_DEL_EN             1    /*    Include code for OSSemDel()                               */
-#define OS_SEM_PEND_ABORT_EN      1    /*    Include code for OSSemPendAbort()                         */
-#define OS_SEM_QUERY_EN           1    /*    Include code for OSSemQuery()                             */
-#define OS_SEM_SET_EN             1    /*    Include code for OSSemSet()                               */
-
-
-                                       /* --------------------- TIME MANAGEMENT ---------------------- */
-#define OS_TIME_DLY_HMSM_EN       1    /*     Include code for OSTimeDlyHMSM()                         */
-#define OS_TIME_DLY_RESUME_EN     1    /*     Include code for OSTimeDlyResume()                       */
-#define OS_TIME_GET_SET_EN        1    /*     Include code for OSTimeGet() and OSTimeSet()             */
-#define OS_TIME_TICK_HOOK_EN      1    /*     Include code for OSTimeTickHook()                        */
-
-
-                                       /* --------------------- TIMER MANAGEMENT --------------------- */
-#define OS_TMR_EN                 0    /* Enable (1) or Disable (0) code generation for TIMERS         */
-#define OS_TMR_CFG_MAX           16    /*     Maximum number of timers                                 */
-#define OS_TMR_CFG_NAME_EN        1    /*     Determine timer names                                    */
-#define OS_TMR_CFG_WHEEL_SIZE     8    /*     Size of timer wheel (#Spokes)                            */
-#define OS_TMR_CFG_TICKS_PER_SEC 10    /*     Rate at which timer management task runs (Hz)            */
-
-#endif
+/*
+*********************************************************************************************************
+*                                                uC/OS-II
+*                                          The Real-Time Kernel
+*                                  uC/OS-II Configuration File for V2.8x
+*
+*                               (c) Copyright 2005-2009, Micrium, Weston, FL
+*                                          All Rights Reserved
+*
+*
+* File    : OS_CFG.H
+* By      : Jean J. Labrosse
+* Version : V2.88
+*
+* LICENSING TERMS:
+* ---------------
+*   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.
+* If you plan on using  uC/OS-II  in a commercial product you need to contact Micriµm to properly license
+* its use in your product. We provide ALL the source code for your convenience and to help you experience
+* uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a
+* licensing fee.
+*********************************************************************************************************
+*/
+
+#ifndef OS_CFG_H
+#define OS_CFG_H
+
+
+                                       /* ---------------------- MISCELLANEOUS ----------------------- */
+#define OS_APP_HOOKS_EN           0    /* Application-defined hooks are called from the uC/OS-II hooks */
+#define OS_ARG_CHK_EN             0    /* Enable (1) or Disable (0) argument checking                  */
+#define OS_CPU_HOOKS_EN           1    /* uC/OS-II hooks are found in the processor port files         */
+
+#define OS_DEBUG_EN               1    /* Enable(1) debug variables                                    */
+
+#define OS_EVENT_MULTI_EN         1    /* Include code for OSEventPendMulti()                          */
+#define OS_EVENT_NAME_EN          1    /* Enable names for Sem, Mutex, Mbox and Q                      */
+
+#define OS_LOWEST_PRIO           63    /* Defines the lowest priority that can be assigned ...         */
+                                       /* ... MUST NEVER be higher than 254!                           */
+
+#define OS_MAX_EVENTS            40    /* Max. number of event control blocks in your application      */
+#define OS_MAX_FLAGS              5    /* Max. number of Event Flag Groups    in your application      */
+#define OS_MAX_MEM_PART           5    /* Max. number of memory partitions                             */
+#define OS_MAX_QS                 8    /* Max. number of queue control blocks in your application      */
+#define OS_MAX_TASKS             20    /* Max. number of tasks in your application, MUST be >= 2       */
+
+#define OS_SCHED_LOCK_EN          1    /* Include code for OSSchedLock() and OSSchedUnlock()           */
+
+#define OS_TICK_STEP_EN           1    /* Enable tick stepping feature for uC/OS-View                  */
+#define OS_TICKS_PER_SEC        1000//200    /* Set the number of ticks in one second                        */     
+                                       /* --------------------- TASK STACK SIZE ---------------------- */
+#define OS_TASK_TMR_STK_SIZE    128    /* Timer      task stack size (# of OS_STK wide entries)        */
+#define OS_TASK_STAT_STK_SIZE   128    /* Statistics task stack size (# of OS_STK wide entries)        */
+#define OS_TASK_IDLE_STK_SIZE   128    /* Idle       task stack size (# of OS_STK wide entries)        */
+
+
+                                       /* --------------------- TASK MANAGEMENT ---------------------- */
+#define OS_TASK_CHANGE_PRIO_EN    1    /*     Include code for OSTaskChangePrio()                      */
+#define OS_TASK_CREATE_EN         1    /*     Include code for OSTaskCreate()                          */
+#define OS_TASK_CREATE_EXT_EN     1    /*     Include code for OSTaskCreateExt()                       */
+#define OS_TASK_DEL_EN            1    /*     Include code for OSTaskDel()                             */
+#define OS_TASK_NAME_EN           1    /*     Enable task names                                        */
+#define OS_TASK_PROFILE_EN        1    /*     Include variables in OS_TCB for profiling                */
+#define OS_TASK_QUERY_EN          1    /*     Include code for OSTaskQuery()                           */
+#define OS_TASK_STAT_EN           1    /*     Enable (1) or Disable(0) the statistics task             */
+#define OS_TASK_STAT_STK_CHK_EN   1    /*     Check task stacks from statistic task                    */
+#define OS_TASK_SUSPEND_EN        1    /*     Include code for OSTaskSuspend() and OSTaskResume()      */
+#define OS_TASK_SW_HOOK_EN        1    /*     Include code for OSTaskSwHook()                          */
+#define OS_TASK_REG_TBL_SIZE      1    /*     Size of task variables array (#of INT32U entries)        */
+
+
+                                       /* ----------------------- EVENT FLAGS ------------------------ */
+#define OS_FLAG_EN                1    /* Enable (1) or Disable (0) code generation for EVENT FLAGS    */
+#define OS_FLAG_ACCEPT_EN         1    /*     Include code for OSFlagAccept()                          */
+#define OS_FLAG_DEL_EN            1    /*     Include code for OSFlagDel()                             */
+#define OS_FLAG_NAME_EN           1    /*     Enable names for event flag group                        */
+#define OS_FLAG_QUERY_EN          1    /*     Include code for OSFlagQuery()                           */
+#define OS_FLAG_WAIT_CLR_EN       1    /* Include code for Wait on Clear EVENT FLAGS                   */
+#define OS_FLAGS_NBITS           16    /* Size in #bits of OS_FLAGS data type (8, 16 or 32)            */
+
+
+                                       /* -------------------- MESSAGE MAILBOXES --------------------- */
+#define OS_MBOX_EN                1    /* Enable (1) or Disable (0) code generation for MAILBOXES      */
+#define OS_MBOX_ACCEPT_EN         1    /*     Include code for OSMboxAccept()                          */
+#define OS_MBOX_DEL_EN            1    /*     Include code for OSMboxDel()                             */
+#define OS_MBOX_PEND_ABORT_EN     1    /*     Include code for OSMboxPendAbort()                       */
+#define OS_MBOX_POST_EN           1    /*     Include code for OSMboxPost()                            */
+#define OS_MBOX_POST_OPT_EN       1    /*     Include code for OSMboxPostOpt()                         */
+#define OS_MBOX_QUERY_EN          1    /*     Include code for OSMboxQuery()                           */
+
+
+                                       /* --------------------- MEMORY MANAGEMENT -------------------- */
+#define OS_MEM_EN                 1    /* Enable (1) or Disable (0) code generation for MEMORY MANAGER */
+#define OS_MEM_NAME_EN            1    /*     Enable memory partition names                            */
+#define OS_MEM_QUERY_EN           1    /*     Include code for OSMemQuery()                            */
+
+
+                                       /* ---------------- MUTUAL EXCLUSION SEMAPHORES --------------- */
+#define OS_MUTEX_EN               1    /* Enable (1) or Disable (0) code generation for MUTEX          */
+#define OS_MUTEX_ACCEPT_EN        1    /*     Include code for OSMutexAccept()                         */
+#define OS_MUTEX_DEL_EN           1    /*     Include code for OSMutexDel()                            */
+#define OS_MUTEX_QUERY_EN         1    /*     Include code for OSMutexQuery()                          */
+
+
+                                       /* ---------------------- MESSAGE QUEUES ---------------------- */
+#define OS_Q_EN                   1    /* Enable (1) or Disable (0) code generation for QUEUES         */
+#define OS_Q_ACCEPT_EN            1    /*     Include code for OSQAccept()                             */
+#define OS_Q_DEL_EN               1    /*     Include code for OSQDel()                                */
+#define OS_Q_FLUSH_EN             1    /*     Include code for OSQFlush()                              */
+#define OS_Q_PEND_ABORT_EN        1    /*     Include code for OSQPendAbort()                          */
+#define OS_Q_POST_EN              1    /*     Include code for OSQPost()                               */
+#define OS_Q_POST_FRONT_EN        1    /*     Include code for OSQPostFront()                          */
+#define OS_Q_POST_OPT_EN          1    /*     Include code for OSQPostOpt()                            */
+#define OS_Q_QUERY_EN             1    /*     Include code for OSQQuery()                              */
+
+
+                                       /* ------------------------ SEMAPHORES ------------------------ */
+#define OS_SEM_EN                 1    /* Enable (1) or Disable (0) code generation for SEMAPHORES     */
+#define OS_SEM_ACCEPT_EN          1    /*    Include code for OSSemAccept()                            */
+#define OS_SEM_DEL_EN             1    /*    Include code for OSSemDel()                               */
+#define OS_SEM_PEND_ABORT_EN      1    /*    Include code for OSSemPendAbort()                         */
+#define OS_SEM_QUERY_EN           1    /*    Include code for OSSemQuery()                             */
+#define OS_SEM_SET_EN             1    /*    Include code for OSSemSet()                               */
+
+
+                                       /* --------------------- TIME MANAGEMENT ---------------------- */
+#define OS_TIME_DLY_HMSM_EN       1    /*     Include code for OSTimeDlyHMSM()                         */
+#define OS_TIME_DLY_RESUME_EN     1    /*     Include code for OSTimeDlyResume()                       */
+#define OS_TIME_GET_SET_EN        1    /*     Include code for OSTimeGet() and OSTimeSet()             */
+#define OS_TIME_TICK_HOOK_EN      1    /*     Include code for OSTimeTickHook()                        */
+
+
+                                       /* --------------------- TIMER MANAGEMENT --------------------- */
+#define OS_TMR_EN                 0    /* Enable (1) or Disable (0) code generation for TIMERS         */
+#define OS_TMR_CFG_MAX           16    /*     Maximum number of timers                                 */
+#define OS_TMR_CFG_NAME_EN        1    /*     Determine timer names                                    */
+#define OS_TMR_CFG_WHEEL_SIZE     8    /*     Size of timer wheel (#Spokes)                            */
+#define OS_TMR_CFG_TICKS_PER_SEC 10    /*     Rate at which timer management task runs (Hz)            */
+
+#endif

+ 261 - 259
User/main.c → Project/main.c

@@ -1,260 +1,262 @@
-/*
-*********************************************************************************************************
-*	函 数 名: main
-*	功能说明: c程序入口
-*	形    参:无
-*	返 回 值: 错误代码(无需处理)
-*********************************************************************************************************
-*/
-
-#include "main.h"
-#include "bsp_fatfs.h"
-
-void DumpHEX(uint8_t *buffer, uint32_t len)
-{
-
-    uint32_t i;
-    printf("[DumpHEX]Length:%d ", len);
-    for (i = 0; i < len; i++)
-    {
-        if (i % 16 == 0)
-            printf("\r\n");
-        else if (i % 8 == 0)
-            printf("    ");
-        else
-            printf(":");
-        printf("%02x", buffer[i]);
-    }
-    printf("\r\n");
-}
-
-int main(void)
-{
-#if 0
-    /* 打开GOIOI 端口时钟 */
-    *(unsigned int *)(0x40023800 + 0x30) |= (1 << 8);
-
-    /* PI10 为输出 */
-    *(unsigned int *)(0x40022000 + 0x00) &= ~((0x03) << (2 * 10));
-    *(unsigned int *)(0x40022000 + 0x00) |= (1 << (2 * 10));
-
-    /* PI10 输出高电平 */
-    *(unsigned int *)(0x40022000 + 0x14) |= (1 << 10);
-    /* PI10 输出低电平 */
-    *(unsigned int *)(0x40022000 + 0x14) &= ~(1 << 10);
-#elif 0
-    bsp_init();
-    while (1)
-    {
-        GPIO_ResetBits(GPIOI, GPIO_Pin_10);
-        Delay(0xFFFFFFFF);
-        // GPIO_SetBits(GPIOI, GPIO_Pin_10);
-        // Delay(0xFFFFFFFF);
-
-        GPIO_ResetBits(GPIOF, GPIO_Pin_7);
-        Delay(0xFFFFFF);
-        // GPIO_SetBits(GPIOF, GPIO_Pin_7);
-        // Delay(0xFFFFFF);
-
-        GPIO_ResetBits(GPIOF, GPIO_Pin_8);
-        Delay(0xFFFFFF);
-        // GPIO_SetBits(GPIOF, GPIO_Pin_8);
-        // Delay(0xFFFFFF);
-
-        GPIO_ResetBits(GPIOC, GPIO_Pin_2);
-        Delay(0xFFFFFF);
-        // GPIO_SetBits(GPIOC, GPIO_Pin_2);
-        // Delay(0xFFFFFF);
-    };
-#elif 1
-    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
-    OSInit();
-    bsp_init();
-    RegisterIec10x();
-
-    /* init task */
-    /* 创建一个启动任务(也就是主任务)。启动任务会创建所有的应用程序任务 */
-    OSTaskCreateExt(init_task,                                   /* 启动任务函数指针 */
-                    (void *)0,                                   /* 传递给任务的参数 */
-                    (OS_STK *)&init_task_stk[INIT_STK_SIZE - 1], /* 指向任务栈栈顶的指针 */
-                    INIT_TASK_PRIO,                              /* 任务的优先级,必须唯一,数字越低优先级越高 */
-                    INIT_TASK_PRIO,                              /* 任务ID,一般和任务优先级相同 */
-                    (OS_STK *)&init_task_stk[0],                 /* 指向任务栈栈底的指针。OS_STK_GROWTH
-                                                                    决定堆栈增长方向 */
-                    INIT_STK_SIZE,                               /* 任务栈大小 */
-                    (void *)0,                                   /* 一块用户内存区的指针,用于任务控制块TCB的扩展功能
-                                                                (如任务切换时保存CPU浮点寄存器的数据)。一般不用,填0即可 */
-                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);  /* 任务选项字 */
-
-    OSStart();
-
-#endif
-}
-
-/*!
-    \brief      init task
-    \param[in]  pvParameters not used
-    \param[out] none
-    \retval     none
-*/
-void init_task(void *pvParameters)
-{
-    SysTick_Config(SystemCoreClock / OS_TICKS_PER_SEC);
-    /* configure the systick handler priority */
-    NVIC_SetPriority(SysTick_IRQn, 0x00U);
-
-    OSTaskCreateExt((void (*)(void *))misc_task,                                              /* 启动任务函数指针 */
-                    (void *)0,                                                                /* 传递给任务的参数 */
-                    (OS_STK *)&misc_task_stk[MISC_TASK_STK_SIZE - 1],                         /* 指向任务栈栈顶的指针 */
-                    (INT8U)MISC_PRIO,                                                         /* 任务的优先级,必须唯一,数字越低优先级越高 */
-                    (INT16U)MISC_PRIO,                                                        /* 任务ID,一般和任务优先级相同 */
-                    (OS_STK *)&misc_task_stk[0],                                              /* 指向任务栈栈底的指针。OS_STK_GROWTH 决定堆栈增长方向 */
-                    (INT32U)MISC_TASK_STK_SIZE,                                               /* 任务栈大小 */
-                    (void *)0,                                                                /* 一块用户内存区的指针,用于任务控制块TCB的扩展功能
-                                                                                              (如任务切换时保存CPU浮点寄存器的数据)。一般不用,填0即可 */
-                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP); /* 任务选项字 */
-
-    // OSTaskCreateExt((void (*)(void *))modbus_master_task,
-    //                 (void *)0,
-    //                 (OS_STK *)&uart1_task_stk[UART1_TASK_STK_SIZE - 1],
-    //                 (INT8U)UART1_TASK_PRIO,
-    //                 (INT16U)UART1_TASK_PRIO,
-    //                 (OS_STK *)&uart1_task_stk[0],
-    //                 (INT32U)UART1_TASK_STK_SIZE,
-    //                 (void *)0,
-    //                 (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
-
-    /* 485 modbus从机模式 */
-    OSTaskCreateExt((void (*)(void *))modbus_slave_task,
-                    (void *)0,
-                    (OS_STK *)&uart3_task_stk[UART3_TASK_STK_SIZE - 1],
-                    (INT8U)UART3_TASK_PRIO,
-                    (INT16U)UART3_TASK_PRIO,
-                    (OS_STK *)&uart3_task_stk[0],
-                    (INT32U)UART3_TASK_STK_SIZE,
-                    (void *)0,
-                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
-
-    OSTaskCreateExt((void (*)(void *))net_task,
-                    (void *)0,
-                    (OS_STK *)&net_task_stk[NET_TASK_STK_SIZE - 1],
-                    (INT8U)NET_PRIO,
-                    (INT16U)NET_PRIO,
-                    (OS_STK *)&net_task_stk[0],
-                    (INT32U)NET_TASK_STK_SIZE,
-                    (void *)0,
-                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
-
-    // /* ESP8266 STA任务*/
-    // OSTaskCreateExt((void (*)(void *))esp_8266_task,
-    //                 (void *)0,
-    //                 (OS_STK *)&uart6_task_stk[UART6_TASK_STK_SIZE - 1],
-    //                 (INT8U)UART6_TASK_PRIO,
-    //                 (INT16U)UART6_TASK_PRIO,
-    //                 (OS_STK *)&uart6_task_stk[0],
-    //                 (INT32U)UART6_TASK_STK_SIZE,
-    //                 (void *)0,
-    //                 (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
-}
-
-void misc_task(void)
-{
-    INT8U  cnt      = 0;
-    INT16U save_cnt = 0;
-    INT8U  temperature;
-    INT8U  humidity;
-    INT8U  ret;
-    INT8U  key_state;
-    AD7606_SetOS(AD_OS_NO);  /* 无过采样 */
-    AD7606_SetInputRange(0); /* 0表示输入量程为正负5V, 1表示正负10V */
-
-    // bsp_StartAutoTimer(0, 500); /* 启动1个200ms的自动重装的定时器 */
-    AD7606_ReadNowAdc();  /* 读取采样结果 */
-    AD7606_StartConvst(); /* 启动1次转换 */
-    while (1)
-    {
-        iwdg_feed(MISC_DOG);
-        key_scan();
-        USBH_Process(&USB_OTG_Core, &USB_Host);
-        key_state = key_get();
-        if (key_state != KEY_NONE)
-        {
-            switch (key_state)
-            {
-            case KEY_1_UP:
-                printf("1111111\r\n");
-                break;
-            case KEY_1_DOWN:
-                printf("wwwwwwwwwwww\r\n");
-                break;
-            case KEY_1_LONG:
-                printf("333333333\r\n");
-                break;
-            default:
-                printf("44444444\r\n");
-                break;
-            }
-        }
-        if ((cnt % 10 == 0) && (cnt != 0))
-        {
-            // printf("%ld\r\n", NAND_ReadID());
-            // printf("%c\r\n", NOR_ReadByte(0x4000));
-        }
-        if ((cnt % 25 == 0) && (cnt != 0))
-        {
-            // printf("%ld\r\n", NAND_ReadID());
-            LED2_RUN_TOGGLE;
-        }
-
-        if ((cnt % 15 == 0) && (cnt != 0))
-        {
-            // if (NOR_EraseSector(0x4000) == 0)
-            // {
-            //     NOR_WriteByte(0x4000, 0xFF);
-            // }
-        }
-
-        if (cnt == 10)
-        {
-            // if (am2303_init())
-            // {
-            //     printf("error\r\n");
-            // }
-            // else
-            // {
-            ret = am2303_read_data(&temperature, &humidity); //读取温湿度值
-            // if (ret == 1)
-            // {
-            //     printf("Temp: (%d).\n", temperature);
-            //     printf("Humi: (%d).\n", humidity);
-            // }
-            // else
-            // {
-            //     printf("\r\n未发现DHT11温湿度传感器\r\n");
-            // }
-            // }
-        }
-        if (cnt >= 25)
-        {
-            /* 每隔500ms 进来一次. 由软件启动转换 */
-            AD7606_ReadNowAdc();  /* 读取采样结果 */
-            AD7606_StartConvst(); /* 启动下次转换 */
-
-            cnt = 0; /* 刷新显示 */
-        }
-        else
-        {
-            cnt++;
-        }
-
-        if (save_cnt >= 25)
-        {
-            save_cnt = 0;
-        }
-        else
-        {
-            save_cnt++;
-        }
-        OSTimeDly(20);
-    };
+/*
+*********************************************************************************************************
+*	函 数 名: main
+*	功能说明: c程序入口
+*	形    参:无
+*	返 回 值: 错误代码(无需处理)
+*********************************************************************************************************
+*/
+
+#include "main.h"
+#include "bsp_fatfs.h"
+
+void DumpHEX(uint8_t *buffer, uint32_t len)
+{
+
+    uint32_t i;
+    printf("[DumpHEX]Length:%d ", len);
+    for (i = 0; i < len; i++)
+    {
+        if (i % 16 == 0)
+            printf("\r\n");
+        else if (i % 8 == 0)
+            printf("    ");
+        else
+            printf(":");
+        printf("%02x", buffer[i]);
+    }
+    printf("\r\n");
+}
+
+int main(void)
+{
+#if 0
+    /* 打开GOIOI 端口时钟 */
+    *(unsigned int *)(0x40023800 + 0x30) |= (1 << 8);
+
+    /* PI10 为输出 */
+    *(unsigned int *)(0x40022000 + 0x00) &= ~((0x03) << (2 * 10));
+    *(unsigned int *)(0x40022000 + 0x00) |= (1 << (2 * 10));
+
+    /* PI10 输出高电平 */
+    *(unsigned int *)(0x40022000 + 0x14) |= (1 << 10);
+    /* PI10 输出低电平 */
+    *(unsigned int *)(0x40022000 + 0x14) &= ~(1 << 10);
+#elif 0
+    bsp_init();
+    while (1)
+    {
+        GPIO_ResetBits(GPIOI, GPIO_Pin_10);
+        Delay(0xFFFFFFFF);
+        // GPIO_SetBits(GPIOI, GPIO_Pin_10);
+        // Delay(0xFFFFFFFF);
+
+        GPIO_ResetBits(GPIOF, GPIO_Pin_7);
+        Delay(0xFFFFFF);
+        // GPIO_SetBits(GPIOF, GPIO_Pin_7);
+        // Delay(0xFFFFFF);
+
+        GPIO_ResetBits(GPIOF, GPIO_Pin_8);
+        Delay(0xFFFFFF);
+        // GPIO_SetBits(GPIOF, GPIO_Pin_8);
+        // Delay(0xFFFFFF);
+
+        GPIO_ResetBits(GPIOC, GPIO_Pin_2);
+        Delay(0xFFFFFF);
+        // GPIO_SetBits(GPIOC, GPIO_Pin_2);
+        // Delay(0xFFFFFF);
+    };
+#elif 1
+    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
+    OSInit();
+    bsp_init();
+    RegisterIec10x();
+
+    /* init task */
+    /* 创建一个启动任务(也就是主任务)。启动任务会创建所有的应用程序任务 */
+    OSTaskCreateExt(init_task,                                   /* 启动任务函数指针 */
+                    (void *)0,                                   /* 传递给任务的参数 */
+                    (OS_STK *)&init_task_stk[INIT_STK_SIZE - 1], /* 指向任务栈栈顶的指针 */
+                    INIT_TASK_PRIO,                              /* 任务的优先级,必须唯一,数字越低优先级越高 */
+                    INIT_TASK_PRIO,                              /* 任务ID,一般和任务优先级相同 */
+                    (OS_STK *)&init_task_stk[0],                 /* 指向任务栈栈底的指针。OS_STK_GROWTH
+                                                                    决定堆栈增长方向 */
+                    INIT_STK_SIZE,                               /* 任务栈大小 */
+                    (void *)0,                                   /* 一块用户内存区的指针,用于任务控制块TCB的扩展功能
+                                                                (如任务切换时保存CPU浮点寄存器的数据)。一般不用,填0即可 */
+                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);  /* 任务选项字 */
+
+    OSStart();
+
+#endif
+}
+
+/*!
+    \brief      init task
+    \param[in]  pvParameters not used
+    \param[out] none
+    \retval     none
+*/
+void init_task(void *pvParameters)
+{
+    uint8_t *p;
+    p = pvParameters;
+    SysTick_Config(SystemCoreClock / OS_TICKS_PER_SEC);
+    /* configure the systick handler priority */
+    NVIC_SetPriority(SysTick_IRQn, 0x00U);
+
+    OSTaskCreateExt((void (*)(void *))misc_task,                                              /* 启动任务函数指针 */
+                    (void *)0,                                                                /* 传递给任务的参数 */
+                    (OS_STK *)&misc_task_stk[MISC_TASK_STK_SIZE - 1],                         /* 指向任务栈栈顶的指针 */
+                    (INT8U)MISC_PRIO,                                                         /* 任务的优先级,必须唯一,数字越低优先级越高 */
+                    (INT16U)MISC_PRIO,                                                        /* 任务ID,一般和任务优先级相同 */
+                    (OS_STK *)&misc_task_stk[0],                                              /* 指向任务栈栈底的指针。OS_STK_GROWTH 决定堆栈增长方向 */
+                    (INT32U)MISC_TASK_STK_SIZE,                                               /* 任务栈大小 */
+                    (void *)0,                                                                /* 一块用户内存区的指针,用于任务控制块TCB的扩展功能
+                                                                                              (如任务切换时保存CPU浮点寄存器的数据)。一般不用,填0即可 */
+                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP); /* 任务选项字 */
+
+    // OSTaskCreateExt((void (*)(void *))modbus_master_task,
+    //                 (void *)0,
+    //                 (OS_STK *)&uart1_task_stk[UART1_TASK_STK_SIZE - 1],
+    //                 (INT8U)UART1_TASK_PRIO,
+    //                 (INT16U)UART1_TASK_PRIO,
+    //                 (OS_STK *)&uart1_task_stk[0],
+    //                 (INT32U)UART1_TASK_STK_SIZE,
+    //                 (void *)0,
+    //                 (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
+
+    /* 485 modbus从机模式 */
+    OSTaskCreateExt((void (*)(void *))modbus_slave_task,
+                    (void *)0,
+                    (OS_STK *)&uart3_task_stk[UART3_TASK_STK_SIZE - 1],
+                    (INT8U)UART3_TASK_PRIO,
+                    (INT16U)UART3_TASK_PRIO,
+                    (OS_STK *)&uart3_task_stk[0],
+                    (INT32U)UART3_TASK_STK_SIZE,
+                    (void *)0,
+                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
+
+    OSTaskCreateExt((void (*)(void *))net_task,
+                    (void *)0,
+                    (OS_STK *)&net_task_stk[NET_TASK_STK_SIZE - 1],
+                    (INT8U)NET_PRIO,
+                    (INT16U)NET_PRIO,
+                    (OS_STK *)&net_task_stk[0],
+                    (INT32U)NET_TASK_STK_SIZE,
+                    (void *)0,
+                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
+
+    /* ESP8266 STA任务*/
+    OSTaskCreateExt((void (*)(void *))esp_8266_task,
+                    (void *)0,
+                    (OS_STK *)&uart6_task_stk[UART6_TASK_STK_SIZE - 1],
+                    (INT8U)UART6_TASK_PRIO,
+                    (INT16U)UART6_TASK_PRIO,
+                    (OS_STK *)&uart6_task_stk[0],
+                    (INT32U)UART6_TASK_STK_SIZE,
+                    (void *)0,
+                    (INT16U)OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR | OS_TASK_OPT_SAVE_FP);
+}
+
+void misc_task(void)
+{
+    INT8U  cnt      = 0;
+    INT16U save_cnt = 0;
+    INT8U  temperature;
+    INT8U  humidity;
+    INT8U  ret;
+    // INT8U  key_state;
+    AD7606_SetOS(AD_OS_NO);  /* 无过采样 */
+    AD7606_SetInputRange(0); /* 0表示输入量程为正负5V, 1表示正负10V */
+
+    // bsp_StartAutoTimer(0, 500); /* 启动1个200ms的自动重装的定时器 */
+    AD7606_ReadNowAdc();  /* 读取采样结果 */
+    AD7606_StartConvst(); /* 启动1次转换 */
+    while (1)
+    {
+        iwdg_feed(MISC_DOG);
+        // key_scan();
+        USBH_Process(&USB_OTG_Core, &USB_Host);
+        // key_state = key_get();
+        // if (key_state != KEY_NONE)
+        // {
+        //     switch (key_state)
+        //     {
+        //     case KEY_1_UP:
+        //         printf("1111111\r\n");
+        //         break;
+        //     case KEY_1_DOWN:
+        //         printf("wwwwwwwwwwww\r\n");
+        //         break;
+        //     case KEY_1_LONG:
+        //         printf("333333333\r\n");
+        //         break;
+        //     default:
+        //         printf("44444444\r\n");
+        //         break;
+        //     }
+        // }
+        if ((cnt % 10 == 0) && (cnt != 0))
+        {
+            // printf("%ld\r\n", NAND_ReadID());
+            // printf("%c\r\n", NOR_ReadByte(0x4000));
+        }
+        if ((cnt % 25 == 0) && (cnt != 0))
+        {
+            // printf("%ld\r\n", NAND_ReadID());
+            LED2_RUN_TOGGLE;
+        }
+
+        if ((cnt % 15 == 0) && (cnt != 0))
+        {
+            // if (NOR_EraseSector(0x4000) == 0)
+            // {
+            //     NOR_WriteByte(0x4000, 0xFF);
+            // }
+        }
+
+        if (cnt == 10)
+        {
+            // if (am2303_init())
+            // {
+            //     printf("error\r\n");
+            // }
+            // else
+            // {
+            ret = am2303_read_data(&temperature, &humidity); //读取温湿度值
+            // if (ret == 1)
+            // {
+            //     printf("Temp: (%d).\n", temperature);
+            //     printf("Humi: (%d).\n", humidity);
+            // }
+            // else
+            // {
+            //     printf("\r\n未发现DHT11温湿度传感器\r\n");
+            // }
+            // }
+        }
+        if (cnt >= 25)
+        {
+            /* 每隔500ms 进来一次. 由软件启动转换 */
+            AD7606_ReadNowAdc();  /* 读取采样结果 */
+            AD7606_StartConvst(); /* 启动下次转换 */
+
+            cnt = 0; /* 刷新显示 */
+        }
+        else
+        {
+            cnt++;
+        }
+
+        if (save_cnt >= 25)
+        {
+            save_cnt = 0;
+        }
+        else
+        {
+            save_cnt++;
+        }
+        OSTimeDly(20);
+    };
 }

+ 25 - 25
User/main.h → Project/main.h

@@ -1,26 +1,26 @@
-#ifndef __MAIN_H
-#define __MAIN_H
-
-#include "ad7606.h"
-#include "am2303.h"
-#include "esp8266.h"
-#include "fly_param.h"
-#include "iec10x_type.h"
-#include "includes.h"
-#include "interface.h"
-#include "key.h"
-#include "modbus.h"
-#include "nand_flash.h"
-#include "net.h"
-#include "nor_flash.h"
-#include "stm32f4x7_phy.h"
-#include "stm32f4xx.h"
-#include <stdio.h>
-#include "usbh_bsp_msc.h"
-
-void bsp_init(void);
-void init_task(void *pvParameters);
-void misc_task(void);
-
-iec_32u RegisterIec10x(void);
+#ifndef __MAIN_H
+#define __MAIN_H
+
+#include "ad7606.h"
+#include "am2303.h"
+#include "esp8266.h"
+#include "fly_param.h"
+#include "iec10x_type.h"
+#include "includes.h"
+#include "interface.h"
+#include "key.h"
+#include "modbus.h"
+#include "nand_flash.h"
+#include "net.h"
+#include "nor_flash.h"
+#include "stm32f4x7_phy.h"
+#include "stm32f4xx.h"
+#include "usbh_bsp_msc.h"
+#include <stdio.h>
+
+void bsp_init(void);
+void init_task(void *pvParameters);
+void misc_task(void);
+
+iec_32u RegisterIec10x(void);
 #endif

+ 0 - 0
User/project_var.h → Project/project_var.h


+ 119 - 119
User/stm32f4x7_eth_conf.h → Project/stm32f4x7_eth_conf.h

@@ -1,119 +1,119 @@
-/**
- ******************************************************************************
- * @file    stm32f4x7_eth_conf.h
- * @author  MCD Application Team
- * @version V1.1.0
- * @date    31-July-2013
- * @brief   Configuration file for the STM32F4x7 Ethernet driver.
- ******************************************************************************
- * @attention
- *
- * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *        http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STM32F4x7_ETH_CONF_H
-#define __STM32F4x7_ETH_CONF_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32f4xx.h"
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-
-/* Uncomment the line below when using time stamping and/or IPv4 checksum offload */
-#define USE_ENHANCED_DMA_DESCRIPTORS
-
-/* Uncomment the line below if you want to use user defined Delay function
-   (for precise timing), otherwise default _eth_delay_ function defined within
-   the Ethernet driver is used (less precise timing) */
-#define USE_Delay
-
-#ifdef USE_Delay
-    //  #include "main.h"              /* Header file where the Delay function prototype is exported */
-#define _eth_delay_ ETH_Delay10ms /* User can provide more timing precise _eth_delay_ function \
-                            in this example Systick is configured with an interrupt every 10 ms*/
-    extern void ETH_Delay10ms(uint32_t nCount);
-#else
-#define _eth_delay_ ETH_Delay /* Default _eth_delay_ function with less precise timing */
-#endif
-
-/*This define allow to customize configuration of the Ethernet driver buffers */
-#define CUSTOM_DRIVER_BUFFERS_CONFIG
-
-#ifdef CUSTOM_DRIVER_BUFFERS_CONFIG
-    /* Redefinition of the Ethernet driver buffers size and count */
-#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
-#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
-#define ETH_RXBUFNB     4                   /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
-#define ETH_TXBUFNB     4                   /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
-#endif
-
-/* PHY configuration section **************************************************/
-#ifdef USE_Delay
-/* PHY Reset delay */
-#define PHY_RESET_DELAY ((uint32_t)0x000000FF)
-/* PHY Configuration delay */
-#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
-/* Delay when writing to Ethernet registers*/
-#define ETH_REG_WRITE_DELAY ((uint32_t)0x00000001)
-#else
-/* PHY Reset delay */
-#define PHY_RESET_DELAY     ((uint32_t)0x000FFFFF)
-/* PHY Configuration delay */
-#define PHY_CONFIG_DELAY    ((uint32_t)0x00FFFFFF)
-/* Delay when writing to Ethernet registers*/
-#define ETH_REG_WRITE_DELAY ((uint32_t)0x0000FFFF)
-#endif
-
-/*******************  PHY Extended Registers section : ************************/
-
-/* These values are relatives to DP83848 PHY and change from PHY to another,
-   so the user have to update this value depending on the used external PHY */
-
-/* The DP83848 PHY status register  */
-#define PHY_SR            ((uint16_t)0x10)   /* PHY status register Offset */
-#define PHY_SPEED_STATUS  ((uint16_t)0x0002) /* PHY Speed mask */
-#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /* PHY Duplex mask */
-
-/* The DP83848 PHY: MII Interrupt Control Register  */
-#define PHY_MICR        ((uint16_t)0x11)   /* MII Interrupt Control Register */
-#define PHY_MICR_INT_EN ((uint16_t)0x0002) /* PHY Enable interrupts */
-#define PHY_MICR_INT_OE ((uint16_t)0x0001) /* PHY Enable output interrupt events */
-
-/* The DP83848 PHY: MII Interrupt Status and Misc. Control Register */
-#define PHY_MISR             ((uint16_t)0x12)   /* MII Interrupt Status and Misc. Control Register */
-#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /* Enable Interrupt on change of link status */
-#define PHY_LINK_STATUS      ((uint16_t)0x2000) /* PHY link status interrupt mask */
-
-    /* Note : Common PHY registers are defined in stm32f4x7_eth.h file */
-
-    /* Exported macro ------------------------------------------------------------*/
-    /* Exported functions ------------------------------------------------------- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __STM32F4x7_ETH_CONF_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+/**
+ ******************************************************************************
+ * @file    stm32f4x7_eth_conf.h
+ * @author  MCD Application Team
+ * @version V1.1.0
+ * @date    31-July-2013
+ * @brief   Configuration file for the STM32F4x7 Ethernet driver.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *        http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4x7_ETH_CONF_H
+#define __STM32F4x7_ETH_CONF_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f4xx.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* Uncomment the line below when using time stamping and/or IPv4 checksum offload */
+#define USE_ENHANCED_DMA_DESCRIPTORS
+
+/* Uncomment the line below if you want to use user defined Delay function
+   (for precise timing), otherwise default _eth_delay_ function defined within
+   the Ethernet driver is used (less precise timing) */
+#define USE_Delay
+
+#ifdef USE_Delay
+    //  #include "main.h"              /* Header file where the Delay function prototype is exported */
+#define _eth_delay_ ETH_Delay10ms /* User can provide more timing precise _eth_delay_ function \
+                            in this example Systick is configured with an interrupt every 10 ms*/
+    extern void ETH_Delay10ms(uint32_t nCount);
+#else
+#define _eth_delay_ ETH_Delay /* Default _eth_delay_ function with less precise timing */
+#endif
+
+/*This define allow to customize configuration of the Ethernet driver buffers */
+#define CUSTOM_DRIVER_BUFFERS_CONFIG
+
+#ifdef CUSTOM_DRIVER_BUFFERS_CONFIG
+    /* Redefinition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB     4                   /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB     4                   /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+#endif
+
+/* PHY configuration section **************************************************/
+#ifdef USE_Delay
+/* PHY Reset delay */
+#define PHY_RESET_DELAY ((uint32_t)0x000000FF)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
+/* Delay when writing to Ethernet registers*/
+#define ETH_REG_WRITE_DELAY ((uint32_t)0x00000001)
+#else
+/* PHY Reset delay */
+#define PHY_RESET_DELAY     ((uint32_t)0x000FFFFF)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY    ((uint32_t)0x00FFFFFF)
+/* Delay when writing to Ethernet registers*/
+#define ETH_REG_WRITE_DELAY ((uint32_t)0x0000FFFF)
+#endif
+
+/*******************  PHY Extended Registers section : ************************/
+
+/* These values are relatives to DP83848 PHY and change from PHY to another,
+   so the user have to update this value depending on the used external PHY */
+
+/* The DP83848 PHY status register  */
+#define PHY_SR            ((uint16_t)0x10)   /* PHY status register Offset */
+#define PHY_SPEED_STATUS  ((uint16_t)0x0002) /* PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /* PHY Duplex mask */
+
+/* The DP83848 PHY: MII Interrupt Control Register  */
+#define PHY_MICR        ((uint16_t)0x11)   /* MII Interrupt Control Register */
+#define PHY_MICR_INT_EN ((uint16_t)0x0002) /* PHY Enable interrupts */
+#define PHY_MICR_INT_OE ((uint16_t)0x0001) /* PHY Enable output interrupt events */
+
+/* The DP83848 PHY: MII Interrupt Status and Misc. Control Register */
+#define PHY_MISR             ((uint16_t)0x12)   /* MII Interrupt Status and Misc. Control Register */
+#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /* Enable Interrupt on change of link status */
+#define PHY_LINK_STATUS      ((uint16_t)0x2000) /* PHY link status interrupt mask */
+
+    /* Note : Common PHY registers are defined in stm32f4x7_eth.h file */
+
+    /* Exported macro ------------------------------------------------------------*/
+    /* Exported functions ------------------------------------------------------- */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4x7_ETH_CONF_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 132 - 132
User/stm32f4xx_conf.h → Project/stm32f4xx_conf.h

@@ -1,132 +1,132 @@
-/**
- ******************************************************************************
- * @file    Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_conf.h
- * @author  MCD Application Team
- * @version V1.5.0
- * @date    06-March-2015
- * @brief   Library configuration file.
- ******************************************************************************
- * @attention
- *
- * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *        http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STM32F4xx_CONF_H
-#define __STM32F4xx_CONF_H
-
-/* Includes ------------------------------------------------------------------*/
-/* Uncomment the line below to enable peripheral header file inclusion */
-#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
-#include "stm32f4xx_adc.h"
-#include "stm32f4xx_crc.h"
-#include "stm32f4xx_dbgmcu.h"
-#include "stm32f4xx_dma.h"
-#include "stm32f4xx_exti.h"
-#include "stm32f4xx_flash.h"
-#include "stm32f4xx_gpio.h"
-#include "stm32f4xx_i2c.h"
-#include "stm32f4xx_iwdg.h"
-#include "stm32f4xx_pwr.h"
-#include "stm32f4xx_rcc.h"
-#include "stm32f4xx_rtc.h"
-#include "stm32f4xx_sdio.h"
-#include "stm32f4xx_spi.h"
-#include "stm32f4xx_syscfg.h"
-#include "stm32f4xx_tim.h"
-#include "stm32f4xx_usart.h"
-#include "stm32f4xx_wwdg.h"
-
-#if defined(STM32F429_439xx) || defined(STM32F446xx)
-#include "stm32f4xx_can.h"
-#include "stm32f4xx_cryp.h"
-#include "stm32f4xx_dac.h"
-#include "stm32f4xx_dcmi.h"
-#include "stm32f4xx_dma2d.h"
-#include "stm32f4xx_fmc.h"
-#include "stm32f4xx_hash.h"
-#include "stm32f4xx_ltdc.h"
-#include "stm32f4xx_rng.h"
-#include "stm32f4xx_sai.h"
-#endif /* STM32F429_439xx || STM32F446xx */
-
-#if defined(STM32F427_437xx)
-#include "stm32f4xx_can.h"
-#include "stm32f4xx_cryp.h"
-#include "stm32f4xx_dac.h"
-#include "stm32f4xx_dcmi.h"
-#include "stm32f4xx_dma2d.h"
-#include "stm32f4xx_fmc.h"
-#include "stm32f4xx_hash.h"
-#include "stm32f4xx_rng.h"
-#include "stm32f4xx_sai.h"
-#endif /* STM32F427_437xx */
-
-#if defined(STM32F40_41xxx)
-#include "stm32f4xx_can.h"
-#include "stm32f4xx_cryp.h"
-#include "stm32f4xx_dac.h"
-#include "stm32f4xx_dcmi.h"
-#include "stm32f4xx_fsmc.h"
-#include "stm32f4xx_hash.h"
-#include "stm32f4xx_rng.h"
-#endif /* STM32F40_41xxx */
-
-#if defined(STM32F411xE)
-#include "stm32f4xx_flash_ramfunc.h"
-#endif /* STM32F411xE */
-
-#if defined(STM32F446xx)
-#include "stm32f4xx_cec.h"
-#include "stm32f4xx_fmpi2c.h"
-#include "stm32f4xx_qspi.h"
-#include "stm32f4xx_spdifrx.h"
-#endif /* STM32F446xx */
-
-/* Exported types ------------------------------------------------------------*/
-/* Exported constants --------------------------------------------------------*/
-
-/* If an external clock source is used, then the value of the following define
-   should be set to the value of the external clock source, else, if no external
-   clock is used, keep this define commented */
-/*#define I2S_EXTERNAL_CLOCK_VAL   12288000 */ /* Value of the external clock in Hz */
-
-/* Uncomment the line below to expanse the "assert_param" macro in the
-   Standard Peripheral Library drivers code */
-/* #define USE_FULL_ASSERT    1 */
-
-/* Exported macro ------------------------------------------------------------*/
-#ifdef USE_FULL_ASSERT
-
-/**
- * @brief  The assert_param macro is used for function's parameters check.
- * @param  expr: If expr is false, it calls assert_failed function
- *   which reports the name of the source file and the source
- *   line number of the call that failed.
- *   If expr is true, it returns no value.
- * @retval None
- */
-#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
-/* Exported functions ------------------------------------------------------- */
-void assert_failed(uint8_t *file, uint32_t line);
-#else
-#define assert_param(expr) ((void)0)
-#endif /* USE_FULL_ASSERT */
-
-#endif /* __STM32F4xx_CONF_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+/**
+ ******************************************************************************
+ * @file    Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_conf.h
+ * @author  MCD Application Team
+ * @version V1.5.0
+ * @date    06-March-2015
+ * @brief   Library configuration file.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *        http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_CONF_H
+#define __STM32F4xx_CONF_H
+
+/* Includes ------------------------------------------------------------------*/
+/* Uncomment the line below to enable peripheral header file inclusion */
+#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
+#include "stm32f4xx_adc.h"
+#include "stm32f4xx_crc.h"
+#include "stm32f4xx_dbgmcu.h"
+#include "stm32f4xx_dma.h"
+#include "stm32f4xx_exti.h"
+#include "stm32f4xx_flash.h"
+#include "stm32f4xx_gpio.h"
+#include "stm32f4xx_i2c.h"
+#include "stm32f4xx_iwdg.h"
+#include "stm32f4xx_pwr.h"
+#include "stm32f4xx_rcc.h"
+#include "stm32f4xx_rtc.h"
+#include "stm32f4xx_sdio.h"
+#include "stm32f4xx_spi.h"
+#include "stm32f4xx_syscfg.h"
+#include "stm32f4xx_tim.h"
+#include "stm32f4xx_usart.h"
+#include "stm32f4xx_wwdg.h"
+
+#if defined(STM32F429_439xx) || defined(STM32F446xx)
+#include "stm32f4xx_can.h"
+#include "stm32f4xx_cryp.h"
+#include "stm32f4xx_dac.h"
+#include "stm32f4xx_dcmi.h"
+#include "stm32f4xx_dma2d.h"
+#include "stm32f4xx_fmc.h"
+#include "stm32f4xx_hash.h"
+#include "stm32f4xx_ltdc.h"
+#include "stm32f4xx_rng.h"
+#include "stm32f4xx_sai.h"
+#endif /* STM32F429_439xx || STM32F446xx */
+
+#if defined(STM32F427_437xx)
+#include "stm32f4xx_can.h"
+#include "stm32f4xx_cryp.h"
+#include "stm32f4xx_dac.h"
+#include "stm32f4xx_dcmi.h"
+#include "stm32f4xx_dma2d.h"
+#include "stm32f4xx_fmc.h"
+#include "stm32f4xx_hash.h"
+#include "stm32f4xx_rng.h"
+#include "stm32f4xx_sai.h"
+#endif /* STM32F427_437xx */
+
+#if defined(STM32F40_41xxx)
+#include "stm32f4xx_can.h"
+#include "stm32f4xx_cryp.h"
+#include "stm32f4xx_dac.h"
+#include "stm32f4xx_dcmi.h"
+#include "stm32f4xx_fsmc.h"
+#include "stm32f4xx_hash.h"
+#include "stm32f4xx_rng.h"
+#endif /* STM32F40_41xxx */
+
+#if defined(STM32F411xE)
+#include "stm32f4xx_flash_ramfunc.h"
+#endif /* STM32F411xE */
+
+#if defined(STM32F446xx)
+#include "stm32f4xx_cec.h"
+#include "stm32f4xx_fmpi2c.h"
+#include "stm32f4xx_qspi.h"
+#include "stm32f4xx_spdifrx.h"
+#endif /* STM32F446xx */
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* If an external clock source is used, then the value of the following define
+   should be set to the value of the external clock source, else, if no external
+   clock is used, keep this define commented */
+/*#define I2S_EXTERNAL_CLOCK_VAL   12288000 */ /* Value of the external clock in Hz */
+
+/* Uncomment the line below to expanse the "assert_param" macro in the
+   Standard Peripheral Library drivers code */
+/* #define USE_FULL_ASSERT    1 */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+
+/**
+ * @brief  The assert_param macro is used for function's parameters check.
+ * @param  expr: If expr is false, it calls assert_failed function
+ *   which reports the name of the source file and the source
+ *   line number of the call that failed.
+ *   If expr is true, it returns no value.
+ * @retval None
+ */
+#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+void assert_failed(uint8_t *file, uint32_t line);
+#else
+#define assert_param(expr) ((void)0)
+#endif /* USE_FULL_ASSERT */
+
+#endif /* __STM32F4xx_CONF_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 197 - 197
User/stm32f4xx_it.c → Project/stm32f4xx_it.c

@@ -1,197 +1,197 @@
-/**
- ******************************************************************************
- * @file    Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.c
- * @author  MCD Application Team
- * @version V1.5.0
- * @date    06-March-2015
- * @brief   Main Interrupt Service Routines.
- *          This file provides template for all exceptions handler and
- *          peripherals interrupt service routine.
- ******************************************************************************
- * @attention
- *
- * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *        http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32f4xx_it.h"
-#include "includes.h"
-#include "lwip_eth.h"
-#include "stm32f4x7_eth.h"
-#include "stm32f4xx.h"
-
-extern OS_EVENT *g_enet_rx_sem;
-/** @addtogroup Template_Project
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/******************************************************************************/
-/*            Cortex-M4 Processor Exceptions Handlers                         */
-/******************************************************************************/
-
-/**
- * @brief  This function handles NMI exception.
- * @param  None
- * @retval None
- */
-void NMI_Handler(void)
-{
-}
-
-/**
- * @brief  This function handles Hard Fault exception.
- * @param  None
- * @retval None
- */
-void HardFault_Handler(void)
-{
-    /* Go to infinite loop when Hard Fault exception occurs */
-    while (1)
-    {
-    }
-}
-
-/**
- * @brief  This function handles Memory Manage exception.
- * @param  None
- * @retval None
- */
-void MemManage_Handler(void)
-{
-    /* Go to infinite loop when Memory Manage exception occurs */
-    while (1)
-    {
-    }
-}
-
-/**
- * @brief  This function handles Bus Fault exception.
- * @param  None
- * @retval None
- */
-void BusFault_Handler(void)
-{
-    /* Go to infinite loop when Bus Fault exception occurs */
-    while (1)
-    {
-    }
-}
-
-/**
- * @brief  This function handles Usage Fault exception.
- * @param  None
- * @retval None
- */
-void UsageFault_Handler(void)
-{
-    /* Go to infinite loop when Usage Fault exception occurs */
-    while (1)
-    {
-    }
-}
-
-/**
- * @brief  This function handles SVCall exception.
- * @param  None
- * @retval None
- */
-void SVC_Handler(void)
-{
-}
-
-/**
- * @brief  This function handles Debug Monitor exception.
- * @param  None
- * @retval None
- */
-void DebugMon_Handler(void)
-{
-}
-
-/**
- * @brief  This function handles PendSVC exception.
- * @param  None
- * @retval None
- */
-// void PendSV_Handler(void)
-// {
-// }
-
-/**
- * @brief  This function handles SysTick Handler.
- * @param  None
- * @retval None
- */
-// void SysTick_Handler(void)
-// {
-//     // TimingDelay_Decrement();
-// }
-
-/******************************************************************************/
-/*                 STM32F4xx Peripherals Interrupt Handlers                   */
-/*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
-/*  available peripheral interrupt handler's name please refer to the startup */
-/*  file (startup_stm32f4xx.s).                                               */
-/******************************************************************************/
-
-/**
- * @brief  This function handles PPP interrupt request.
- * @param  None
- * @retval None
- */
-/*void PPP_IRQHandler(void)
-{
-}*/
-
-/**
- * @}
- */
-
-#ifdef USE_ETH_INTERRUPT
-/*!
-    \brief      this function handles ethernet interrupt request
-    \param[in]  none
-    \param[out] none
-    \retval     none
-*/
-void ETH_IRQHandler(void)
-{
-    OSIntEnter();
-
-    /* frame received */
-    if (SET == ETH_GetDMAITStatus(ETH_DMA_FLAG_R))
-    {
-        /* clear the enet DMA Rx interrupt pending bits */
-        ETH_DMAClearITPendingBit(ETH_DMA_FLAG_R);
-        ETH_DMAClearITPendingBit(ETH_DMA_FLAG_NIS);
-
-        /* give the semaphore to wakeup LwIP task */
-        OSSemPost(g_enet_rx_sem);
-    }
-
-    OSIntExit();
-}
-#endif /* USE_ETH_INTERRUPT */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+/**
+ ******************************************************************************
+ * @file    Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.c
+ * @author  MCD Application Team
+ * @version V1.5.0
+ * @date    06-March-2015
+ * @brief   Main Interrupt Service Routines.
+ *          This file provides template for all exceptions handler and
+ *          peripherals interrupt service routine.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *        http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f4xx_it.h"
+#include "includes.h"
+#include "lwip_eth.h"
+#include "stm32f4x7_eth.h"
+#include "stm32f4xx.h"
+
+extern OS_EVENT *g_enet_rx_sem;
+/** @addtogroup Template_Project
+ * @{
+ */
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/******************************************************************************/
+/*            Cortex-M4 Processor Exceptions Handlers                         */
+/******************************************************************************/
+
+/**
+ * @brief  This function handles NMI exception.
+ * @param  None
+ * @retval None
+ */
+void NMI_Handler(void)
+{
+}
+
+/**
+ * @brief  This function handles Hard Fault exception.
+ * @param  None
+ * @retval None
+ */
+void HardFault_Handler(void)
+{
+    /* Go to infinite loop when Hard Fault exception occurs */
+    while (1)
+    {
+    }
+}
+
+/**
+ * @brief  This function handles Memory Manage exception.
+ * @param  None
+ * @retval None
+ */
+void MemManage_Handler(void)
+{
+    /* Go to infinite loop when Memory Manage exception occurs */
+    while (1)
+    {
+    }
+}
+
+/**
+ * @brief  This function handles Bus Fault exception.
+ * @param  None
+ * @retval None
+ */
+void BusFault_Handler(void)
+{
+    /* Go to infinite loop when Bus Fault exception occurs */
+    while (1)
+    {
+    }
+}
+
+/**
+ * @brief  This function handles Usage Fault exception.
+ * @param  None
+ * @retval None
+ */
+void UsageFault_Handler(void)
+{
+    /* Go to infinite loop when Usage Fault exception occurs */
+    while (1)
+    {
+    }
+}
+
+/**
+ * @brief  This function handles SVCall exception.
+ * @param  None
+ * @retval None
+ */
+void SVC_Handler(void)
+{
+}
+
+/**
+ * @brief  This function handles Debug Monitor exception.
+ * @param  None
+ * @retval None
+ */
+void DebugMon_Handler(void)
+{
+}
+
+/**
+ * @brief  This function handles PendSVC exception.
+ * @param  None
+ * @retval None
+ */
+// void PendSV_Handler(void)
+// {
+// }
+
+/**
+ * @brief  This function handles SysTick Handler.
+ * @param  None
+ * @retval None
+ */
+// void SysTick_Handler(void)
+// {
+//     // TimingDelay_Decrement();
+// }
+
+/******************************************************************************/
+/*                 STM32F4xx Peripherals Interrupt Handlers                   */
+/*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
+/*  available peripheral interrupt handler's name please refer to the startup */
+/*  file (startup_stm32f4xx.s).                                               */
+/******************************************************************************/
+
+/**
+ * @brief  This function handles PPP interrupt request.
+ * @param  None
+ * @retval None
+ */
+/*void PPP_IRQHandler(void)
+{
+}*/
+
+/**
+ * @}
+ */
+
+#ifdef USE_ETH_INTERRUPT
+/*!
+    \brief      this function handles ethernet interrupt request
+    \param[in]  none
+    \param[out] none
+    \retval     none
+*/
+void ETH_IRQHandler(void)
+{
+    OSIntEnter();
+
+    /* frame received */
+    if (SET == ETH_GetDMAITStatus(ETH_DMA_FLAG_R))
+    {
+        /* clear the enet DMA Rx interrupt pending bits */
+        ETH_DMAClearITPendingBit(ETH_DMA_FLAG_R);
+        ETH_DMAClearITPendingBit(ETH_DMA_FLAG_NIS);
+
+        /* give the semaphore to wakeup LwIP task */
+        OSSemPost(g_enet_rx_sem);
+    }
+
+    OSIntExit();
+}
+#endif /* USE_ETH_INTERRUPT */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 61 - 61
User/stm32f4xx_it.h → Project/stm32f4xx_it.h

@@ -1,61 +1,61 @@
-/**
- ******************************************************************************
- * @file    Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.h
- * @author  MCD Application Team
- * @version V1.5.0
- * @date    06-March-2015
- * @brief   This file contains the headers of the interrupt handlers.
- ******************************************************************************
- * @attention
- *
- * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *        http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STM32F4xx_IT_H
-#define __STM32F4xx_IT_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32f4xx.h"
-
-    /* Exported types ------------------------------------------------------------*/
-    /* Exported constants --------------------------------------------------------*/
-    /* Exported macro ------------------------------------------------------------*/
-    /* Exported functions ------------------------------------------------------- */
-
-    void NMI_Handler(void);
-    void HardFault_Handler(void);
-    void MemManage_Handler(void);
-    void BusFault_Handler(void);
-    void UsageFault_Handler(void);
-    void SVC_Handler(void);
-    void DebugMon_Handler(void);
-    void PendSV_Handler(void);
-    void SysTick_Handler(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __STM32F4xx_IT_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+/**
+ ******************************************************************************
+ * @file    Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.h
+ * @author  MCD Application Team
+ * @version V1.5.0
+ * @date    06-March-2015
+ * @brief   This file contains the headers of the interrupt handlers.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *        http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_IT_H
+#define __STM32F4xx_IT_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f4xx.h"
+
+    /* Exported types ------------------------------------------------------------*/
+    /* Exported constants --------------------------------------------------------*/
+    /* Exported macro ------------------------------------------------------------*/
+    /* Exported functions ------------------------------------------------------- */
+
+    void NMI_Handler(void);
+    void HardFault_Handler(void);
+    void MemManage_Handler(void);
+    void BusFault_Handler(void);
+    void UsageFault_Handler(void);
+    void SVC_Handler(void);
+    void DebugMon_Handler(void);
+    void PendSV_Handler(void);
+    void SysTick_Handler(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_IT_H */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 1220 - 1220
User/system_stm32f4xx.c → Project/system_stm32f4xx.c

@@ -1,1220 +1,1220 @@
-/**
- ******************************************************************************
- * @file    system_stm32f4xx.c
- * @author  MCD Application Team
- * @version V1.5.0
- * @date    06-March-2015
- * @brief   CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
- *          This file contains the system clock configuration for STM32F4xx devices.
- *
- * 1.  This file provides two functions and one global variable to be called from
- *     user application:
- *      - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
- *                      and Divider factors, AHB/APBx prescalers and Flash settings),
- *                      depending on the configuration made in the clock xls tool.
- *                      This function is called at startup just after reset and
- *                      before branch to main program. This call is made inside
- *                      the "startup_stm32f4xx.s" file.
- *
- *      - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
- *                                  by the user application to setup the SysTick
- *                                  timer or configure other parameters.
- *
- *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
- *                                 be called whenever the core clock is changed
- *                                 during program execution.
- *
- * 2. After each device reset the HSI (16 MHz) is used as system clock source.
- *    Then SystemInit() function is called, in "startup_stm32f4xx.s" file, to
- *    configure the system clock before to branch to main program.
- *
- * 3. If the system clock source selected by user fails to startup, the SystemInit()
- *    function will do nothing and HSI still used as system clock source. User can
- *    add some code to deal with this issue inside the SetSysClock() function.
- *
- * 4. The default value of HSE crystal is set to 25MHz, refer to "HSE_VALUE" define
- *    in "stm32f4xx.h" file. When HSE is used as system clock source, directly or
- *    through PLL, and you are using different crystal you have to adapt the HSE
- *    value to your own configuration.
- *
- * 5. This file configures the system clock as follows:
- *=============================================================================
- *=============================================================================
- *                    Supported STM32F40xxx/41xxx devices
- *-----------------------------------------------------------------------------
- *        System Clock source                    | PLL (HSE)
- *-----------------------------------------------------------------------------
- *        SYSCLK(Hz)                             | 168000000
- *-----------------------------------------------------------------------------
- *        HCLK(Hz)                               | 168000000
- *-----------------------------------------------------------------------------
- *        AHB Prescaler                          | 1
- *-----------------------------------------------------------------------------
- *        APB1 Prescaler                         | 4
- *-----------------------------------------------------------------------------
- *        APB2 Prescaler                         | 2
- *-----------------------------------------------------------------------------
- *        HSE Frequency(Hz)                      | 25000000
- *-----------------------------------------------------------------------------
- *        PLL_M                                  | 25
- *-----------------------------------------------------------------------------
- *        PLL_N                                  | 336
- *-----------------------------------------------------------------------------
- *        PLL_P                                  | 2
- *-----------------------------------------------------------------------------
- *        PLL_Q                                  | 7
- *-----------------------------------------------------------------------------
- *        PLLI2S_N                               | NA
- *-----------------------------------------------------------------------------
- *        PLLI2S_R                               | NA
- *-----------------------------------------------------------------------------
- *        I2S input clock                        | NA
- *-----------------------------------------------------------------------------
- *        VDD(V)                                 | 3.3
- *-----------------------------------------------------------------------------
- *        Main regulator output voltage          | Scale1 mode
- *-----------------------------------------------------------------------------
- *        Flash Latency(WS)                      | 5
- *-----------------------------------------------------------------------------
- *        Prefetch Buffer                        | ON
- *-----------------------------------------------------------------------------
- *        Instruction cache                      | ON
- *-----------------------------------------------------------------------------
- *        Data cache                             | ON
- *-----------------------------------------------------------------------------
- *        Require 48MHz for USB OTG FS,          | Disabled
- *        SDIO and RNG clock                     |
- *-----------------------------------------------------------------------------
- *=============================================================================
- *=============================================================================
- *                    Supported STM32F42xxx/43xxx devices
- *-----------------------------------------------------------------------------
- *        System Clock source                    | PLL (HSE)
- *-----------------------------------------------------------------------------
- *        SYSCLK(Hz)                             | 180000000
- *-----------------------------------------------------------------------------
- *        HCLK(Hz)                               | 180000000
- *-----------------------------------------------------------------------------
- *        AHB Prescaler                          | 1
- *-----------------------------------------------------------------------------
- *        APB1 Prescaler                         | 4
- *-----------------------------------------------------------------------------
- *        APB2 Prescaler                         | 2
- *-----------------------------------------------------------------------------
- *        HSE Frequency(Hz)                      | 25000000
- *-----------------------------------------------------------------------------
- *        PLL_M                                  | 25
- *-----------------------------------------------------------------------------
- *        PLL_N                                  | 360
- *-----------------------------------------------------------------------------
- *        PLL_P                                  | 2
- *-----------------------------------------------------------------------------
- *        PLL_Q                                  | 7
- *-----------------------------------------------------------------------------
- *        PLLI2S_N                               | NA
- *-----------------------------------------------------------------------------
- *        PLLI2S_R                               | NA
- *-----------------------------------------------------------------------------
- *        I2S input clock                        | NA
- *-----------------------------------------------------------------------------
- *        VDD(V)                                 | 3.3
- *-----------------------------------------------------------------------------
- *        Main regulator output voltage          | Scale1 mode
- *-----------------------------------------------------------------------------
- *        Flash Latency(WS)                      | 5
- *-----------------------------------------------------------------------------
- *        Prefetch Buffer                        | ON
- *-----------------------------------------------------------------------------
- *        Instruction cache                      | ON
- *-----------------------------------------------------------------------------
- *        Data cache                             | ON
- *-----------------------------------------------------------------------------
- *        Require 48MHz for USB OTG FS,          | Disabled
- *        SDIO and RNG clock                     |
- *-----------------------------------------------------------------------------
- *=============================================================================
- *=============================================================================
- *                         Supported STM32F401xx devices
- *-----------------------------------------------------------------------------
- *        System Clock source                    | PLL (HSE)
- *-----------------------------------------------------------------------------
- *        SYSCLK(Hz)                             | 84000000
- *-----------------------------------------------------------------------------
- *        HCLK(Hz)                               | 84000000
- *-----------------------------------------------------------------------------
- *        AHB Prescaler                          | 1
- *-----------------------------------------------------------------------------
- *        APB1 Prescaler                         | 2
- *-----------------------------------------------------------------------------
- *        APB2 Prescaler                         | 1
- *-----------------------------------------------------------------------------
- *        HSE Frequency(Hz)                      | 25000000
- *-----------------------------------------------------------------------------
- *        PLL_M                                  | 25
- *-----------------------------------------------------------------------------
- *        PLL_N                                  | 336
- *-----------------------------------------------------------------------------
- *        PLL_P                                  | 4
- *-----------------------------------------------------------------------------
- *        PLL_Q                                  | 7
- *-----------------------------------------------------------------------------
- *        PLLI2S_N                               | NA
- *-----------------------------------------------------------------------------
- *        PLLI2S_R                               | NA
- *-----------------------------------------------------------------------------
- *        I2S input clock                        | NA
- *-----------------------------------------------------------------------------
- *        VDD(V)                                 | 3.3
- *-----------------------------------------------------------------------------
- *        Main regulator output voltage          | Scale1 mode
- *-----------------------------------------------------------------------------
- *        Flash Latency(WS)                      | 2
- *-----------------------------------------------------------------------------
- *        Prefetch Buffer                        | ON
- *-----------------------------------------------------------------------------
- *        Instruction cache                      | ON
- *-----------------------------------------------------------------------------
- *        Data cache                             | ON
- *-----------------------------------------------------------------------------
- *        Require 48MHz for USB OTG FS,          | Disabled
- *        SDIO and RNG clock                     |
- *-----------------------------------------------------------------------------
- *=============================================================================
- *=============================================================================
- *                         Supported STM32F411xx devices
- *-----------------------------------------------------------------------------
- *        System Clock source                    | PLL (HSI)
- *-----------------------------------------------------------------------------
- *        SYSCLK(Hz)                             | 100000000
- *-----------------------------------------------------------------------------
- *        HCLK(Hz)                               | 100000000
- *-----------------------------------------------------------------------------
- *        AHB Prescaler                          | 1
- *-----------------------------------------------------------------------------
- *        APB1 Prescaler                         | 2
- *-----------------------------------------------------------------------------
- *        APB2 Prescaler                         | 1
- *-----------------------------------------------------------------------------
- *        HSI Frequency(Hz)                      | 16000000
- *-----------------------------------------------------------------------------
- *        PLL_M                                  | 16
- *-----------------------------------------------------------------------------
- *        PLL_N                                  | 400
- *-----------------------------------------------------------------------------
- *        PLL_P                                  | 4
- *-----------------------------------------------------------------------------
- *        PLL_Q                                  | 7
- *-----------------------------------------------------------------------------
- *        PLLI2S_N                               | NA
- *-----------------------------------------------------------------------------
- *        PLLI2S_R                               | NA
- *-----------------------------------------------------------------------------
- *        I2S input clock                        | NA
- *-----------------------------------------------------------------------------
- *        VDD(V)                                 | 3.3
- *-----------------------------------------------------------------------------
- *        Main regulator output voltage          | Scale1 mode
- *-----------------------------------------------------------------------------
- *        Flash Latency(WS)                      | 3
- *-----------------------------------------------------------------------------
- *        Prefetch Buffer                        | ON
- *-----------------------------------------------------------------------------
- *        Instruction cache                      | ON
- *-----------------------------------------------------------------------------
- *        Data cache                             | ON
- *-----------------------------------------------------------------------------
- *        Require 48MHz for USB OTG FS,          | Disabled
- *        SDIO and RNG clock                     |
- *-----------------------------------------------------------------------------
- *=============================================================================
- *=============================================================================
- *                         Supported STM32F446xx devices
- *-----------------------------------------------------------------------------
- *        System Clock source                    | PLL (HSE)
- *-----------------------------------------------------------------------------
- *        SYSCLK(Hz)                             | 180000000
- *-----------------------------------------------------------------------------
- *        HCLK(Hz)                               | 180000000
- *-----------------------------------------------------------------------------
- *        AHB Prescaler                          | 1
- *-----------------------------------------------------------------------------
- *        APB1 Prescaler                         | 4
- *-----------------------------------------------------------------------------
- *        APB2 Prescaler                         | 2
- *-----------------------------------------------------------------------------
- *        HSE Frequency(Hz)                      | 8000000
- *-----------------------------------------------------------------------------
- *        PLL_M                                  | 8
- *-----------------------------------------------------------------------------
- *        PLL_N                                  | 360
- *-----------------------------------------------------------------------------
- *        PLL_P                                  | 2
- *-----------------------------------------------------------------------------
- *        PLL_Q                                  | 7
- *-----------------------------------------------------------------------------
- *        PLL_R                                  | NA
- *-----------------------------------------------------------------------------
- *        PLLI2S_M                               | NA
- *-----------------------------------------------------------------------------
- *        PLLI2S_N                               | NA
- *-----------------------------------------------------------------------------
- *        PLLI2S_P                               | NA
- *-----------------------------------------------------------------------------
- *        PLLI2S_Q                               | NA
- *-----------------------------------------------------------------------------
- *        PLLI2S_R                               | NA
- *-----------------------------------------------------------------------------
- *        I2S input clock                        | NA
- *-----------------------------------------------------------------------------
- *        VDD(V)                                 | 3.3
- *-----------------------------------------------------------------------------
- *        Main regulator output voltage          | Scale1 mode
- *-----------------------------------------------------------------------------
- *        Flash Latency(WS)                      | 5
- *-----------------------------------------------------------------------------
- *        Prefetch Buffer                        | ON
- *-----------------------------------------------------------------------------
- *        Instruction cache                      | ON
- *-----------------------------------------------------------------------------
- *        Data cache                             | ON
- *-----------------------------------------------------------------------------
- *        Require 48MHz for USB OTG FS,          | Disabled
- *        SDIO and RNG clock                     |
- *-----------------------------------------------------------------------------
- *=============================================================================
- ******************************************************************************
- * @attention
- *
- * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *        http://www.st.com/software_license_agreement_liberty_v2
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
-
-/** @addtogroup CMSIS
- * @{
- */
-
-/** @addtogroup stm32f4xx_system
- * @{
- */
-
-/** @addtogroup STM32F4xx_System_Private_Includes
- * @{
- */
-
-#include "stm32f4xx.h"
-
-/**
- * @}
- */
-
-/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
- * @{
- */
-
-/**
- * @}
- */
-
-/** @addtogroup STM32F4xx_System_Private_Defines
- * @{
- */
-
-/************************* Miscellaneous Configuration ************************/
-/*!< Uncomment the following line if you need to use external SRAM or SDRAM mounted
-     on STM324xG_EVAL/STM324x7I_EVAL/STM324x9I_EVAL boards as data memory  */
-#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx)
-/* #define DATA_IN_ExtSRAM */
-#endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx */
-
-#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
-/* #define DATA_IN_ExtSDRAM */
-#endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx */
-
-#if defined(STM32F411xE)
-/*!< Uncomment the following line if you need to clock the STM32F411xE by HSE Bypass
-     through STLINK MCO pin of STM32F103 microcontroller. The frequency cannot be changed
-     and is fixed at 8 MHz.
-     Hardware configuration needed for Nucleo Board:
-     � SB54, SB55 OFF
-     � R35 removed
-     � SB16, SB50 ON */
-/* #define USE_HSE_BYPASS */
-
-#if defined(USE_HSE_BYPASS)
-#define HSE_BYPASS_INPUT_FREQUENCY 8000000
-#endif /* USE_HSE_BYPASS */
-#endif /* STM32F411xE */
-
-/*!< Uncomment the following line if you need to relocate your vector Table in
-     Internal SRAM. */
-/* #define VECT_TAB_SRAM */
-#define VECT_TAB_OFFSET 0x10000 /*!< Vector Table base offset field. \
-                                  This value must be a multiple of 0x200. */
-/******************************************************************************/
-
-/************************* PLL Parameters *************************************/
-#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx)
-/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
-#define PLL_M 25
-#elif defined(STM32F446xx)
-#define PLL_M 8
-#elif defined(STM32F411xE)
-
-#if defined(USE_HSE_BYPASS)
-#define PLL_M 8
-#else
-#define PLL_M 16
-#endif /* USE_HSE_BYPASS */
-
-#endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx */
-
-/* USB OTG FS, SDIO and RNG Clock =  PLL_VCO / PLLQ */
-#define PLL_Q 7
-
-#if defined(STM32F446xx)
-/* PLL division factor for I2S, SAI, SYSTEM and SPDIF: Clock =  PLL_VCO / PLLR */
-#define PLL_R 7
-#endif /* STM32F446xx */
-
-#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
-#define PLL_N 336
-/* SYSCLK = PLL_VCO / PLL_P */
-#define PLL_P 2
-#endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx || STM32F446xx */
-
-#if defined(STM32F401xx)
-#define PLL_N 336
-/* SYSCLK = PLL_VCO / PLL_P */
-#define PLL_P 4
-#endif /* STM32F401xx */
-
-#if defined(STM32F411xE)
-#define PLL_N 400
-/* SYSCLK = PLL_VCO / PLL_P */
-#define PLL_P 4
-#endif /* STM32F411xx */
-
-/******************************************************************************/
-
-/**
- * @}
- */
-
-/** @addtogroup STM32F4xx_System_Private_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-/** @addtogroup STM32F4xx_System_Private_Variables
- * @{
- */
-
-#if defined(STM32F40_41xxx)
-uint32_t SystemCoreClock = 168000000;
-#endif /* STM32F40_41xxx */
-
-#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
-uint32_t SystemCoreClock = 180000000;
-#endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx */
-
-#if defined(STM32F401xx)
-uint32_t SystemCoreClock = 84000000;
-#endif /* STM32F401xx */
-
-#if defined(STM32F411xE)
-uint32_t SystemCoreClock = 100000000;
-#endif /* STM32F401xx */
-
-__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
-
-/**
- * @}
- */
-
-/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
- * @{
- */
-
-static void SetSysClock(void);
-
-#if defined(DATA_IN_ExtSRAM) || defined(DATA_IN_ExtSDRAM)
-static void SystemInit_ExtMemCtl(void);
-#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
-
-/**
- * @}
- */
-
-/** @addtogroup STM32F4xx_System_Private_Functions
- * @{
- */
-
-/**
- * @brief  Setup the microcontroller system
- *         Initialize the Embedded Flash Interface, the PLL and update the
- *         SystemFrequency variable.
- * @param  None
- * @retval None
- */
-void SystemInit(void)
-{
-/* FPU settings ------------------------------------------------------------*/
-#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
-    SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */
-#endif
-    /* Reset the RCC clock configuration to the default reset state ------------*/
-    /* Set HSION bit */
-    RCC->CR |= (uint32_t)0x00000001;
-
-    /* Reset CFGR register */
-    RCC->CFGR = 0x00000000;
-
-    /* Reset HSEON, CSSON and PLLON bits */
-    RCC->CR &= (uint32_t)0xFEF6FFFF;
-
-    /* Reset PLLCFGR register */
-    RCC->PLLCFGR = 0x24003010;
-
-    /* Reset HSEBYP bit */
-    RCC->CR &= (uint32_t)0xFFFBFFFF;
-
-    /* Disable all interrupts */
-    RCC->CIR = 0x00000000;
-
-#if defined(DATA_IN_ExtSRAM) || defined(DATA_IN_ExtSDRAM)
-    SystemInit_ExtMemCtl();
-#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
-
-    /* Configure the System clock source, PLL Multiplier and Divider factors,
-       AHB/APBx prescalers and Flash settings ----------------------------------*/
-    SetSysClock();
-
-    /* Configure the Vector Table location add offset address ------------------*/
-#ifdef VECT_TAB_SRAM
-    SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
-#else
-    SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
-#endif
-}
-
-/**
- * @brief  Update SystemCoreClock variable according to Clock Register Values.
- *         The SystemCoreClock variable contains the core clock (HCLK), it can
- *         be used by the user application to setup the SysTick timer or configure
- *         other parameters.
- *
- * @note   Each time the core clock (HCLK) changes, this function must be called
- *         to update SystemCoreClock variable value. Otherwise, any configuration
- *         based on this variable will be incorrect.
- *
- * @note   - The system frequency computed by this function is not the real
- *           frequency in the chip. It is calculated based on the predefined
- *           constant and the selected clock source:
- *
- *           - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
- *
- *           - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
- *
- *           - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
- *             or HSI_VALUE(*) multiplied/divided by the PLL factors.
- *
- *         (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value
- *             16 MHz) but the real value may vary depending on the variations
- *             in voltage and temperature.
- *
- *         (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value
- *              25 MHz), user has to ensure that HSE_VALUE is same as the real
- *              frequency of the crystal used. Otherwise, this function may
- *              have wrong result.
- *
- *         - The result of this function could be not correct when using fractional
- *           value for HSE crystal.
- *
- * @param  None
- * @retval None
- */
-void SystemCoreClockUpdate(void)
-{
-    uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
-#if defined(STM32F446xx)
-    uint32_t pllr = 2;
-#endif /* STM32F446xx */
-    /* Get SYSCLK source -------------------------------------------------------*/
-    tmp = RCC->CFGR & RCC_CFGR_SWS;
-
-    switch (tmp)
-    {
-    case 0x00: /* HSI used as system clock source */
-        SystemCoreClock = HSI_VALUE;
-        break;
-    case 0x04: /* HSE used as system clock source */
-        SystemCoreClock = HSE_VALUE;
-        break;
-    case 0x08: /* PLL P used as system clock source */
-               /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
-                 SYSCLK = PLL_VCO / PLL_P
-                 */
-        pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
-        pllm      = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
-
-#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F446xx)
-        if (pllsource != 0)
-        {
-            /* HSE used as PLL clock source */
-            pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
-        }
-        else
-        {
-            /* HSI used as PLL clock source */
-            pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
-        }
-#elif defined(STM32F411xE)
-#if defined(USE_HSE_BYPASS)
-        if (pllsource != 0)
-        {
-            /* HSE used as PLL clock source */
-            pllvco = (HSE_BYPASS_INPUT_FREQUENCY / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
-        }
-#else
-        if (pllsource == 0)
-        {
-            /* HSI used as PLL clock source */
-            pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
-        }
-#endif /* USE_HSE_BYPASS */
-#endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F446xx */
-        pllp            = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >> 16) + 1) * 2;
-        SystemCoreClock = pllvco / pllp;
-        break;
-#if defined(STM32F446xx)
-    case 0x0C: /* PLL R used as system clock source */
-               /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
-                 SYSCLK = PLL_VCO / PLL_R
-                 */
-        pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
-        pllm      = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
-        if (pllsource != 0)
-        {
-            /* HSE used as PLL clock source */
-            pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
-        }
-        else
-        {
-            /* HSI used as PLL clock source */
-            pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
-        }
-
-        pllr            = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 28) + 1) * 2;
-        SystemCoreClock = pllvco / pllr;
-        break;
-#endif /* STM32F446xx */
-    default:
-        SystemCoreClock = HSI_VALUE;
-        break;
-    }
-    /* Compute HCLK frequency --------------------------------------------------*/
-    /* Get HCLK prescaler */
-    tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
-    /* HCLK frequency */
-    SystemCoreClock >>= tmp;
-}
-
-/**
- * @brief  Configures the System clock source, PLL Multiplier and Divider factors,
- *         AHB/APBx prescalers and Flash settings
- * @Note   This function should be called only once the RCC clock configuration
- *         is reset to the default reset state (done in SystemInit() function).
- * @param  None
- * @retval None
- */
-static void SetSysClock(void)
-{
-#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F446xx)
-    /******************************************************************************/
-    /*            PLL (clocked by HSE) used as System clock source                */
-    /******************************************************************************/
-    __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
-
-    /* Enable HSE */
-    RCC->CR |= ((uint32_t)RCC_CR_HSEON);
-
-    /* Wait till HSE is ready and if Time out is reached exit */
-    do
-    {
-        HSEStatus = RCC->CR & RCC_CR_HSERDY;
-        StartUpCounter++;
-    } while ((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
-
-    if ((RCC->CR & RCC_CR_HSERDY) != RESET)
-    {
-        HSEStatus = (uint32_t)0x01;
-    }
-    else
-    {
-        HSEStatus = (uint32_t)0x00;
-    }
-
-    if (HSEStatus == (uint32_t)0x01)
-    {
-        /* Select regulator voltage output Scale 1 mode */
-        RCC->APB1ENR |= RCC_APB1ENR_PWREN;
-        PWR->CR |= PWR_CR_VOS;
-
-        /* HCLK = SYSCLK / 1*/
-        RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
-
-#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
-        /* PCLK2 = HCLK / 2*/
-        RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
-
-        /* PCLK1 = HCLK / 4*/
-        RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
-#endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx || STM32F446xx */
-
-#if defined(STM32F401xx)
-        /* PCLK2 = HCLK / 2*/
-        RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
-
-        /* PCLK1 = HCLK / 4*/
-        RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
-#endif /* STM32F401xx */
-
-#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx)
-        /* Configure the main PLL */
-        RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) |
-                       (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);
-#endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx || STM32F401xx */
-
-#if defined(STM32F446xx)
-        /* Configure the main PLL */
-        RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) |
-                       (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24) | (PLL_R << 28);
-#endif /* STM32F446xx */
-
-        /* Enable the main PLL */
-        RCC->CR |= RCC_CR_PLLON;
-
-        /* Wait till the main PLL is ready */
-        while ((RCC->CR & RCC_CR_PLLRDY) == 0)
-        {
-        }
-
-#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
-        /* Enable the Over-drive to extend the clock frequency to 180 Mhz */
-        PWR->CR |= PWR_CR_ODEN;
-        while ((PWR->CSR & PWR_CSR_ODRDY) == 0)
-        {
-        }
-        PWR->CR |= PWR_CR_ODSWEN;
-        while ((PWR->CSR & PWR_CSR_ODSWRDY) == 0)
-        {
-        }
-        /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
-        FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS;
-#endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx */
-
-#if defined(STM32F40_41xxx)
-        /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
-        FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS;
-#endif /* STM32F40_41xxx  */
-
-#if defined(STM32F401xx)
-        /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
-        FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_2WS;
-#endif /* STM32F401xx */
-
-        /* Select the main PLL as system clock source */
-        RCC->CFGR &= (uint32_t)((uint32_t) ~(RCC_CFGR_SW));
-        RCC->CFGR |= RCC_CFGR_SW_PLL;
-
-        /* Wait till the main PLL is used as system clock source */
-        while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL)
-        {
-        };
-    }
-    else
-    { /* If HSE fails to start-up, the application will have wrong clock
-           configuration. User can add here some code to deal with this error */
-    }
-#elif defined(STM32F411xE)
-#if defined(USE_HSE_BYPASS)
-    /******************************************************************************/
-    /*            PLL (clocked by HSE) used as System clock source                */
-    /******************************************************************************/
-    __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
-
-    /* Enable HSE and HSE BYPASS */
-    RCC->CR |= ((uint32_t)RCC_CR_HSEON | RCC_CR_HSEBYP);
-
-    /* Wait till HSE is ready and if Time out is reached exit */
-    do
-    {
-        HSEStatus = RCC->CR & RCC_CR_HSERDY;
-        StartUpCounter++;
-    } while ((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
-
-    if ((RCC->CR & RCC_CR_HSERDY) != RESET)
-    {
-        HSEStatus = (uint32_t)0x01;
-    }
-    else
-    {
-        HSEStatus = (uint32_t)0x00;
-    }
-
-    if (HSEStatus == (uint32_t)0x01)
-    {
-        /* Select regulator voltage output Scale 1 mode */
-        RCC->APB1ENR |= RCC_APB1ENR_PWREN;
-        PWR->CR |= PWR_CR_VOS;
-
-        /* HCLK = SYSCLK / 1*/
-        RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
-
-        /* PCLK2 = HCLK / 2*/
-        RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
-
-        /* PCLK1 = HCLK / 4*/
-        RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
-
-        /* Configure the main PLL */
-        RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) |
-                       (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);
-
-        /* Enable the main PLL */
-        RCC->CR |= RCC_CR_PLLON;
-
-        /* Wait till the main PLL is ready */
-        while ((RCC->CR & RCC_CR_PLLRDY) == 0)
-        {
-        }
-
-        /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
-        FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_2WS;
-
-        /* Select the main PLL as system clock source */
-        RCC->CFGR &= (uint32_t)((uint32_t) ~(RCC_CFGR_SW));
-        RCC->CFGR |= RCC_CFGR_SW_PLL;
-
-        /* Wait till the main PLL is used as system clock source */
-        while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL)
-            ;
-        {
-        }
-    }
-    else
-    { /* If HSE fails to start-up, the application will have wrong clock
-           configuration. User can add here some code to deal with this error */
-    }
-#else  /* HSI will be used as PLL clock source */
-    /* Select regulator voltage output Scale 1 mode */
-    RCC->APB1ENR |= RCC_APB1ENR_PWREN;
-    PWR->CR |= PWR_CR_VOS;
-
-    /* HCLK = SYSCLK / 1*/
-    RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
-
-    /* PCLK2 = HCLK / 2*/
-    RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
-
-    /* PCLK1 = HCLK / 4*/
-    RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
-
-    /* Configure the main PLL */
-    RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) | (PLL_Q << 24);
-
-    /* Enable the main PLL */
-    RCC->CR |= RCC_CR_PLLON;
-
-    /* Wait till the main PLL is ready */
-    while ((RCC->CR & RCC_CR_PLLRDY) == 0)
-    {
-    }
-
-    /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
-    FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_2WS;
-
-    /* Select the main PLL as system clock source */
-    RCC->CFGR &= (uint32_t)((uint32_t) ~(RCC_CFGR_SW));
-    RCC->CFGR |= RCC_CFGR_SW_PLL;
-
-    /* Wait till the main PLL is used as system clock source */
-    while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL)
-        ;
-    {
-    }
-#endif /* USE_HSE_BYPASS */
-#endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx */
-}
-
-/**
- * @brief  Setup the external memory controller. Called in startup_stm32f4xx.s
- *          before jump to __main
- * @param  None
- * @retval None
- */
-#ifdef DATA_IN_ExtSRAM
-/**
- * @brief  Setup the external memory controller.
- *         Called in startup_stm32f4xx.s before jump to main.
- *         This function configures the external SRAM mounted on STM324xG_EVAL/STM324x7I boards
- *         This SRAM will be used as program data memory (including heap and stack).
- * @param  None
- * @retval None
- */
-void SystemInit_ExtMemCtl(void)
-{
-    /*-- GPIOs Configuration -----------------------------------------------------*/
-    /*
-     +-------------------+--------------------+------------------+--------------+
-     +                       SRAM pins assignment                               +
-     +-------------------+--------------------+------------------+--------------+
-     | PD0  <-> FMC_D2  | PE0  <-> FMC_NBL0 | PF0  <-> FMC_A0 | PG0 <-> FMC_A10 |
-     | PD1  <-> FMC_D3  | PE1  <-> FMC_NBL1 | PF1  <-> FMC_A1 | PG1 <-> FMC_A11 |
-     | PD4  <-> FMC_NOE | PE3  <-> FMC_A19  | PF2  <-> FMC_A2 | PG2 <-> FMC_A12 |
-     | PD5  <-> FMC_NWE | PE4  <-> FMC_A20  | PF3  <-> FMC_A3 | PG3 <-> FMC_A13 |
-     | PD8  <-> FMC_D13 | PE7  <-> FMC_D4   | PF4  <-> FMC_A4 | PG4 <-> FMC_A14 |
-     | PD9  <-> FMC_D14 | PE8  <-> FMC_D5   | PF5  <-> FMC_A5 | PG5 <-> FMC_A15 |
-     | PD10 <-> FMC_D15 | PE9  <-> FMC_D6   | PF12 <-> FMC_A6 | PG9 <-> FMC_NE2 |
-     | PD11 <-> FMC_A16 | PE10 <-> FMC_D7   | PF13 <-> FMC_A7 |-----------------+
-     | PD12 <-> FMC_A17 | PE11 <-> FMC_D8   | PF14 <-> FMC_A8 |
-     | PD13 <-> FMC_A18 | PE12 <-> FMC_D9   | PF15 <-> FMC_A9 |
-     | PD14 <-> FMC_D0  | PE13 <-> FMC_D10  |-----------------+
-     | PD15 <-> FMC_D1  | PE14 <-> FMC_D11  |
-     |                  | PE15 <-> FMC_D12  |
-     +------------------+------------------+
-    */
-    /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
-    RCC->AHB1ENR |= 0x00000078;
-
-    /* Connect PDx pins to FMC Alternate function */
-    GPIOD->AFR[0] = 0x00cc00cc;
-    GPIOD->AFR[1] = 0xcccccccc;
-    /* Configure PDx pins in Alternate function mode */
-    GPIOD->MODER = 0xaaaa0a0a;
-    /* Configure PDx pins speed to 100 MHz */
-    GPIOD->OSPEEDR = 0xffff0f0f;
-    /* Configure PDx pins Output type to push-pull */
-    GPIOD->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PDx pins */
-    GPIOD->PUPDR = 0x00000000;
-
-    /* Connect PEx pins to FMC Alternate function */
-    GPIOE->AFR[0] = 0xcccccccc;
-    GPIOE->AFR[1] = 0xcccccccc;
-    /* Configure PEx pins in Alternate function mode */
-    GPIOE->MODER = 0xaaaaaaaa;
-    /* Configure PEx pins speed to 100 MHz */
-    GPIOE->OSPEEDR = 0xffffffff;
-    /* Configure PEx pins Output type to push-pull */
-    GPIOE->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PEx pins */
-    GPIOE->PUPDR = 0x00000000;
-
-    /* Connect PFx pins to FMC Alternate function */
-    GPIOF->AFR[0] = 0x00cccccc;
-    GPIOF->AFR[1] = 0xcccc0000;
-    /* Configure PFx pins in Alternate function mode */
-    GPIOF->MODER = 0xaa000aaa;
-    /* Configure PFx pins speed to 100 MHz */
-    GPIOF->OSPEEDR = 0xff000fff;
-    /* Configure PFx pins Output type to push-pull */
-    GPIOF->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PFx pins */
-    GPIOF->PUPDR = 0x00000000;
-
-    /* Connect PGx pins to FMC Alternate function */
-    GPIOG->AFR[0] = 0x00cccccc;
-    GPIOG->AFR[1] = 0x000000c0;
-    /* Configure PGx pins in Alternate function mode */
-    GPIOG->MODER = 0x00080aaa;
-    /* Configure PGx pins speed to 100 MHz */
-    GPIOG->OSPEEDR = 0x000c0fff;
-    /* Configure PGx pins Output type to push-pull */
-    GPIOG->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PGx pins */
-    GPIOG->PUPDR = 0x00000000;
-
-    /*-- FMC Configuration ------------------------------------------------------*/
-    /* Enable the FMC/FSMC interface clock */
-    RCC->AHB3ENR |= 0x00000001;
-
-#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
-    /* Configure and enable Bank1_SRAM2 */
-    FMC_Bank1->BTCR[2]  = 0x00001011;
-    FMC_Bank1->BTCR[3]  = 0x00000201;
-    FMC_Bank1E->BWTR[2] = 0x0fffffff;
-#endif /* STM32F427_437xx || STM32F429_439xx */
-
-#if defined(STM32F40_41xxx)
-    /* Configure and enable Bank1_SRAM2 */
-    FSMC_Bank1->BTCR[2]  = 0x00001011;
-    FSMC_Bank1->BTCR[3]  = 0x00000201;
-    FSMC_Bank1E->BWTR[2] = 0x0fffffff;
-#endif /* STM32F40_41xxx */
-
-    /*
-      Bank1_SRAM2 is configured as follow:
-      In case of FSMC configuration
-      NORSRAMTimingStructure.FSMC_AddressSetupTime = 1;
-      NORSRAMTimingStructure.FSMC_AddressHoldTime = 0;
-      NORSRAMTimingStructure.FSMC_DataSetupTime = 2;
-      NORSRAMTimingStructure.FSMC_BusTurnAroundDuration = 0;
-      NORSRAMTimingStructure.FSMC_CLKDivision = 0;
-      NORSRAMTimingStructure.FSMC_DataLatency = 0;
-      NORSRAMTimingStructure.FSMC_AccessMode = FMC_AccessMode_A;
-
-      FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
-      FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
-      FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
-      FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
-      FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
-      FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
-      FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
-      FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
-      FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
-      FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
-      FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
-      FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
-      FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
-      FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &NORSRAMTimingStructure;
-      FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &NORSRAMTimingStructure;
-
-      In case of FMC configuration
-      NORSRAMTimingStructure.FMC_AddressSetupTime = 1;
-      NORSRAMTimingStructure.FMC_AddressHoldTime = 0;
-      NORSRAMTimingStructure.FMC_DataSetupTime = 2;
-      NORSRAMTimingStructure.FMC_BusTurnAroundDuration = 0;
-      NORSRAMTimingStructure.FMC_CLKDivision = 0;
-      NORSRAMTimingStructure.FMC_DataLatency = 0;
-      NORSRAMTimingStructure.FMC_AccessMode = FMC_AccessMode_A;
-
-      FMC_NORSRAMInitStructure.FMC_Bank = FMC_Bank1_NORSRAM2;
-      FMC_NORSRAMInitStructure.FMC_DataAddressMux = FMC_DataAddressMux_Disable;
-      FMC_NORSRAMInitStructure.FMC_MemoryType = FMC_MemoryType_SRAM;
-      FMC_NORSRAMInitStructure.FMC_MemoryDataWidth = FMC_MemoryDataWidth_16b;
-      FMC_NORSRAMInitStructure.FMC_BurstAccessMode = FMC_BurstAccessMode_Disable;
-      FMC_NORSRAMInitStructure.FMC_AsynchronousWait = FMC_AsynchronousWait_Disable;
-      FMC_NORSRAMInitStructure.FMC_WaitSignalPolarity = FMC_WaitSignalPolarity_Low;
-      FMC_NORSRAMInitStructure.FMC_WrapMode = FMC_WrapMode_Disable;
-      FMC_NORSRAMInitStructure.FMC_WaitSignalActive = FMC_WaitSignalActive_BeforeWaitState;
-      FMC_NORSRAMInitStructure.FMC_WriteOperation = FMC_WriteOperation_Enable;
-      FMC_NORSRAMInitStructure.FMC_WaitSignal = FMC_WaitSignal_Disable;
-      FMC_NORSRAMInitStructure.FMC_ExtendedMode = FMC_ExtendedMode_Disable;
-      FMC_NORSRAMInitStructure.FMC_WriteBurst = FMC_WriteBurst_Disable;
-      FMC_NORSRAMInitStructure.FMC_ContinousClock = FMC_CClock_SyncOnly;
-      FMC_NORSRAMInitStructure.FMC_ReadWriteTimingStruct = &NORSRAMTimingStructure;
-      FMC_NORSRAMInitStructure.FMC_WriteTimingStruct = &NORSRAMTimingStructure;
-    */
-}
-#endif /* DATA_IN_ExtSRAM */
-
-#ifdef DATA_IN_ExtSDRAM
-/**
- * @brief  Setup the external memory controller.
- *         Called in startup_stm32f4xx.s before jump to main.
- *         This function configures the external SDRAM mounted on STM324x9I_EVAL board
- *         This SDRAM will be used as program data memory (including heap and stack).
- * @param  None
- * @retval None
- */
-void SystemInit_ExtMemCtl(void)
-{
-    register uint32_t tmpreg = 0, timeout = 0xFFFF;
-    register uint32_t index;
-
-    /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
-        clock */
-    RCC->AHB1ENR |= 0x000001FC;
-
-    /* Connect PCx pins to FMC Alternate function */
-    GPIOC->AFR[0] = 0x0000000c;
-    GPIOC->AFR[1] = 0x00007700;
-    /* Configure PCx pins in Alternate function mode */
-    GPIOC->MODER = 0x00a00002;
-    /* Configure PCx pins speed to 50 MHz */
-    GPIOC->OSPEEDR = 0x00a00002;
-    /* Configure PCx pins Output type to push-pull */
-    GPIOC->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PCx pins */
-    GPIOC->PUPDR = 0x00500000;
-
-    /* Connect PDx pins to FMC Alternate function */
-    GPIOD->AFR[0] = 0x000000CC;
-    GPIOD->AFR[1] = 0xCC000CCC;
-    /* Configure PDx pins in Alternate function mode */
-    GPIOD->MODER = 0xA02A000A;
-    /* Configure PDx pins speed to 50 MHz */
-    GPIOD->OSPEEDR = 0xA02A000A;
-    /* Configure PDx pins Output type to push-pull */
-    GPIOD->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PDx pins */
-    GPIOD->PUPDR = 0x00000000;
-
-    /* Connect PEx pins to FMC Alternate function */
-    GPIOE->AFR[0] = 0xC00000CC;
-    GPIOE->AFR[1] = 0xCCCCCCCC;
-    /* Configure PEx pins in Alternate function mode */
-    GPIOE->MODER = 0xAAAA800A;
-    /* Configure PEx pins speed to 50 MHz */
-    GPIOE->OSPEEDR = 0xAAAA800A;
-    /* Configure PEx pins Output type to push-pull */
-    GPIOE->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PEx pins */
-    GPIOE->PUPDR = 0x00000000;
-
-    /* Connect PFx pins to FMC Alternate function */
-    GPIOF->AFR[0] = 0xcccccccc;
-    GPIOF->AFR[1] = 0xcccccccc;
-    /* Configure PFx pins in Alternate function mode */
-    GPIOF->MODER = 0xAA800AAA;
-    /* Configure PFx pins speed to 50 MHz */
-    GPIOF->OSPEEDR = 0xAA800AAA;
-    /* Configure PFx pins Output type to push-pull */
-    GPIOF->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PFx pins */
-    GPIOF->PUPDR = 0x00000000;
-
-    /* Connect PGx pins to FMC Alternate function */
-    GPIOG->AFR[0] = 0xcccccccc;
-    GPIOG->AFR[1] = 0xcccccccc;
-    /* Configure PGx pins in Alternate function mode */
-    GPIOG->MODER = 0xaaaaaaaa;
-    /* Configure PGx pins speed to 50 MHz */
-    GPIOG->OSPEEDR = 0xaaaaaaaa;
-    /* Configure PGx pins Output type to push-pull */
-    GPIOG->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PGx pins */
-    GPIOG->PUPDR = 0x00000000;
-
-    /* Connect PHx pins to FMC Alternate function */
-    GPIOH->AFR[0] = 0x00C0CC00;
-    GPIOH->AFR[1] = 0xCCCCCCCC;
-    /* Configure PHx pins in Alternate function mode */
-    GPIOH->MODER = 0xAAAA08A0;
-    /* Configure PHx pins speed to 50 MHz */
-    GPIOH->OSPEEDR = 0xAAAA08A0;
-    /* Configure PHx pins Output type to push-pull */
-    GPIOH->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PHx pins */
-    GPIOH->PUPDR = 0x00000000;
-
-    /* Connect PIx pins to FMC Alternate function */
-    GPIOI->AFR[0] = 0xCCCCCCCC;
-    GPIOI->AFR[1] = 0x00000CC0;
-    /* Configure PIx pins in Alternate function mode */
-    GPIOI->MODER = 0x0028AAAA;
-    /* Configure PIx pins speed to 50 MHz */
-    GPIOI->OSPEEDR = 0x0028AAAA;
-    /* Configure PIx pins Output type to push-pull */
-    GPIOI->OTYPER = 0x00000000;
-    /* No pull-up, pull-down for PIx pins */
-    GPIOI->PUPDR = 0x00000000;
-
-    /*-- FMC Configuration ------------------------------------------------------*/
-    /* Enable the FMC interface clock */
-    RCC->AHB3ENR |= 0x00000001;
-
-    /* Configure and enable SDRAM bank1 */
-    FMC_Bank5_6->SDCR[0] = 0x000039D0;
-    FMC_Bank5_6->SDTR[0] = 0x01115351;
-
-    /* SDRAM initialization sequence */
-    /* Clock enable command */
-    FMC_Bank5_6->SDCMR = 0x00000011;
-    tmpreg             = FMC_Bank5_6->SDSR & 0x00000020;
-    while ((tmpreg != 0) & (timeout-- > 0))
-    {
-        tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
-    }
-
-    /* Delay */
-    for (index = 0; index < 1000; index++)
-        ;
-
-    /* PALL command */
-    FMC_Bank5_6->SDCMR = 0x00000012;
-    timeout            = 0xFFFF;
-    while ((tmpreg != 0) & (timeout-- > 0))
-    {
-        tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
-    }
-
-    /* Auto refresh command */
-    FMC_Bank5_6->SDCMR = 0x00000073;
-    timeout            = 0xFFFF;
-    while ((tmpreg != 0) & (timeout-- > 0))
-    {
-        tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
-    }
-
-    /* MRD register program */
-    FMC_Bank5_6->SDCMR = 0x00046014;
-    timeout            = 0xFFFF;
-    while ((tmpreg != 0) & (timeout-- > 0))
-    {
-        tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
-    }
-
-    /* Set refresh count */
-    tmpreg             = FMC_Bank5_6->SDRTR;
-    FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C << 1));
-
-    /* Disable write protection */
-    tmpreg               = FMC_Bank5_6->SDCR[0];
-    FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
-
-    /*
-      Bank1_SDRAM is configured as follow:
-
-      FMC_SDRAMTimingInitStructure.FMC_LoadToActiveDelay = 2;
-      FMC_SDRAMTimingInitStructure.FMC_ExitSelfRefreshDelay = 6;
-      FMC_SDRAMTimingInitStructure.FMC_SelfRefreshTime = 4;
-      FMC_SDRAMTimingInitStructure.FMC_RowCycleDelay = 6;
-      FMC_SDRAMTimingInitStructure.FMC_WriteRecoveryTime = 2;
-      FMC_SDRAMTimingInitStructure.FMC_RPDelay = 2;
-      FMC_SDRAMTimingInitStructure.FMC_RCDDelay = 2;
-
-      FMC_SDRAMInitStructure.FMC_Bank = SDRAM_BANK;
-      FMC_SDRAMInitStructure.FMC_ColumnBitsNumber = FMC_ColumnBits_Number_8b;
-      FMC_SDRAMInitStructure.FMC_RowBitsNumber = FMC_RowBits_Number_11b;
-      FMC_SDRAMInitStructure.FMC_SDMemoryDataWidth = FMC_SDMemory_Width_16b;
-      FMC_SDRAMInitStructure.FMC_InternalBankNumber = FMC_InternalBank_Number_4;
-      FMC_SDRAMInitStructure.FMC_CASLatency = FMC_CAS_Latency_3;
-      FMC_SDRAMInitStructure.FMC_WriteProtection = FMC_Write_Protection_Disable;
-      FMC_SDRAMInitStructure.FMC_SDClockPeriod = FMC_SDClock_Period_2;
-      FMC_SDRAMInitStructure.FMC_ReadBurst = FMC_Read_Burst_disable;
-      FMC_SDRAMInitStructure.FMC_ReadPipeDelay = FMC_ReadPipe_Delay_1;
-      FMC_SDRAMInitStructure.FMC_SDRAMTimingStruct = &FMC_SDRAMTimingInitStructure;
-    */
-}
-#endif /* DATA_IN_ExtSDRAM */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+/**
+ ******************************************************************************
+ * @file    system_stm32f4xx.c
+ * @author  MCD Application Team
+ * @version V1.5.0
+ * @date    06-March-2015
+ * @brief   CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
+ *          This file contains the system clock configuration for STM32F4xx devices.
+ *
+ * 1.  This file provides two functions and one global variable to be called from
+ *     user application:
+ *      - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
+ *                      and Divider factors, AHB/APBx prescalers and Flash settings),
+ *                      depending on the configuration made in the clock xls tool.
+ *                      This function is called at startup just after reset and
+ *                      before branch to main program. This call is made inside
+ *                      the "startup_stm32f4xx.s" file.
+ *
+ *      - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
+ *                                  by the user application to setup the SysTick
+ *                                  timer or configure other parameters.
+ *
+ *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
+ *                                 be called whenever the core clock is changed
+ *                                 during program execution.
+ *
+ * 2. After each device reset the HSI (16 MHz) is used as system clock source.
+ *    Then SystemInit() function is called, in "startup_stm32f4xx.s" file, to
+ *    configure the system clock before to branch to main program.
+ *
+ * 3. If the system clock source selected by user fails to startup, the SystemInit()
+ *    function will do nothing and HSI still used as system clock source. User can
+ *    add some code to deal with this issue inside the SetSysClock() function.
+ *
+ * 4. The default value of HSE crystal is set to 25MHz, refer to "HSE_VALUE" define
+ *    in "stm32f4xx.h" file. When HSE is used as system clock source, directly or
+ *    through PLL, and you are using different crystal you have to adapt the HSE
+ *    value to your own configuration.
+ *
+ * 5. This file configures the system clock as follows:
+ *=============================================================================
+ *=============================================================================
+ *                    Supported STM32F40xxx/41xxx devices
+ *-----------------------------------------------------------------------------
+ *        System Clock source                    | PLL (HSE)
+ *-----------------------------------------------------------------------------
+ *        SYSCLK(Hz)                             | 168000000
+ *-----------------------------------------------------------------------------
+ *        HCLK(Hz)                               | 168000000
+ *-----------------------------------------------------------------------------
+ *        AHB Prescaler                          | 1
+ *-----------------------------------------------------------------------------
+ *        APB1 Prescaler                         | 4
+ *-----------------------------------------------------------------------------
+ *        APB2 Prescaler                         | 2
+ *-----------------------------------------------------------------------------
+ *        HSE Frequency(Hz)                      | 25000000
+ *-----------------------------------------------------------------------------
+ *        PLL_M                                  | 25
+ *-----------------------------------------------------------------------------
+ *        PLL_N                                  | 336
+ *-----------------------------------------------------------------------------
+ *        PLL_P                                  | 2
+ *-----------------------------------------------------------------------------
+ *        PLL_Q                                  | 7
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_N                               | NA
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_R                               | NA
+ *-----------------------------------------------------------------------------
+ *        I2S input clock                        | NA
+ *-----------------------------------------------------------------------------
+ *        VDD(V)                                 | 3.3
+ *-----------------------------------------------------------------------------
+ *        Main regulator output voltage          | Scale1 mode
+ *-----------------------------------------------------------------------------
+ *        Flash Latency(WS)                      | 5
+ *-----------------------------------------------------------------------------
+ *        Prefetch Buffer                        | ON
+ *-----------------------------------------------------------------------------
+ *        Instruction cache                      | ON
+ *-----------------------------------------------------------------------------
+ *        Data cache                             | ON
+ *-----------------------------------------------------------------------------
+ *        Require 48MHz for USB OTG FS,          | Disabled
+ *        SDIO and RNG clock                     |
+ *-----------------------------------------------------------------------------
+ *=============================================================================
+ *=============================================================================
+ *                    Supported STM32F42xxx/43xxx devices
+ *-----------------------------------------------------------------------------
+ *        System Clock source                    | PLL (HSE)
+ *-----------------------------------------------------------------------------
+ *        SYSCLK(Hz)                             | 180000000
+ *-----------------------------------------------------------------------------
+ *        HCLK(Hz)                               | 180000000
+ *-----------------------------------------------------------------------------
+ *        AHB Prescaler                          | 1
+ *-----------------------------------------------------------------------------
+ *        APB1 Prescaler                         | 4
+ *-----------------------------------------------------------------------------
+ *        APB2 Prescaler                         | 2
+ *-----------------------------------------------------------------------------
+ *        HSE Frequency(Hz)                      | 25000000
+ *-----------------------------------------------------------------------------
+ *        PLL_M                                  | 25
+ *-----------------------------------------------------------------------------
+ *        PLL_N                                  | 360
+ *-----------------------------------------------------------------------------
+ *        PLL_P                                  | 2
+ *-----------------------------------------------------------------------------
+ *        PLL_Q                                  | 7
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_N                               | NA
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_R                               | NA
+ *-----------------------------------------------------------------------------
+ *        I2S input clock                        | NA
+ *-----------------------------------------------------------------------------
+ *        VDD(V)                                 | 3.3
+ *-----------------------------------------------------------------------------
+ *        Main regulator output voltage          | Scale1 mode
+ *-----------------------------------------------------------------------------
+ *        Flash Latency(WS)                      | 5
+ *-----------------------------------------------------------------------------
+ *        Prefetch Buffer                        | ON
+ *-----------------------------------------------------------------------------
+ *        Instruction cache                      | ON
+ *-----------------------------------------------------------------------------
+ *        Data cache                             | ON
+ *-----------------------------------------------------------------------------
+ *        Require 48MHz for USB OTG FS,          | Disabled
+ *        SDIO and RNG clock                     |
+ *-----------------------------------------------------------------------------
+ *=============================================================================
+ *=============================================================================
+ *                         Supported STM32F401xx devices
+ *-----------------------------------------------------------------------------
+ *        System Clock source                    | PLL (HSE)
+ *-----------------------------------------------------------------------------
+ *        SYSCLK(Hz)                             | 84000000
+ *-----------------------------------------------------------------------------
+ *        HCLK(Hz)                               | 84000000
+ *-----------------------------------------------------------------------------
+ *        AHB Prescaler                          | 1
+ *-----------------------------------------------------------------------------
+ *        APB1 Prescaler                         | 2
+ *-----------------------------------------------------------------------------
+ *        APB2 Prescaler                         | 1
+ *-----------------------------------------------------------------------------
+ *        HSE Frequency(Hz)                      | 25000000
+ *-----------------------------------------------------------------------------
+ *        PLL_M                                  | 25
+ *-----------------------------------------------------------------------------
+ *        PLL_N                                  | 336
+ *-----------------------------------------------------------------------------
+ *        PLL_P                                  | 4
+ *-----------------------------------------------------------------------------
+ *        PLL_Q                                  | 7
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_N                               | NA
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_R                               | NA
+ *-----------------------------------------------------------------------------
+ *        I2S input clock                        | NA
+ *-----------------------------------------------------------------------------
+ *        VDD(V)                                 | 3.3
+ *-----------------------------------------------------------------------------
+ *        Main regulator output voltage          | Scale1 mode
+ *-----------------------------------------------------------------------------
+ *        Flash Latency(WS)                      | 2
+ *-----------------------------------------------------------------------------
+ *        Prefetch Buffer                        | ON
+ *-----------------------------------------------------------------------------
+ *        Instruction cache                      | ON
+ *-----------------------------------------------------------------------------
+ *        Data cache                             | ON
+ *-----------------------------------------------------------------------------
+ *        Require 48MHz for USB OTG FS,          | Disabled
+ *        SDIO and RNG clock                     |
+ *-----------------------------------------------------------------------------
+ *=============================================================================
+ *=============================================================================
+ *                         Supported STM32F411xx devices
+ *-----------------------------------------------------------------------------
+ *        System Clock source                    | PLL (HSI)
+ *-----------------------------------------------------------------------------
+ *        SYSCLK(Hz)                             | 100000000
+ *-----------------------------------------------------------------------------
+ *        HCLK(Hz)                               | 100000000
+ *-----------------------------------------------------------------------------
+ *        AHB Prescaler                          | 1
+ *-----------------------------------------------------------------------------
+ *        APB1 Prescaler                         | 2
+ *-----------------------------------------------------------------------------
+ *        APB2 Prescaler                         | 1
+ *-----------------------------------------------------------------------------
+ *        HSI Frequency(Hz)                      | 16000000
+ *-----------------------------------------------------------------------------
+ *        PLL_M                                  | 16
+ *-----------------------------------------------------------------------------
+ *        PLL_N                                  | 400
+ *-----------------------------------------------------------------------------
+ *        PLL_P                                  | 4
+ *-----------------------------------------------------------------------------
+ *        PLL_Q                                  | 7
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_N                               | NA
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_R                               | NA
+ *-----------------------------------------------------------------------------
+ *        I2S input clock                        | NA
+ *-----------------------------------------------------------------------------
+ *        VDD(V)                                 | 3.3
+ *-----------------------------------------------------------------------------
+ *        Main regulator output voltage          | Scale1 mode
+ *-----------------------------------------------------------------------------
+ *        Flash Latency(WS)                      | 3
+ *-----------------------------------------------------------------------------
+ *        Prefetch Buffer                        | ON
+ *-----------------------------------------------------------------------------
+ *        Instruction cache                      | ON
+ *-----------------------------------------------------------------------------
+ *        Data cache                             | ON
+ *-----------------------------------------------------------------------------
+ *        Require 48MHz for USB OTG FS,          | Disabled
+ *        SDIO and RNG clock                     |
+ *-----------------------------------------------------------------------------
+ *=============================================================================
+ *=============================================================================
+ *                         Supported STM32F446xx devices
+ *-----------------------------------------------------------------------------
+ *        System Clock source                    | PLL (HSE)
+ *-----------------------------------------------------------------------------
+ *        SYSCLK(Hz)                             | 180000000
+ *-----------------------------------------------------------------------------
+ *        HCLK(Hz)                               | 180000000
+ *-----------------------------------------------------------------------------
+ *        AHB Prescaler                          | 1
+ *-----------------------------------------------------------------------------
+ *        APB1 Prescaler                         | 4
+ *-----------------------------------------------------------------------------
+ *        APB2 Prescaler                         | 2
+ *-----------------------------------------------------------------------------
+ *        HSE Frequency(Hz)                      | 8000000
+ *-----------------------------------------------------------------------------
+ *        PLL_M                                  | 8
+ *-----------------------------------------------------------------------------
+ *        PLL_N                                  | 360
+ *-----------------------------------------------------------------------------
+ *        PLL_P                                  | 2
+ *-----------------------------------------------------------------------------
+ *        PLL_Q                                  | 7
+ *-----------------------------------------------------------------------------
+ *        PLL_R                                  | NA
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_M                               | NA
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_N                               | NA
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_P                               | NA
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_Q                               | NA
+ *-----------------------------------------------------------------------------
+ *        PLLI2S_R                               | NA
+ *-----------------------------------------------------------------------------
+ *        I2S input clock                        | NA
+ *-----------------------------------------------------------------------------
+ *        VDD(V)                                 | 3.3
+ *-----------------------------------------------------------------------------
+ *        Main regulator output voltage          | Scale1 mode
+ *-----------------------------------------------------------------------------
+ *        Flash Latency(WS)                      | 5
+ *-----------------------------------------------------------------------------
+ *        Prefetch Buffer                        | ON
+ *-----------------------------------------------------------------------------
+ *        Instruction cache                      | ON
+ *-----------------------------------------------------------------------------
+ *        Data cache                             | ON
+ *-----------------------------------------------------------------------------
+ *        Require 48MHz for USB OTG FS,          | Disabled
+ *        SDIO and RNG clock                     |
+ *-----------------------------------------------------------------------------
+ *=============================================================================
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *        http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************
+ */
+
+/** @addtogroup CMSIS
+ * @{
+ */
+
+/** @addtogroup stm32f4xx_system
+ * @{
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Includes
+ * @{
+ */
+
+#include "stm32f4xx.h"
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Defines
+ * @{
+ */
+
+/************************* Miscellaneous Configuration ************************/
+/*!< Uncomment the following line if you need to use external SRAM or SDRAM mounted
+     on STM324xG_EVAL/STM324x7I_EVAL/STM324x9I_EVAL boards as data memory  */
+#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx)
+/* #define DATA_IN_ExtSRAM */
+#endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx */
+
+#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
+/* #define DATA_IN_ExtSDRAM */
+#endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx */
+
+#if defined(STM32F411xE)
+/*!< Uncomment the following line if you need to clock the STM32F411xE by HSE Bypass
+     through STLINK MCO pin of STM32F103 microcontroller. The frequency cannot be changed
+     and is fixed at 8 MHz.
+     Hardware configuration needed for Nucleo Board:
+     � SB54, SB55 OFF
+     � R35 removed
+     � SB16, SB50 ON */
+/* #define USE_HSE_BYPASS */
+
+#if defined(USE_HSE_BYPASS)
+#define HSE_BYPASS_INPUT_FREQUENCY 8000000
+#endif /* USE_HSE_BYPASS */
+#endif /* STM32F411xE */
+
+/*!< Uncomment the following line if you need to relocate your vector Table in
+     Internal SRAM. */
+/* #define VECT_TAB_SRAM */
+#define VECT_TAB_OFFSET 0x10000 /*!< Vector Table base offset field. \
+                                  This value must be a multiple of 0x200. */
+/******************************************************************************/
+
+/************************* PLL Parameters *************************************/
+#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx)
+/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
+#define PLL_M 25
+#elif defined(STM32F446xx)
+#define PLL_M 8
+#elif defined(STM32F411xE)
+
+#if defined(USE_HSE_BYPASS)
+#define PLL_M 8
+#else
+#define PLL_M 16
+#endif /* USE_HSE_BYPASS */
+
+#endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx */
+
+/* USB OTG FS, SDIO and RNG Clock =  PLL_VCO / PLLQ */
+#define PLL_Q 7
+
+#if defined(STM32F446xx)
+/* PLL division factor for I2S, SAI, SYSTEM and SPDIF: Clock =  PLL_VCO / PLLR */
+#define PLL_R 7
+#endif /* STM32F446xx */
+
+#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
+#define PLL_N 336
+/* SYSCLK = PLL_VCO / PLL_P */
+#define PLL_P 2
+#endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx || STM32F446xx */
+
+#if defined(STM32F401xx)
+#define PLL_N 336
+/* SYSCLK = PLL_VCO / PLL_P */
+#define PLL_P 4
+#endif /* STM32F401xx */
+
+#if defined(STM32F411xE)
+#define PLL_N 400
+/* SYSCLK = PLL_VCO / PLL_P */
+#define PLL_P 4
+#endif /* STM32F411xx */
+
+/******************************************************************************/
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Variables
+ * @{
+ */
+
+#if defined(STM32F40_41xxx)
+uint32_t SystemCoreClock = 168000000;
+#endif /* STM32F40_41xxx */
+
+#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
+uint32_t SystemCoreClock = 180000000;
+#endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx */
+
+#if defined(STM32F401xx)
+uint32_t SystemCoreClock = 84000000;
+#endif /* STM32F401xx */
+
+#if defined(STM32F411xE)
+uint32_t SystemCoreClock = 100000000;
+#endif /* STM32F401xx */
+
+__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
+ * @{
+ */
+
+static void SetSysClock(void);
+
+#if defined(DATA_IN_ExtSRAM) || defined(DATA_IN_ExtSDRAM)
+static void SystemInit_ExtMemCtl(void);
+#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief  Setup the microcontroller system
+ *         Initialize the Embedded Flash Interface, the PLL and update the
+ *         SystemFrequency variable.
+ * @param  None
+ * @retval None
+ */
+void SystemInit(void)
+{
+/* FPU settings ------------------------------------------------------------*/
+#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
+    SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */
+#endif
+    /* Reset the RCC clock configuration to the default reset state ------------*/
+    /* Set HSION bit */
+    RCC->CR |= (uint32_t)0x00000001;
+
+    /* Reset CFGR register */
+    RCC->CFGR = 0x00000000;
+
+    /* Reset HSEON, CSSON and PLLON bits */
+    RCC->CR &= (uint32_t)0xFEF6FFFF;
+
+    /* Reset PLLCFGR register */
+    RCC->PLLCFGR = 0x24003010;
+
+    /* Reset HSEBYP bit */
+    RCC->CR &= (uint32_t)0xFFFBFFFF;
+
+    /* Disable all interrupts */
+    RCC->CIR = 0x00000000;
+
+#if defined(DATA_IN_ExtSRAM) || defined(DATA_IN_ExtSDRAM)
+    SystemInit_ExtMemCtl();
+#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
+
+    /* Configure the System clock source, PLL Multiplier and Divider factors,
+       AHB/APBx prescalers and Flash settings ----------------------------------*/
+    SetSysClock();
+
+    /* Configure the Vector Table location add offset address ------------------*/
+#ifdef VECT_TAB_SRAM
+    SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
+#else
+    SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
+#endif
+}
+
+/**
+ * @brief  Update SystemCoreClock variable according to Clock Register Values.
+ *         The SystemCoreClock variable contains the core clock (HCLK), it can
+ *         be used by the user application to setup the SysTick timer or configure
+ *         other parameters.
+ *
+ * @note   Each time the core clock (HCLK) changes, this function must be called
+ *         to update SystemCoreClock variable value. Otherwise, any configuration
+ *         based on this variable will be incorrect.
+ *
+ * @note   - The system frequency computed by this function is not the real
+ *           frequency in the chip. It is calculated based on the predefined
+ *           constant and the selected clock source:
+ *
+ *           - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
+ *
+ *           - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
+ *
+ *           - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
+ *             or HSI_VALUE(*) multiplied/divided by the PLL factors.
+ *
+ *         (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value
+ *             16 MHz) but the real value may vary depending on the variations
+ *             in voltage and temperature.
+ *
+ *         (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value
+ *              25 MHz), user has to ensure that HSE_VALUE is same as the real
+ *              frequency of the crystal used. Otherwise, this function may
+ *              have wrong result.
+ *
+ *         - The result of this function could be not correct when using fractional
+ *           value for HSE crystal.
+ *
+ * @param  None
+ * @retval None
+ */
+void SystemCoreClockUpdate(void)
+{
+    uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
+#if defined(STM32F446xx)
+    uint32_t pllr = 2;
+#endif /* STM32F446xx */
+    /* Get SYSCLK source -------------------------------------------------------*/
+    tmp = RCC->CFGR & RCC_CFGR_SWS;
+
+    switch (tmp)
+    {
+    case 0x00: /* HSI used as system clock source */
+        SystemCoreClock = HSI_VALUE;
+        break;
+    case 0x04: /* HSE used as system clock source */
+        SystemCoreClock = HSE_VALUE;
+        break;
+    case 0x08: /* PLL P used as system clock source */
+               /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
+                 SYSCLK = PLL_VCO / PLL_P
+                 */
+        pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
+        pllm      = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
+
+#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F446xx)
+        if (pllsource != 0)
+        {
+            /* HSE used as PLL clock source */
+            pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
+        }
+        else
+        {
+            /* HSI used as PLL clock source */
+            pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
+        }
+#elif defined(STM32F411xE)
+#if defined(USE_HSE_BYPASS)
+        if (pllsource != 0)
+        {
+            /* HSE used as PLL clock source */
+            pllvco = (HSE_BYPASS_INPUT_FREQUENCY / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
+        }
+#else
+        if (pllsource == 0)
+        {
+            /* HSI used as PLL clock source */
+            pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
+        }
+#endif /* USE_HSE_BYPASS */
+#endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F446xx */
+        pllp            = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >> 16) + 1) * 2;
+        SystemCoreClock = pllvco / pllp;
+        break;
+#if defined(STM32F446xx)
+    case 0x0C: /* PLL R used as system clock source */
+               /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
+                 SYSCLK = PLL_VCO / PLL_R
+                 */
+        pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
+        pllm      = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
+        if (pllsource != 0)
+        {
+            /* HSE used as PLL clock source */
+            pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
+        }
+        else
+        {
+            /* HSI used as PLL clock source */
+            pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
+        }
+
+        pllr            = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 28) + 1) * 2;
+        SystemCoreClock = pllvco / pllr;
+        break;
+#endif /* STM32F446xx */
+    default:
+        SystemCoreClock = HSI_VALUE;
+        break;
+    }
+    /* Compute HCLK frequency --------------------------------------------------*/
+    /* Get HCLK prescaler */
+    tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
+    /* HCLK frequency */
+    SystemCoreClock >>= tmp;
+}
+
+/**
+ * @brief  Configures the System clock source, PLL Multiplier and Divider factors,
+ *         AHB/APBx prescalers and Flash settings
+ * @Note   This function should be called only once the RCC clock configuration
+ *         is reset to the default reset state (done in SystemInit() function).
+ * @param  None
+ * @retval None
+ */
+static void SetSysClock(void)
+{
+#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F446xx)
+    /******************************************************************************/
+    /*            PLL (clocked by HSE) used as System clock source                */
+    /******************************************************************************/
+    __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
+
+    /* Enable HSE */
+    RCC->CR |= ((uint32_t)RCC_CR_HSEON);
+
+    /* Wait till HSE is ready and if Time out is reached exit */
+    do
+    {
+        HSEStatus = RCC->CR & RCC_CR_HSERDY;
+        StartUpCounter++;
+    } while ((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
+
+    if ((RCC->CR & RCC_CR_HSERDY) != RESET)
+    {
+        HSEStatus = (uint32_t)0x01;
+    }
+    else
+    {
+        HSEStatus = (uint32_t)0x00;
+    }
+
+    if (HSEStatus == (uint32_t)0x01)
+    {
+        /* Select regulator voltage output Scale 1 mode */
+        RCC->APB1ENR |= RCC_APB1ENR_PWREN;
+        PWR->CR |= PWR_CR_VOS;
+
+        /* HCLK = SYSCLK / 1*/
+        RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
+
+#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
+        /* PCLK2 = HCLK / 2*/
+        RCC->CFGR |= RCC_CFGR_PPRE2_DIV2;
+
+        /* PCLK1 = HCLK / 4*/
+        RCC->CFGR |= RCC_CFGR_PPRE1_DIV4;
+#endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx || STM32F446xx */
+
+#if defined(STM32F401xx)
+        /* PCLK2 = HCLK / 2*/
+        RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
+
+        /* PCLK1 = HCLK / 4*/
+        RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
+#endif /* STM32F401xx */
+
+#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx)
+        /* Configure the main PLL */
+        RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) |
+                       (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);
+#endif /* STM32F40_41xxx || STM32F427_437x || STM32F429_439xx || STM32F401xx */
+
+#if defined(STM32F446xx)
+        /* Configure the main PLL */
+        RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) |
+                       (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24) | (PLL_R << 28);
+#endif /* STM32F446xx */
+
+        /* Enable the main PLL */
+        RCC->CR |= RCC_CR_PLLON;
+
+        /* Wait till the main PLL is ready */
+        while ((RCC->CR & RCC_CR_PLLRDY) == 0)
+        {
+        }
+
+#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
+        /* Enable the Over-drive to extend the clock frequency to 180 Mhz */
+        PWR->CR |= PWR_CR_ODEN;
+        while ((PWR->CSR & PWR_CSR_ODRDY) == 0)
+        {
+        }
+        PWR->CR |= PWR_CR_ODSWEN;
+        while ((PWR->CSR & PWR_CSR_ODSWRDY) == 0)
+        {
+        }
+        /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
+        FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS;
+#endif /* STM32F427_437x || STM32F429_439xx || STM32F446xx */
+
+#if defined(STM32F40_41xxx)
+        /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
+        FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS;
+#endif /* STM32F40_41xxx  */
+
+#if defined(STM32F401xx)
+        /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
+        FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_2WS;
+#endif /* STM32F401xx */
+
+        /* Select the main PLL as system clock source */
+        RCC->CFGR &= (uint32_t)((uint32_t) ~(RCC_CFGR_SW));
+        RCC->CFGR |= RCC_CFGR_SW_PLL;
+
+        /* Wait till the main PLL is used as system clock source */
+        while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL)
+        {
+        };
+    }
+    else
+    { /* If HSE fails to start-up, the application will have wrong clock
+           configuration. User can add here some code to deal with this error */
+    }
+#elif defined(STM32F411xE)
+#if defined(USE_HSE_BYPASS)
+    /******************************************************************************/
+    /*            PLL (clocked by HSE) used as System clock source                */
+    /******************************************************************************/
+    __IO uint32_t StartUpCounter = 0, HSEStatus = 0;
+
+    /* Enable HSE and HSE BYPASS */
+    RCC->CR |= ((uint32_t)RCC_CR_HSEON | RCC_CR_HSEBYP);
+
+    /* Wait till HSE is ready and if Time out is reached exit */
+    do
+    {
+        HSEStatus = RCC->CR & RCC_CR_HSERDY;
+        StartUpCounter++;
+    } while ((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
+
+    if ((RCC->CR & RCC_CR_HSERDY) != RESET)
+    {
+        HSEStatus = (uint32_t)0x01;
+    }
+    else
+    {
+        HSEStatus = (uint32_t)0x00;
+    }
+
+    if (HSEStatus == (uint32_t)0x01)
+    {
+        /* Select regulator voltage output Scale 1 mode */
+        RCC->APB1ENR |= RCC_APB1ENR_PWREN;
+        PWR->CR |= PWR_CR_VOS;
+
+        /* HCLK = SYSCLK / 1*/
+        RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
+
+        /* PCLK2 = HCLK / 2*/
+        RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
+
+        /* PCLK1 = HCLK / 4*/
+        RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
+
+        /* Configure the main PLL */
+        RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) |
+                       (RCC_PLLCFGR_PLLSRC_HSE) | (PLL_Q << 24);
+
+        /* Enable the main PLL */
+        RCC->CR |= RCC_CR_PLLON;
+
+        /* Wait till the main PLL is ready */
+        while ((RCC->CR & RCC_CR_PLLRDY) == 0)
+        {
+        }
+
+        /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
+        FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_2WS;
+
+        /* Select the main PLL as system clock source */
+        RCC->CFGR &= (uint32_t)((uint32_t) ~(RCC_CFGR_SW));
+        RCC->CFGR |= RCC_CFGR_SW_PLL;
+
+        /* Wait till the main PLL is used as system clock source */
+        while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL)
+            ;
+        {
+        }
+    }
+    else
+    { /* If HSE fails to start-up, the application will have wrong clock
+           configuration. User can add here some code to deal with this error */
+    }
+#else  /* HSI will be used as PLL clock source */
+    /* Select regulator voltage output Scale 1 mode */
+    RCC->APB1ENR |= RCC_APB1ENR_PWREN;
+    PWR->CR |= PWR_CR_VOS;
+
+    /* HCLK = SYSCLK / 1*/
+    RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
+
+    /* PCLK2 = HCLK / 2*/
+    RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
+
+    /* PCLK1 = HCLK / 4*/
+    RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
+
+    /* Configure the main PLL */
+    RCC->PLLCFGR = PLL_M | (PLL_N << 6) | (((PLL_P >> 1) - 1) << 16) | (PLL_Q << 24);
+
+    /* Enable the main PLL */
+    RCC->CR |= RCC_CR_PLLON;
+
+    /* Wait till the main PLL is ready */
+    while ((RCC->CR & RCC_CR_PLLRDY) == 0)
+    {
+    }
+
+    /* Configure Flash prefetch, Instruction cache, Data cache and wait state */
+    FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_2WS;
+
+    /* Select the main PLL as system clock source */
+    RCC->CFGR &= (uint32_t)((uint32_t) ~(RCC_CFGR_SW));
+    RCC->CFGR |= RCC_CFGR_SW_PLL;
+
+    /* Wait till the main PLL is used as system clock source */
+    while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL)
+        ;
+    {
+    }
+#endif /* USE_HSE_BYPASS */
+#endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx */
+}
+
+/**
+ * @brief  Setup the external memory controller. Called in startup_stm32f4xx.s
+ *          before jump to __main
+ * @param  None
+ * @retval None
+ */
+#ifdef DATA_IN_ExtSRAM
+/**
+ * @brief  Setup the external memory controller.
+ *         Called in startup_stm32f4xx.s before jump to main.
+ *         This function configures the external SRAM mounted on STM324xG_EVAL/STM324x7I boards
+ *         This SRAM will be used as program data memory (including heap and stack).
+ * @param  None
+ * @retval None
+ */
+void SystemInit_ExtMemCtl(void)
+{
+    /*-- GPIOs Configuration -----------------------------------------------------*/
+    /*
+     +-------------------+--------------------+------------------+--------------+
+     +                       SRAM pins assignment                               +
+     +-------------------+--------------------+------------------+--------------+
+     | PD0  <-> FMC_D2  | PE0  <-> FMC_NBL0 | PF0  <-> FMC_A0 | PG0 <-> FMC_A10 |
+     | PD1  <-> FMC_D3  | PE1  <-> FMC_NBL1 | PF1  <-> FMC_A1 | PG1 <-> FMC_A11 |
+     | PD4  <-> FMC_NOE | PE3  <-> FMC_A19  | PF2  <-> FMC_A2 | PG2 <-> FMC_A12 |
+     | PD5  <-> FMC_NWE | PE4  <-> FMC_A20  | PF3  <-> FMC_A3 | PG3 <-> FMC_A13 |
+     | PD8  <-> FMC_D13 | PE7  <-> FMC_D4   | PF4  <-> FMC_A4 | PG4 <-> FMC_A14 |
+     | PD9  <-> FMC_D14 | PE8  <-> FMC_D5   | PF5  <-> FMC_A5 | PG5 <-> FMC_A15 |
+     | PD10 <-> FMC_D15 | PE9  <-> FMC_D6   | PF12 <-> FMC_A6 | PG9 <-> FMC_NE2 |
+     | PD11 <-> FMC_A16 | PE10 <-> FMC_D7   | PF13 <-> FMC_A7 |-----------------+
+     | PD12 <-> FMC_A17 | PE11 <-> FMC_D8   | PF14 <-> FMC_A8 |
+     | PD13 <-> FMC_A18 | PE12 <-> FMC_D9   | PF15 <-> FMC_A9 |
+     | PD14 <-> FMC_D0  | PE13 <-> FMC_D10  |-----------------+
+     | PD15 <-> FMC_D1  | PE14 <-> FMC_D11  |
+     |                  | PE15 <-> FMC_D12  |
+     +------------------+------------------+
+    */
+    /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
+    RCC->AHB1ENR |= 0x00000078;
+
+    /* Connect PDx pins to FMC Alternate function */
+    GPIOD->AFR[0] = 0x00cc00cc;
+    GPIOD->AFR[1] = 0xcccccccc;
+    /* Configure PDx pins in Alternate function mode */
+    GPIOD->MODER = 0xaaaa0a0a;
+    /* Configure PDx pins speed to 100 MHz */
+    GPIOD->OSPEEDR = 0xffff0f0f;
+    /* Configure PDx pins Output type to push-pull */
+    GPIOD->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PDx pins */
+    GPIOD->PUPDR = 0x00000000;
+
+    /* Connect PEx pins to FMC Alternate function */
+    GPIOE->AFR[0] = 0xcccccccc;
+    GPIOE->AFR[1] = 0xcccccccc;
+    /* Configure PEx pins in Alternate function mode */
+    GPIOE->MODER = 0xaaaaaaaa;
+    /* Configure PEx pins speed to 100 MHz */
+    GPIOE->OSPEEDR = 0xffffffff;
+    /* Configure PEx pins Output type to push-pull */
+    GPIOE->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PEx pins */
+    GPIOE->PUPDR = 0x00000000;
+
+    /* Connect PFx pins to FMC Alternate function */
+    GPIOF->AFR[0] = 0x00cccccc;
+    GPIOF->AFR[1] = 0xcccc0000;
+    /* Configure PFx pins in Alternate function mode */
+    GPIOF->MODER = 0xaa000aaa;
+    /* Configure PFx pins speed to 100 MHz */
+    GPIOF->OSPEEDR = 0xff000fff;
+    /* Configure PFx pins Output type to push-pull */
+    GPIOF->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PFx pins */
+    GPIOF->PUPDR = 0x00000000;
+
+    /* Connect PGx pins to FMC Alternate function */
+    GPIOG->AFR[0] = 0x00cccccc;
+    GPIOG->AFR[1] = 0x000000c0;
+    /* Configure PGx pins in Alternate function mode */
+    GPIOG->MODER = 0x00080aaa;
+    /* Configure PGx pins speed to 100 MHz */
+    GPIOG->OSPEEDR = 0x000c0fff;
+    /* Configure PGx pins Output type to push-pull */
+    GPIOG->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PGx pins */
+    GPIOG->PUPDR = 0x00000000;
+
+    /*-- FMC Configuration ------------------------------------------------------*/
+    /* Enable the FMC/FSMC interface clock */
+    RCC->AHB3ENR |= 0x00000001;
+
+#if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx)
+    /* Configure and enable Bank1_SRAM2 */
+    FMC_Bank1->BTCR[2]  = 0x00001011;
+    FMC_Bank1->BTCR[3]  = 0x00000201;
+    FMC_Bank1E->BWTR[2] = 0x0fffffff;
+#endif /* STM32F427_437xx || STM32F429_439xx */
+
+#if defined(STM32F40_41xxx)
+    /* Configure and enable Bank1_SRAM2 */
+    FSMC_Bank1->BTCR[2]  = 0x00001011;
+    FSMC_Bank1->BTCR[3]  = 0x00000201;
+    FSMC_Bank1E->BWTR[2] = 0x0fffffff;
+#endif /* STM32F40_41xxx */
+
+    /*
+      Bank1_SRAM2 is configured as follow:
+      In case of FSMC configuration
+      NORSRAMTimingStructure.FSMC_AddressSetupTime = 1;
+      NORSRAMTimingStructure.FSMC_AddressHoldTime = 0;
+      NORSRAMTimingStructure.FSMC_DataSetupTime = 2;
+      NORSRAMTimingStructure.FSMC_BusTurnAroundDuration = 0;
+      NORSRAMTimingStructure.FSMC_CLKDivision = 0;
+      NORSRAMTimingStructure.FSMC_DataLatency = 0;
+      NORSRAMTimingStructure.FSMC_AccessMode = FMC_AccessMode_A;
+
+      FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
+      FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
+      FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
+      FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
+      FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
+      FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
+      FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
+      FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
+      FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
+      FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
+      FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
+      FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
+      FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
+      FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &NORSRAMTimingStructure;
+      FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &NORSRAMTimingStructure;
+
+      In case of FMC configuration
+      NORSRAMTimingStructure.FMC_AddressSetupTime = 1;
+      NORSRAMTimingStructure.FMC_AddressHoldTime = 0;
+      NORSRAMTimingStructure.FMC_DataSetupTime = 2;
+      NORSRAMTimingStructure.FMC_BusTurnAroundDuration = 0;
+      NORSRAMTimingStructure.FMC_CLKDivision = 0;
+      NORSRAMTimingStructure.FMC_DataLatency = 0;
+      NORSRAMTimingStructure.FMC_AccessMode = FMC_AccessMode_A;
+
+      FMC_NORSRAMInitStructure.FMC_Bank = FMC_Bank1_NORSRAM2;
+      FMC_NORSRAMInitStructure.FMC_DataAddressMux = FMC_DataAddressMux_Disable;
+      FMC_NORSRAMInitStructure.FMC_MemoryType = FMC_MemoryType_SRAM;
+      FMC_NORSRAMInitStructure.FMC_MemoryDataWidth = FMC_MemoryDataWidth_16b;
+      FMC_NORSRAMInitStructure.FMC_BurstAccessMode = FMC_BurstAccessMode_Disable;
+      FMC_NORSRAMInitStructure.FMC_AsynchronousWait = FMC_AsynchronousWait_Disable;
+      FMC_NORSRAMInitStructure.FMC_WaitSignalPolarity = FMC_WaitSignalPolarity_Low;
+      FMC_NORSRAMInitStructure.FMC_WrapMode = FMC_WrapMode_Disable;
+      FMC_NORSRAMInitStructure.FMC_WaitSignalActive = FMC_WaitSignalActive_BeforeWaitState;
+      FMC_NORSRAMInitStructure.FMC_WriteOperation = FMC_WriteOperation_Enable;
+      FMC_NORSRAMInitStructure.FMC_WaitSignal = FMC_WaitSignal_Disable;
+      FMC_NORSRAMInitStructure.FMC_ExtendedMode = FMC_ExtendedMode_Disable;
+      FMC_NORSRAMInitStructure.FMC_WriteBurst = FMC_WriteBurst_Disable;
+      FMC_NORSRAMInitStructure.FMC_ContinousClock = FMC_CClock_SyncOnly;
+      FMC_NORSRAMInitStructure.FMC_ReadWriteTimingStruct = &NORSRAMTimingStructure;
+      FMC_NORSRAMInitStructure.FMC_WriteTimingStruct = &NORSRAMTimingStructure;
+    */
+}
+#endif /* DATA_IN_ExtSRAM */
+
+#ifdef DATA_IN_ExtSDRAM
+/**
+ * @brief  Setup the external memory controller.
+ *         Called in startup_stm32f4xx.s before jump to main.
+ *         This function configures the external SDRAM mounted on STM324x9I_EVAL board
+ *         This SDRAM will be used as program data memory (including heap and stack).
+ * @param  None
+ * @retval None
+ */
+void SystemInit_ExtMemCtl(void)
+{
+    register uint32_t tmpreg = 0, timeout = 0xFFFF;
+    register uint32_t index;
+
+    /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
+        clock */
+    RCC->AHB1ENR |= 0x000001FC;
+
+    /* Connect PCx pins to FMC Alternate function */
+    GPIOC->AFR[0] = 0x0000000c;
+    GPIOC->AFR[1] = 0x00007700;
+    /* Configure PCx pins in Alternate function mode */
+    GPIOC->MODER = 0x00a00002;
+    /* Configure PCx pins speed to 50 MHz */
+    GPIOC->OSPEEDR = 0x00a00002;
+    /* Configure PCx pins Output type to push-pull */
+    GPIOC->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PCx pins */
+    GPIOC->PUPDR = 0x00500000;
+
+    /* Connect PDx pins to FMC Alternate function */
+    GPIOD->AFR[0] = 0x000000CC;
+    GPIOD->AFR[1] = 0xCC000CCC;
+    /* Configure PDx pins in Alternate function mode */
+    GPIOD->MODER = 0xA02A000A;
+    /* Configure PDx pins speed to 50 MHz */
+    GPIOD->OSPEEDR = 0xA02A000A;
+    /* Configure PDx pins Output type to push-pull */
+    GPIOD->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PDx pins */
+    GPIOD->PUPDR = 0x00000000;
+
+    /* Connect PEx pins to FMC Alternate function */
+    GPIOE->AFR[0] = 0xC00000CC;
+    GPIOE->AFR[1] = 0xCCCCCCCC;
+    /* Configure PEx pins in Alternate function mode */
+    GPIOE->MODER = 0xAAAA800A;
+    /* Configure PEx pins speed to 50 MHz */
+    GPIOE->OSPEEDR = 0xAAAA800A;
+    /* Configure PEx pins Output type to push-pull */
+    GPIOE->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PEx pins */
+    GPIOE->PUPDR = 0x00000000;
+
+    /* Connect PFx pins to FMC Alternate function */
+    GPIOF->AFR[0] = 0xcccccccc;
+    GPIOF->AFR[1] = 0xcccccccc;
+    /* Configure PFx pins in Alternate function mode */
+    GPIOF->MODER = 0xAA800AAA;
+    /* Configure PFx pins speed to 50 MHz */
+    GPIOF->OSPEEDR = 0xAA800AAA;
+    /* Configure PFx pins Output type to push-pull */
+    GPIOF->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PFx pins */
+    GPIOF->PUPDR = 0x00000000;
+
+    /* Connect PGx pins to FMC Alternate function */
+    GPIOG->AFR[0] = 0xcccccccc;
+    GPIOG->AFR[1] = 0xcccccccc;
+    /* Configure PGx pins in Alternate function mode */
+    GPIOG->MODER = 0xaaaaaaaa;
+    /* Configure PGx pins speed to 50 MHz */
+    GPIOG->OSPEEDR = 0xaaaaaaaa;
+    /* Configure PGx pins Output type to push-pull */
+    GPIOG->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PGx pins */
+    GPIOG->PUPDR = 0x00000000;
+
+    /* Connect PHx pins to FMC Alternate function */
+    GPIOH->AFR[0] = 0x00C0CC00;
+    GPIOH->AFR[1] = 0xCCCCCCCC;
+    /* Configure PHx pins in Alternate function mode */
+    GPIOH->MODER = 0xAAAA08A0;
+    /* Configure PHx pins speed to 50 MHz */
+    GPIOH->OSPEEDR = 0xAAAA08A0;
+    /* Configure PHx pins Output type to push-pull */
+    GPIOH->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PHx pins */
+    GPIOH->PUPDR = 0x00000000;
+
+    /* Connect PIx pins to FMC Alternate function */
+    GPIOI->AFR[0] = 0xCCCCCCCC;
+    GPIOI->AFR[1] = 0x00000CC0;
+    /* Configure PIx pins in Alternate function mode */
+    GPIOI->MODER = 0x0028AAAA;
+    /* Configure PIx pins speed to 50 MHz */
+    GPIOI->OSPEEDR = 0x0028AAAA;
+    /* Configure PIx pins Output type to push-pull */
+    GPIOI->OTYPER = 0x00000000;
+    /* No pull-up, pull-down for PIx pins */
+    GPIOI->PUPDR = 0x00000000;
+
+    /*-- FMC Configuration ------------------------------------------------------*/
+    /* Enable the FMC interface clock */
+    RCC->AHB3ENR |= 0x00000001;
+
+    /* Configure and enable SDRAM bank1 */
+    FMC_Bank5_6->SDCR[0] = 0x000039D0;
+    FMC_Bank5_6->SDTR[0] = 0x01115351;
+
+    /* SDRAM initialization sequence */
+    /* Clock enable command */
+    FMC_Bank5_6->SDCMR = 0x00000011;
+    tmpreg             = FMC_Bank5_6->SDSR & 0x00000020;
+    while ((tmpreg != 0) & (timeout-- > 0))
+    {
+        tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+    }
+
+    /* Delay */
+    for (index = 0; index < 1000; index++)
+        ;
+
+    /* PALL command */
+    FMC_Bank5_6->SDCMR = 0x00000012;
+    timeout            = 0xFFFF;
+    while ((tmpreg != 0) & (timeout-- > 0))
+    {
+        tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+    }
+
+    /* Auto refresh command */
+    FMC_Bank5_6->SDCMR = 0x00000073;
+    timeout            = 0xFFFF;
+    while ((tmpreg != 0) & (timeout-- > 0))
+    {
+        tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+    }
+
+    /* MRD register program */
+    FMC_Bank5_6->SDCMR = 0x00046014;
+    timeout            = 0xFFFF;
+    while ((tmpreg != 0) & (timeout-- > 0))
+    {
+        tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+    }
+
+    /* Set refresh count */
+    tmpreg             = FMC_Bank5_6->SDRTR;
+    FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C << 1));
+
+    /* Disable write protection */
+    tmpreg               = FMC_Bank5_6->SDCR[0];
+    FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
+
+    /*
+      Bank1_SDRAM is configured as follow:
+
+      FMC_SDRAMTimingInitStructure.FMC_LoadToActiveDelay = 2;
+      FMC_SDRAMTimingInitStructure.FMC_ExitSelfRefreshDelay = 6;
+      FMC_SDRAMTimingInitStructure.FMC_SelfRefreshTime = 4;
+      FMC_SDRAMTimingInitStructure.FMC_RowCycleDelay = 6;
+      FMC_SDRAMTimingInitStructure.FMC_WriteRecoveryTime = 2;
+      FMC_SDRAMTimingInitStructure.FMC_RPDelay = 2;
+      FMC_SDRAMTimingInitStructure.FMC_RCDDelay = 2;
+
+      FMC_SDRAMInitStructure.FMC_Bank = SDRAM_BANK;
+      FMC_SDRAMInitStructure.FMC_ColumnBitsNumber = FMC_ColumnBits_Number_8b;
+      FMC_SDRAMInitStructure.FMC_RowBitsNumber = FMC_RowBits_Number_11b;
+      FMC_SDRAMInitStructure.FMC_SDMemoryDataWidth = FMC_SDMemory_Width_16b;
+      FMC_SDRAMInitStructure.FMC_InternalBankNumber = FMC_InternalBank_Number_4;
+      FMC_SDRAMInitStructure.FMC_CASLatency = FMC_CAS_Latency_3;
+      FMC_SDRAMInitStructure.FMC_WriteProtection = FMC_Write_Protection_Disable;
+      FMC_SDRAMInitStructure.FMC_SDClockPeriod = FMC_SDClock_Period_2;
+      FMC_SDRAMInitStructure.FMC_ReadBurst = FMC_Read_Burst_disable;
+      FMC_SDRAMInitStructure.FMC_ReadPipeDelay = FMC_ReadPipe_Delay_1;
+      FMC_SDRAMInitStructure.FMC_SDRAMTimingStruct = &FMC_SDRAMTimingInitStructure;
+    */
+}
+#endif /* DATA_IN_ExtSDRAM */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 118 - 118
MiddleWare/FATFS/doc/00index_e.html → Third_Party/FATFS/doc/00index_e.html

@@ -1,118 +1,118 @@
-<!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">
-<meta http-equiv="cache-control" content="no-cache">
-<meta name="description" content="Open source FAT file system module for embedded projects">
-<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>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 small microcontrollers with limited resource, such as AVR, 8051, PIC, ARM, Z80, 68k and etc. Also Petit FatFs module for tiny microcontrollers is 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 an open 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/forward.html">f_forward</a> - Forward file data to the stream</li>
- <li><a href="en/stat.html">f_stat</a> - Check existance of a file or sub-directory</li>
- <li><a href="en/opendir.html">f_opendir</a> - Open a directory</li>
- <li><a href="en/closedir.html">f_closedir</a> - Close an open directory</li>
- <li><a href="en/readdir.html">f_readdir</a> - Read a directory item</li>
- <li><a href="en/mkdir.html">f_mkdir</a> - Create a sub-directory</li>
- <li><a href="en/unlink.html">f_unlink</a> - Remove a file or sub-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 sub-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/getfree.html">f_getfree</a> - Get free space on the volume</li>
- <li><a href="en/getlabel.html">f_getlabel</a> - Get volume label</li>
- <li><a href="en/setlabel.html">f_setlabel</a> - Set volume label</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 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>Device Control Interface</h3>
-<p>Since the FatFs module is a file system driver, it is completely separated from physical devices, such as memory card, harddisk and any type of storage devices. The low level device control module is not a part of FatFs module. FatFs accesses the storage device via a simple interface described below. These functions are provided by implementer. Sample implementations for some platforms are also available in the downloads.</p>
-<ul>
- <li><a href="en/dstat.html">disk_status</a> - Get device status</li>
- <li><a href="en/dinit.html">disk_initialize</a> - Initialize device</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></li>
- <li>Latest Information: <a href="http://elm-chan.org/fsw/ff/00index_e.html">http://elm-chan.org/fsw/ff/00index_e.html</a>↗</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/fat.html">The basics of FAT file system [ja]</a>↗</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>
+<!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">
+<meta http-equiv="cache-control" content="no-cache">
+<meta name="description" content="Open source FAT file system module for embedded projects">
+<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>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 small microcontrollers with limited resource, such as AVR, 8051, PIC, ARM, Z80, 68k and etc. Also Petit FatFs module for tiny microcontrollers is 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 an open 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/forward.html">f_forward</a> - Forward file data to the stream</li>
+ <li><a href="en/stat.html">f_stat</a> - Check existance of a file or sub-directory</li>
+ <li><a href="en/opendir.html">f_opendir</a> - Open a directory</li>
+ <li><a href="en/closedir.html">f_closedir</a> - Close an open directory</li>
+ <li><a href="en/readdir.html">f_readdir</a> - Read a directory item</li>
+ <li><a href="en/mkdir.html">f_mkdir</a> - Create a sub-directory</li>
+ <li><a href="en/unlink.html">f_unlink</a> - Remove a file or sub-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 sub-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/getfree.html">f_getfree</a> - Get free space on the volume</li>
+ <li><a href="en/getlabel.html">f_getlabel</a> - Get volume label</li>
+ <li><a href="en/setlabel.html">f_setlabel</a> - Set volume label</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 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>Device Control Interface</h3>
+<p>Since the FatFs module is a file system driver, it is completely separated from physical devices, such as memory card, harddisk and any type of storage devices. The low level device control module is not a part of FatFs module. FatFs accesses the storage device via a simple interface described below. These functions are provided by implementer. Sample implementations for some platforms are also available in the downloads.</p>
+<ul>
+ <li><a href="en/dstat.html">disk_status</a> - Get device status</li>
+ <li><a href="en/dinit.html">disk_initialize</a> - Initialize device</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></li>
+ <li>Latest Information: <a href="http://elm-chan.org/fsw/ff/00index_e.html">http://elm-chan.org/fsw/ff/00index_e.html</a>↗</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/fat.html">The basics of FAT file system [ja]</a>↗</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>

+ 118 - 118
MiddleWare/FATFS/doc/00index_j.html → Third_Party/FATFS/doc/00index_j.html

@@ -1,118 +1,118 @@
-<!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">
-<meta http-equiv="cache-control" content="no-cache">
-<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>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/forward.html">f_forward</a> - ファイル・データをストリーム関数に転送</li>
- <li><a href="ja/stat.html">f_stat</a> - ファイル/サブ・ディレクトリの存在チェックと情報の取得</li>
- <li><a href="ja/opendir.html">f_opendir</a> - ディレクトリのオープン</li>
- <li><a href="ja/closedir.html">f_closedir</a> - ディレクトリのクローズ</li>
- <li><a href="ja/readdir.html">f_readdir</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/getfree.html">f_getfree</a> - ボリューム空き領域の取得</li>
- <li><a href="ja/getlabel.html">f_getlabel</a> - ボリューム・ラベルの取得</li>
- <li><a href="ja/setlabel.html">f_setlabel</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モジュールは、単なるファイル・システム・レイヤなので、ストレージ・デバイス制御レイヤは含まれません。使用するストレージに対応した制御関数は、ユーザによって提供される必要があります。FatFsモジュールは、下位レイヤに対し少なくとも次のインターフェースを要求します。OS関連機能を有効にしたときは、これに加えてプロセス/メモリ関連関数も必要になります。サンプル・プロジェクトに下位レイヤの実装例を示します。</p>
-<ul>
- <li><a href="ja/dstat.html">disk_status</a> - デバイスの状態取得</li>
- <li><a href="ja/dinit.html">disk_initialize</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></li>
- <li>最新版: <a href="http://elm-chan.org/fsw/ff/00index_j.html">http://elm-chan.org/fsw/ff/00index_j.html</a>↗</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>↗ (The reference document on FAT file system)</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>
+<!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">
+<meta http-equiv="cache-control" content="no-cache">
+<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>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/forward.html">f_forward</a> - ファイル・データをストリーム関数に転送</li>
+ <li><a href="ja/stat.html">f_stat</a> - ファイル/サブ・ディレクトリの存在チェックと情報の取得</li>
+ <li><a href="ja/opendir.html">f_opendir</a> - ディレクトリのオープン</li>
+ <li><a href="ja/closedir.html">f_closedir</a> - ディレクトリのクローズ</li>
+ <li><a href="ja/readdir.html">f_readdir</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/getfree.html">f_getfree</a> - ボリューム空き領域の取得</li>
+ <li><a href="ja/getlabel.html">f_getlabel</a> - ボリューム・ラベルの取得</li>
+ <li><a href="ja/setlabel.html">f_setlabel</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モジュールは、単なるファイル・システム・レイヤなので、ストレージ・デバイス制御レイヤは含まれません。使用するストレージに対応した制御関数は、ユーザによって提供される必要があります。FatFsモジュールは、下位レイヤに対し少なくとも次のインターフェースを要求します。OS関連機能を有効にしたときは、これに加えてプロセス/メモリ関連関数も必要になります。サンプル・プロジェクトに下位レイヤの実装例を示します。</p>
+<ul>
+ <li><a href="ja/dstat.html">disk_status</a> - デバイスの状態取得</li>
+ <li><a href="ja/dinit.html">disk_initialize</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></li>
+ <li>最新版: <a href="http://elm-chan.org/fsw/ff/00index_j.html">http://elm-chan.org/fsw/ff/00index_j.html</a>↗</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>↗ (The reference document on FAT file system)</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>

+ 65 - 65
MiddleWare/FATFS/doc/css_e.css → Third_Party/FATFS/doc/css_e.css

@@ -1,65 +1,65 @@
-* {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; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;}
-abbr {border-width: 1px;}
-
-p {margin: 0 0 0.3em 1em;}
-i {margin: 0 0.3em 0 0;}
-b {margin: 0 0.1em;}
-em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
-strong {}
-pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-size: 85%; font-family: "Consolas", "Courier New", monospace; background-color: white;}
-pre span.c {color: green;}
-pre span.k {color: blue;}
-pre span.arg {font-style: italic;}
-tt {margin: 0 0.2em; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
-tt.arg {font-style: italic;}
-ol {margin: 0.5em 2.5em;}
-ul {margin: 0.5em 2em;}
-dl {margin: 0.5em 1em;}
-dd {margin: 0 2em;}
-dt {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
-dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; }
-dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
-hr {border-width: 1px; margin: 1em;}
-div.abst {font-family: sans-serif;}
-div.para {clear: both; font-family: serif;}
-div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
-.equ {text-indent: 0; margin: 1em 2em 1em;}
-.indent {margin-left: 2em;}
-.rset {float: right; margin: 0.3em 0 0.5em 0.5em;}
-.lset {float: left; margin: 0.3em 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}
-.ral {text-align: right; }
-.lal {text-align: left; }
-.cal {text-align: center; }
-
-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: 2em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.5em 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-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
-table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", 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;}
+* {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; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;}
+abbr {border-width: 1px;}
+
+p {margin: 0 0 0.3em 1em;}
+i {margin: 0 0.3em 0 0;}
+b {margin: 0 0.1em;}
+em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
+strong {}
+pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-size: 85%; font-family: "Consolas", "Courier New", monospace; background-color: white;}
+pre span.c {color: green;}
+pre span.k {color: blue;}
+pre span.arg {font-style: italic;}
+tt {margin: 0 0.2em; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
+tt.arg {font-style: italic;}
+ol {margin: 0.5em 2.5em;}
+ul {margin: 0.5em 2em;}
+dl {margin: 0.5em 1em;}
+dd {margin: 0 2em;}
+dt {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
+dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; }
+dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
+hr {border-width: 1px; margin: 1em;}
+div.abst {font-family: sans-serif;}
+div.para {clear: both; font-family: serif;}
+div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
+.equ {text-indent: 0; margin: 1em 2em 1em;}
+.indent {margin-left: 2em;}
+.rset {float: right; margin: 0.3em 0 0.5em 0.5em;}
+.lset {float: left; margin: 0.3em 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}
+.ral {text-align: right; }
+.lal {text-align: left; }
+.cal {text-align: center; }
+
+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: 2em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.5em 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-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
+table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", 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;}

+ 68 - 68
MiddleWare/FATFS/doc/css_j.css → Third_Party/FATFS/doc/css_j.css

@@ -1,68 +1,68 @@
-@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; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;}
-abbr {border-width: 1px;}
-
-p {text-indent: 1em; margin: 0 0 0.3em 0.5em;}
-i {margin: 0 0.3em 0 0;}
-b {margin: 0 0.1em;}
-em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
-strong {}
-pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace; background-color: white;}
-pre span.c {color: green;}
-pre span.k {color: blue;}
-pre span.arg {font-style: italic;}
-tt {margin: 0 0.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace;}
-tt.arg {font-style: italic;}
-ol {margin: 0.5em 2.5em;}
-ul {margin: 0.5em 2em;}
-dl {margin: 0.5em 1em;}
-dd {margin: 0em   2em;}
-dt {font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", 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-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace; letter-spacing: 0; }
-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-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
-.equ {text-indent: 0; margin: 1em 2em 1em;}
-.indent {margin-left: 2em;}
-.rset {float: right; margin: 0.3em 0 0.5em 0.5em;}
-.lset {float: left; margin: 0.3em 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}
-.ral {text-align: right; }
-.lal {text-align: left; }
-.cal {text-align: center; }
-
-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: 2em; font-family: "MS Pゴシック",sans-serif; background-color: #d8d8FF; padding: 0.5em 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-size: 0.85em; font-family: "Consolas", "Courier New", monospace; white-space: nowrap;}
-table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", 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;}
+@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; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;}
+abbr {border-width: 1px;}
+
+p {text-indent: 1em; margin: 0 0 0.3em 0.5em;}
+i {margin: 0 0.3em 0 0;}
+b {margin: 0 0.1em;}
+em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
+strong {}
+pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace; background-color: white;}
+pre span.c {color: green;}
+pre span.k {color: blue;}
+pre span.arg {font-style: italic;}
+tt {margin: 0 0.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace;}
+tt.arg {font-style: italic;}
+ol {margin: 0.5em 2.5em;}
+ul {margin: 0.5em 2em;}
+dl {margin: 0.5em 1em;}
+dd {margin: 0em   2em;}
+dt {font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", 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-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace; letter-spacing: 0; }
+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-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
+.equ {text-indent: 0; margin: 1em 2em 1em;}
+.indent {margin-left: 2em;}
+.rset {float: right; margin: 0.3em 0 0.5em 0.5em;}
+.lset {float: left; margin: 0.3em 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}
+.ral {text-align: right; }
+.lal {text-align: left; }
+.cal {text-align: center; }
+
+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: 2em; font-family: "MS Pゴシック",sans-serif; background-color: #d8d8FF; padding: 0.5em 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-size: 0.85em; font-family: "Consolas", "Courier New", monospace; white-space: nowrap;}
+table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", 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;}

+ 1 - 1
MiddleWare/FATFS/doc/css_p.css → Third_Party/FATFS/doc/css_p.css

@@ -1 +1 @@
-body {margin: 8px; background-color: #ffecf0; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;}
+body {margin: 8px; background-color: #ffecf0; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;}

+ 275 - 275
MiddleWare/FATFS/doc/en/appnote.html → Third_Party/FATFS/doc/en/appnote.html

@@ -1,275 +1,275 @@
-<!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="#fs3">Extended Use of FatFs API</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 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 <tt>integer.h</tt>. 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>System organizations</h4>
-<p>The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.</p>
-<p><img src="../img/modules.png" width="580" height="280" alt="dependency diagram"></p>
-<p>(a) If a working disk module with FatFs API is provided, no additional function is needed. (b) To attach existing disk drivers with different API, glue functions are needed to translate the APIs between FatFs and the drivers.</p>
-<p><img src="../img/funcs.png" width="680" height="430" alt="functional diagram"></p>
-
-<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. Most of 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_status<br>disk_initialize<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 != _MIN_SS</td></tr>
-<tr><td>disk_ioctl (CTRL_TRIM)</td><td>_USE_TRIM == 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/unicode.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 the FAT specs. (upto 4G-1 bytes)</li>
-<li>Volume size: Depends on the FAT specs. (upto 2T bytes at 512 bytes/sector)</li>
-<li>Cluster size: Depends on the FAT specs. (upto 64K bytes at 512 bytes/sector)</li>
-<li>Sector size: Depends on the FAT specs. (512, 1024, 2048 and 4096 bytes)</li>
-</ul>
-</div>
-
-<div class="para" id="memory">
-<h3>Memory Usage</h3>
-<table class="lst2">
-<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<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>RX600</th><th>IA-32</th></tr>
-<tr class="cal">     <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 class="cal">     <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>
-<!--                                                          ARM           Thumb        CM3          AVR           H8            PIC24         RL78          V850ES       SH-2A        RX600        IA-32   -->
-<tr class="lst3 ral"><td class="cal">text (Full, R/W)</td><td>10675</td><td>7171</td><td>6617</td><td>13355</td><td>10940</td><td>11722</td><td>13262</td><td>8113</td><td>9048</td><td>6032</td><td>7952</td></tr>
-<tr class="ral">     <td class="cal">text (Min, R/W)</td>  <td>6727</td><td>4631</td><td>4331</td> <td>8569</td> <td>7262</td> <td>7720</td> <td>9088</td><td>5287</td><td>5800</td><td>3948</td><td>5183</td></tr>
-<tr class="ral">     <td class="cal">text (Full, R/O)</td> <td>4731</td><td>3147</td><td>2889</td> <td>6235</td> <td>5170</td> <td>5497</td> <td>6482</td><td>3833</td><td>3972</td><td>2862</td><td>3719</td></tr>
-<tr class="ral">     <td class="cal">text (Min, R/O)</td>  <td>3559</td><td>2485</td><td>2295</td> <td>4575</td> <td>4064</td> <td>4240</td> <td>5019</td><td>2993</td><td>3104</td><td>2214</td><td>2889</td></tr>
-<tr class="ral">     <td class="cal">bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
-<tr class="ral">     <td class="cal">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 class="ral">     <td class="cal">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> denotes number of volumes and <em>F</em> denotes number of open files. All samples are optimezed in code size.</p>
-<pre>
-FatFs R0.10a options:
-_FS_READONLY     0 (R/W) or 1 (R/O)
-_FS_MINIMIZE     0 (Full function) or 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 feature)
-_MAX_SS          512 (Fixed sector size)
-_FS_RPATH        0 (Disable relative path feature)
-_FS_LABEL        0 (Disable volume label functions)
-_VOLUMES         V (Number of logical drives to be used)
-_MULTI_PARTITION 0 (Single partition per drive)
-_FS_REENTRANT    0 (Disable thread safe)
-_FS_LOCK         0 (Disable file lock 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">_FS_LABEL</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</td><td>1</td><td>0</td><td>1</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><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><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><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><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><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><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><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><td></td><td></td></tr>
-<tr><td>f_closedir</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><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><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><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><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><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><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><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><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><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><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><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><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><td></td><td></td></tr>
-<tr><td>f_getlabel</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><td></td><td></td><td></td><td></td></tr>
-<tr><td>f_setlabel</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><td></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></td><td></td><td>x</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></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></td><td></td><td>x</td><td></td><td></td><td></td><td>x</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><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><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><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><td></td><td></td></tr>
-</table>
-</div>
-
-<div class="para" id="lfn">
-<h3>Long File Name</h3>
-<p>FatFs module supports LFN (long file name). The two different file names, SFN (short file name) and LFN, of a file is transparent on the API except for <tt>f_readdir()</tt> function. The LFN feature is disabled by default. To enable it, set <tt>_USE_LFN</tt> to 1, 2 or 3, and add <tt>option/unicode.c</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> according to the available memory. The length of an LFN 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 input file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant configuration, <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 ARM7TDMI</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. Especially, in the CJK region, tens of thousands of characters are being used. 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 those code pages will not able to be implemented to most 8-bit microcontrollers.</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 come with the LFN feature. FatFs can swich the LFN feature off 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>By default, FatFs uses ANSI/OEM code set on the API under LFN configuration. FatFs can also switch the character encoding to Unicode on the API by <tt>_LFN_UNICODE</tt> option. This means that the FatFs supports the True-LFN feature. 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 by <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, <tt>ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant() and ff_rel_grant()</tt> must be added to the project. There are some examples in the <tt>option/syscall.c</tt>.</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 the 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 by some RTOS.</p>
-<p>There is an exception for <tt>f_mount(), f_mkfs(), f_fdisk()</tt> function. These functions are not re-entrant to the same volume or corresponding physical drive. When use these functions, all other tasks must unmount 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 will need to be re-entrant.</p>
-</div>
-
-<div class="para" id="dup">
-<h3>Duplicated File Access</h3>
-<p>FatFs module does not support the read/write collision control of duplicated open to a file. The duplicated open is permitted only when each of open method to a file is read mode. The duplicated open with one or more write mode to a file is always prohibited, and also open file must not be renamed and deleted. A violation of these rules can cause data colluption.</p>
-<p>The file lock control can be enabled by <tt>_FS_LOCK</tt> option. The value of option defines the number of open objects 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 objects, files and sub-directories, is equal to <tt>_FS_LOCK</tt>, an extra <tt>f_open(), f_optndir()</tt> 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 read/write throughput on the small embedded systems with limited size of memory, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by <tt>f_read()</tt> function.</p>
-<p>Figure 1. Sector misaligned read (short)<br>
-<img src="../img/f1.png" width="490" height="110" alt="">
-</p>
-<p>Figure 2. Sector misaligned read (long)<br>
-<img src="../img/f2.png" width="490" height="140" alt="">
-</p>
-<p>Figure 3. Fully sector aligned read<br>
-<img src="../img/f3.png" width="490" height="119" alt="">
-</p>
-<p>The file I/O buffer is 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 in 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 configuration (1) is selected, data memory consumption is reduced <tt>_MAX_SS</tt> bytes each file object. In this case, FatFs module uses only a sector buffer in 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 a partial sector, sector misaligned part of the file, is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to the 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 <tt>disk_read()</tt> function at a time but the multiple sector transfer is divided at cluster boundary even if it is contiguous.</p>
-<p>Therefore taking effort to sector aligned read/write accesss eliminates 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 at 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, CFC and U Disk, 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 transaction. The write throughput increases as the number of sectors per a write transaction. This effect more appers at faster interface speed and the performance ratio often becomes grater than ten. <a href="../img/rwtest2.png">This graph</a> is clearly explaining how fast is multiple block write (W:16K, 32 sectors) than single block write (W:100, 1 sector), and also larger card tends to be slow at single block write. The number of write transactions also affects the life time of the flash memory media. Therefore the application program should write the data in large block as possible. The ideal write chunk size and alighment is size of sector, and size of cluster is the best. Of course all layers between the application and the storage device must have consideration on multiple sector write, however most of open-source disk drivers lack it. Do not split a multiple sector write request into single sector write transactions or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write feature. </p>
-<h4>Forcing Memory Erase</h4>
-<p>When remove a file with <tt>f_remove()</tt> 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 flash memory array as 'live block'. If the file data is forced erased on removing the file, those data blocks will be turned in to the free block pool. This may skip internal block erase operation to the data block on next write operation. As the result the write performance might be improved. FatFs can manage this feature by setting <tt>_USE_ERASE</tt> to 1. Note that this is an expectation of internal process of the flash memory storage and not that always effective. Also <tt>f_remove()</tt> function will take a time when remove a large file. Most applications will not need this feature.</p>
-</div>
-
-<div class="para" id="critical">
-<h3>Critical Section</h3>
-<p>If a write operation to the FAT volume is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure on the volume can be broken. Following images shows the critical section of the FatFs module.</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 can be lost. If an interruption in the yellow section is occured, there is one or more possibility listed below.</p>
-<ul>
-<li>The file data being rewrited is collapsed.</li>
-<li>The file being appended returns initial state.</li>
-<li>The file created as new is gone.</li>
-<li>The file created as new or overwritten remains but 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 opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using <tt>f_sync()</tt> function as shown in Figure 5.</p>
-</div>
-
-<div class="para" id="fs3">
-<h3>Extended Use of FatFs API</h3>
-<p>These are examples of extended use of FatFs APIs. New item will be added whenever a useful code is found.</p>
-<ol>
-<li><a href="../img/app1.c">Open or create a file for append</a></li>
-<li><a href="../img/app2.c">Empty a directory</a></li>
-<li><a href="../img/app3.c">Allocate contiguous area to the file</a></li>
-<li><a href="../img/app4.c">Function/Compatible checker for low level disk I/O module</a></li>
-<li><a href="../img/mkfatimg.zip">FAT image creator</a></li>
-</ol>
-</div>
-
-<div class="para" id="license">
-<h3>About FatFs License</h3>
-<p>FatFs has being developped as a personal project of author, ChaN. It is free from the code anyone else wrote. Following code block shows a copy of the FatFs license document that included in the source files.</p>
-<pre>/*----------------------------------------------------------------------------/
-/  FatFs - FAT file system module  R0.10b                    (C)ChaN, 2014
-/-----------------------------------------------------------------------------/
-/ FatFs module is a generic FAT file system module for small embedded systems.
-/ This is a free software that opened for education, research and commercial
-/ developments under license policy of following trems.
-/
-/  Copyright (C) 2014, ChaN, all right reserved.
-/
-/ * The 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 licenses but there is a significant feature. Because FatFs is for embedded projects, the conditions of redistributions in binary form, such as embedded code, hex file, binary library or any forms without source code, are not specified in order to extend usability for commercial products. The documentation of the distributions need not include about FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course FatFs is compatible with the projects under GNU GPL. When redistribute the FatFs with any modification or branch it as a fork, the license can also be changed to GNU GPL, BSD-style license or any free software licenses that not conflict with FatFs license.</p>
-</div>
-
-<p class="foot"><a href="../00index_e.html">Return</a></p>
-</body>
-</html>
+<!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="#fs3">Extended Use of FatFs API</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 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 <tt>integer.h</tt>. 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>System organizations</h4>
+<p>The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.</p>
+<p><img src="../img/modules.png" width="580" height="280" alt="dependency diagram"></p>
+<p>(a) If a working disk module with FatFs API is provided, no additional function is needed. (b) To attach existing disk drivers with different API, glue functions are needed to translate the APIs between FatFs and the drivers.</p>
+<p><img src="../img/funcs.png" width="680" height="430" alt="functional diagram"></p>
+
+<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. Most of 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_status<br>disk_initialize<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 != _MIN_SS</td></tr>
+<tr><td>disk_ioctl (CTRL_TRIM)</td><td>_USE_TRIM == 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/unicode.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 the FAT specs. (upto 4G-1 bytes)</li>
+<li>Volume size: Depends on the FAT specs. (upto 2T bytes at 512 bytes/sector)</li>
+<li>Cluster size: Depends on the FAT specs. (upto 64K bytes at 512 bytes/sector)</li>
+<li>Sector size: Depends on the FAT specs. (512, 1024, 2048 and 4096 bytes)</li>
+</ul>
+</div>
+
+<div class="para" id="memory">
+<h3>Memory Usage</h3>
+<table class="lst2">
+<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<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>RX600</th><th>IA-32</th></tr>
+<tr class="cal">     <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 class="cal">     <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>
+<!--                                                          ARM           Thumb        CM3          AVR           H8            PIC24         RL78          V850ES       SH-2A        RX600        IA-32   -->
+<tr class="lst3 ral"><td class="cal">text (Full, R/W)</td><td>10675</td><td>7171</td><td>6617</td><td>13355</td><td>10940</td><td>11722</td><td>13262</td><td>8113</td><td>9048</td><td>6032</td><td>7952</td></tr>
+<tr class="ral">     <td class="cal">text (Min, R/W)</td>  <td>6727</td><td>4631</td><td>4331</td> <td>8569</td> <td>7262</td> <td>7720</td> <td>9088</td><td>5287</td><td>5800</td><td>3948</td><td>5183</td></tr>
+<tr class="ral">     <td class="cal">text (Full, R/O)</td> <td>4731</td><td>3147</td><td>2889</td> <td>6235</td> <td>5170</td> <td>5497</td> <td>6482</td><td>3833</td><td>3972</td><td>2862</td><td>3719</td></tr>
+<tr class="ral">     <td class="cal">text (Min, R/O)</td>  <td>3559</td><td>2485</td><td>2295</td> <td>4575</td> <td>4064</td> <td>4240</td> <td>5019</td><td>2993</td><td>3104</td><td>2214</td><td>2889</td></tr>
+<tr class="ral">     <td class="cal">bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
+<tr class="ral">     <td class="cal">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 class="ral">     <td class="cal">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> denotes number of volumes and <em>F</em> denotes number of open files. All samples are optimezed in code size.</p>
+<pre>
+FatFs R0.10a options:
+_FS_READONLY     0 (R/W) or 1 (R/O)
+_FS_MINIMIZE     0 (Full function) or 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 feature)
+_MAX_SS          512 (Fixed sector size)
+_FS_RPATH        0 (Disable relative path feature)
+_FS_LABEL        0 (Disable volume label functions)
+_VOLUMES         V (Number of logical drives to be used)
+_MULTI_PARTITION 0 (Single partition per drive)
+_FS_REENTRANT    0 (Disable thread safe)
+_FS_LOCK         0 (Disable file lock 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">_FS_LABEL</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</td><td>1</td><td>0</td><td>1</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><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><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><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><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><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><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><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><td></td><td></td></tr>
+<tr><td>f_closedir</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><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><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><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><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><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><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><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><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><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><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><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><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><td></td><td></td></tr>
+<tr><td>f_getlabel</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><td></td><td></td><td></td><td></td></tr>
+<tr><td>f_setlabel</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><td></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></td><td></td><td>x</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></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></td><td></td><td>x</td><td></td><td></td><td></td><td>x</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><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><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><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><td></td><td></td></tr>
+</table>
+</div>
+
+<div class="para" id="lfn">
+<h3>Long File Name</h3>
+<p>FatFs module supports LFN (long file name). The two different file names, SFN (short file name) and LFN, of a file is transparent on the API except for <tt>f_readdir()</tt> function. The LFN feature is disabled by default. To enable it, set <tt>_USE_LFN</tt> to 1, 2 or 3, and add <tt>option/unicode.c</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> according to the available memory. The length of an LFN 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 input file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant configuration, <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 ARM7TDMI</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. Especially, in the CJK region, tens of thousands of characters are being used. 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 those code pages will not able to be implemented to most 8-bit microcontrollers.</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 come with the LFN feature. FatFs can swich the LFN feature off 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>By default, FatFs uses ANSI/OEM code set on the API under LFN configuration. FatFs can also switch the character encoding to Unicode on the API by <tt>_LFN_UNICODE</tt> option. This means that the FatFs supports the True-LFN feature. 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 by <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, <tt>ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant() and ff_rel_grant()</tt> must be added to the project. There are some examples in the <tt>option/syscall.c</tt>.</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 the 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 by some RTOS.</p>
+<p>There is an exception for <tt>f_mount(), f_mkfs(), f_fdisk()</tt> function. These functions are not re-entrant to the same volume or corresponding physical drive. When use these functions, all other tasks must unmount 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 will need to be re-entrant.</p>
+</div>
+
+<div class="para" id="dup">
+<h3>Duplicated File Access</h3>
+<p>FatFs module does not support the read/write collision control of duplicated open to a file. The duplicated open is permitted only when each of open method to a file is read mode. The duplicated open with one or more write mode to a file is always prohibited, and also open file must not be renamed and deleted. A violation of these rules can cause data colluption.</p>
+<p>The file lock control can be enabled by <tt>_FS_LOCK</tt> option. The value of option defines the number of open objects 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 objects, files and sub-directories, is equal to <tt>_FS_LOCK</tt>, an extra <tt>f_open(), f_optndir()</tt> 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 read/write throughput on the small embedded systems with limited size of memory, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by <tt>f_read()</tt> function.</p>
+<p>Figure 1. Sector misaligned read (short)<br>
+<img src="../img/f1.png" width="490" height="110" alt="">
+</p>
+<p>Figure 2. Sector misaligned read (long)<br>
+<img src="../img/f2.png" width="490" height="140" alt="">
+</p>
+<p>Figure 3. Fully sector aligned read<br>
+<img src="../img/f3.png" width="490" height="119" alt="">
+</p>
+<p>The file I/O buffer is 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 in 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 configuration (1) is selected, data memory consumption is reduced <tt>_MAX_SS</tt> bytes each file object. In this case, FatFs module uses only a sector buffer in 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 a partial sector, sector misaligned part of the file, is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to the 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 <tt>disk_read()</tt> function at a time but the multiple sector transfer is divided at cluster boundary even if it is contiguous.</p>
+<p>Therefore taking effort to sector aligned read/write accesss eliminates 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 at 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, CFC and U Disk, 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 transaction. The write throughput increases as the number of sectors per a write transaction. This effect more appers at faster interface speed and the performance ratio often becomes grater than ten. <a href="../img/rwtest2.png">This graph</a> is clearly explaining how fast is multiple block write (W:16K, 32 sectors) than single block write (W:100, 1 sector), and also larger card tends to be slow at single block write. The number of write transactions also affects the life time of the flash memory media. Therefore the application program should write the data in large block as possible. The ideal write chunk size and alighment is size of sector, and size of cluster is the best. Of course all layers between the application and the storage device must have consideration on multiple sector write, however most of open-source disk drivers lack it. Do not split a multiple sector write request into single sector write transactions or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write feature. </p>
+<h4>Forcing Memory Erase</h4>
+<p>When remove a file with <tt>f_remove()</tt> 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 flash memory array as 'live block'. If the file data is forced erased on removing the file, those data blocks will be turned in to the free block pool. This may skip internal block erase operation to the data block on next write operation. As the result the write performance might be improved. FatFs can manage this feature by setting <tt>_USE_ERASE</tt> to 1. Note that this is an expectation of internal process of the flash memory storage and not that always effective. Also <tt>f_remove()</tt> function will take a time when remove a large file. Most applications will not need this feature.</p>
+</div>
+
+<div class="para" id="critical">
+<h3>Critical Section</h3>
+<p>If a write operation to the FAT volume is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure on the volume can be broken. Following images shows the critical section of the FatFs module.</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 can be lost. If an interruption in the yellow section is occured, there is one or more possibility listed below.</p>
+<ul>
+<li>The file data being rewrited is collapsed.</li>
+<li>The file being appended returns initial state.</li>
+<li>The file created as new is gone.</li>
+<li>The file created as new or overwritten remains but 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 opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using <tt>f_sync()</tt> function as shown in Figure 5.</p>
+</div>
+
+<div class="para" id="fs3">
+<h3>Extended Use of FatFs API</h3>
+<p>These are examples of extended use of FatFs APIs. New item will be added whenever a useful code is found.</p>
+<ol>
+<li><a href="../img/app1.c">Open or create a file for append</a></li>
+<li><a href="../img/app2.c">Empty a directory</a></li>
+<li><a href="../img/app3.c">Allocate contiguous area to the file</a></li>
+<li><a href="../img/app4.c">Function/Compatible checker for low level disk I/O module</a></li>
+<li><a href="../img/mkfatimg.zip">FAT image creator</a></li>
+</ol>
+</div>
+
+<div class="para" id="license">
+<h3>About FatFs License</h3>
+<p>FatFs has being developped as a personal project of author, ChaN. It is free from the code anyone else wrote. Following code block shows a copy of the FatFs license document that included in the source files.</p>
+<pre>/*----------------------------------------------------------------------------/
+/  FatFs - FAT file system module  R0.10b                    (C)ChaN, 2014
+/-----------------------------------------------------------------------------/
+/ FatFs module is a generic FAT file system module for small embedded systems.
+/ This is a free software that opened for education, research and commercial
+/ developments under license policy of following trems.
+/
+/  Copyright (C) 2014, ChaN, all right reserved.
+/
+/ * The 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 licenses but there is a significant feature. Because FatFs is for embedded projects, the conditions of redistributions in binary form, such as embedded code, hex file, binary library or any forms without source code, are not specified in order to extend usability for commercial products. The documentation of the distributions need not include about FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course FatFs is compatible with the projects under GNU GPL. When redistribute the FatFs with any modification or branch it as a fork, the license can also be changed to GNU GPL, BSD-style license or any free software licenses that not conflict with FatFs license.</p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 81 - 81
MiddleWare/FATFS/doc/en/chdir.html → Third_Party/FATFS/doc/en/chdir.html

@@ -1,81 +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* <span class="arg">path</span> <span class="c">/* [IN] 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 <tt>f_chdir()</tt> 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 volume.</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>
+<!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* <span class="arg">path</span> <span class="c">/* [IN] 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 <tt>f_chdir()</tt> 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 volume.</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 - 60
MiddleWare/FATFS/doc/en/chdrive.html → Third_Party/FATFS/doc/en/chdrive.html

@@ -1,60 +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 (
-  const TCHAR* <span class="arg">path</span>  <span class="c">/* [IN] Logical drive number */</span>
-);
-</pre>
-</div>
-
-<div class="para arg">
-<h4>Parameters</h4>
-<dl class="par">
-<dt>path</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 <tt>f_chdrive()</tt> 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> and <tt>_VOLUMES >= 2</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>
+<!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 (
+  const TCHAR* <span class="arg">path</span>  <span class="c">/* [IN] Logical drive number */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>path</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 <tt>f_chdrive()</tt> 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> and <tt>_VOLUMES >= 2</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 - 89
MiddleWare/FATFS/doc/en/chmod.html → Third_Party/FATFS/doc/en/chmod.html

@@ -1,89 +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 sub-directory.</p>
-<pre>
-FRESULT f_chmod (
-  const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Object name */</span>
-  BYTE <span class="arg">attr</span>,         <span class="c">/* [IN] Attribute flags */</span>
-  BYTE <span class="arg">mask</span>          <span class="c">/* [IN] Attribute masks */</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 an <a href="filename.html">object</a> to be changed</dd>
-<dt>attr</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>mask</dt>
-<dd>Attribute mask that specifies which attribute is changed. The specified attributes are set or cleard and others are left unchanged.</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 <tt>f_chmod()</tt> function changes the attribute of a file or sub-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 left unchanged. */</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>
+<!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 sub-directory.</p>
+<pre>
+FRESULT f_chmod (
+  const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Object name */</span>
+  BYTE <span class="arg">attr</span>,         <span class="c">/* [IN] Attribute flags */</span>
+  BYTE <span class="arg">mask</span>          <span class="c">/* [IN] Attribute masks */</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 an <a href="filename.html">object</a> to be changed</dd>
+<dt>attr</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>mask</dt>
+<dd>Attribute mask that specifies which attribute is changed. The specified attributes are set or cleard and others are left unchanged.</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 <tt>f_chmod()</tt> function changes the attribute of a file or sub-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 left unchanged. */</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>

+ 66 - 66
MiddleWare/FATFS/doc/en/close.html → Third_Party/FATFS/doc/en/close.html

@@ -1,66 +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/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* <span class="arg">fp</span>     <span class="c">/* [IN] Pointer to the file object */</span>
-);
-</pre>
-</div>
-
-<div class="para arg">
-<h4>Parameter</h4>
-<dl class="par">
-<dt>fp</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 <tt>f_close()</tt> 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 volume. After the function succeeded, the file object is no longer valid and it can be discarded.</p>
-<p>Note that if the file object is in read-only mode and <tt>_FS_LOCK</tt> option is not enabled, the file object can also be discarded without this process. However this is not recommended for future compatibility.</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>
+<!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* <span class="arg">fp</span>     <span class="c">/* [IN] Pointer to the file object */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>fp</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 <tt>f_close()</tt> 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 volume. After the function succeeded, the file object is no longer valid and it can be discarded.</p>
+<p>Note that if the file object is in read-only mode and <tt>_FS_LOCK</tt> option is not enabled, the file object can also be discarded without this process. However this is not recommended for future compatibility.</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>

+ 64 - 64
MiddleWare/FATFS/doc/en/closedir.html → Third_Party/FATFS/doc/en/closedir.html

@@ -1,64 +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/close.html">
-<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
-<title>FatFs - f_closedir</title>
-</head>
-
-<body>
-
-<div class="para func">
-<h2>f_closedir</h2>
-<p>The f_closedir function closes an open directory.</p>
-<pre>
-FRESULT f_closedir (
-  DIR* <span class="arg">dp</span>     <span class="c">/* [IN] Pointer to the directory object */</span>
-);
-</pre>
-</div>
-
-<div class="para arg">
-<h4>Parameter</h4>
-<dl class="par">
-<dt>dp</dt>
-<dd>Pointer to the open directory 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#ie">FR_INT_ERR</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 <tt>f_closedir()</tt> function closes an open directory object. After the function succeeded, the directory object is no longer valid and it can be discarded.</p>
-<p>Note that the directory object can also be discarded without this process if <tt>_FS_LOCK</tt> option is not enabled. However this is not recommended for future compatibility.</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="opendir.html">f_opendir</a>, <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>
+<!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_closedir</title>
+</head>
+
+<body>
+
+<div class="para func">
+<h2>f_closedir</h2>
+<p>The f_closedir function closes an open directory.</p>
+<pre>
+FRESULT f_closedir (
+  DIR* <span class="arg">dp</span>     <span class="c">/* [IN] Pointer to the directory object */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>dp</dt>
+<dd>Pointer to the open directory 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#ie">FR_INT_ERR</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 <tt>f_closedir()</tt> function closes an open directory object. After the function succeeded, the directory object is no longer valid and it can be discarded.</p>
+<p>Note that the directory object can also be discarded without this process if <tt>_FS_LOCK</tt> option is not enabled. However this is not recommended for future compatibility.</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="opendir.html">f_opendir</a>, <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>

+ 46 - 46
MiddleWare/FATFS/doc/en/dinit.html → Third_Party/FATFS/doc/en/dinit.html

@@ -1,46 +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 storage device.</p>
-<pre>
-DSTATUS disk_initialize (
-  BYTE <span class="arg">pdrv</span>           <span class="c">/* [IN] Physical drive number */</span>
-);
-</pre>
-</div>
-
-<div class="para arg">
-<h4>Parameter</h4>
-<dl class="par">
-<dt>pdrv</dt>
-<dd>Physical drive number to identify the target device.</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>This function initializes a storage device and put it ready to generic read/write data. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleared.</p>
-<p><em>Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use <tt>f_mount()</tt> function instead.</em> This function is called at volume mount process by FatFs module to manage the media change.</p>
-</div>
-
-<p class="foot"><a href="../00index_e.html">Return</a></p>
-</body>
-</html>
+<!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 storage device.</p>
+<pre>
+DSTATUS disk_initialize (
+  BYTE <span class="arg">pdrv</span>           <span class="c">/* [IN] Physical drive number */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>pdrv</dt>
+<dd>Physical drive number to identify the target device.</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>This function initializes a storage device and put it ready to generic read/write data. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleared.</p>
+<p><em>Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use <tt>f_mount()</tt> function instead.</em> This function is called at volume mount process by FatFs module to manage the media change.</p>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 90 - 90
MiddleWare/FATFS/doc/en/dioctl.html → Third_Party/FATFS/doc/en/dioctl.html

@@ -1,90 +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/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 specific features and miscellaneous functions other than generic read/write.</p>
-<pre>
-DRESULT disk_ioctl (
-  BYTE <span class="arg">pdrv</span>,     <span class="c">/* [IN] Drive number */</span>
-  BYTE <span class="arg">cmd</span>,      <span class="c">/* [IN] Control command code */</span>
-  void* <span class="arg">buff</span>     <span class="c">/* [I/O] Parameter and data buffer */</span>
-);
-</pre>
-</div>
-
-<div class="para arg">
-<h4>Parameters</h4>
-<dl class="par">
-<dt>pdrv</dt>
-<dd>Physical drive number to identify the target device.</dd>
-<dt>cmd</dt>
-<dd>Command code.</dd>
-<dt>buff</dt>
-<dd>Pointer to the parameter depends on the command code. Do not care if no parameter to be passed.</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>An error occured.</dd>
-<dt>RES_PARERR</dt>
-<dd>The command code or parameter is invalid.</dd>
-<dt>RES_NOTRDY</dt>
-<dd>The device has not been initialized.</dd>
-</dl>
-</div>
-
-
-<div class="para desc">
-<h4>Description</h4>
-<p>The FatFs module requires only five device independent commands described below.</p>
-<table class="lst">
-<caption>Standard ioctl command used by FatFs</caption>
-<tr><th>Command</th><th>Description</th></tr>
-<tr><td>CTRL_SYNC</td><td>Make sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. Nothing to do for this command if each write operation to the media is completed within the <tt>disk_write()</tt> function. Required at <tt>_FS_READONLY == 0</tt>.</td></tr>
-<tr><td>GET_SECTOR_COUNT</td><td>Returns number of available sectors on the drive into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. This command is used by only <tt>f_mkfs()</tt> and <tt>f_fdisk()</tt> function to determine the volume/partition size to be created. Required at <tt>_USE_MKFS == 1</tt> or <tt>_MULTI_PARTITION == 1</tt>.</td></tr>
-<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the media into the <tt>WORD</tt> variable pointed by <tt class="arg">buff</tt>. Valid return values of this command are 512, 1024, 2048 or 4096. This command is required at variable sector size configuration, <tt>_MAX_SS &gt; _MIN_SS</tt>. Never used at fixed sector size configuration, <tt>_MAX_SS == _MIN_SS</tt>, and it must work at that sector size.</td></tr>
-<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory in unit of sector into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk media. This command is used by only <tt>f_mkfs()</tt> function and it attempts to align data area to the erase block boundary. Required at <tt>_USE_MKFS == 1</tt>.</td></tr>
-<tr><td>CTRL_ERASE_SECTOR</td><td>Informs device that the data on the block of sectors specified by a <tt>DWORD</tt> array {&lt;start sector&gt;, &lt;end sector&gt;} pointed by <tt class="arg">buff</tt> is no longer needed and may be erased. The device would force erased the memory block. This is a command similar to Trim command of ATA device. When this feature is not supported or not a flash memory media, nothing to do for this command. The FatFs does not check the result code and the file function is not affected even if the sectors ware not erased well. This command is called on removing a cluster chain and <tt>f_mkfs()</tt> function. Required at <tt>_USE_ERASE == 1</tt>.</td></tr>
-</table>
-
-<p>FatFs never uses any device dependent command and user defined command. Following table shows an example of non-standard commands usable for some applications.</p>
-<table class="lst">
-<caption>Example of optional ioctl command</caption>
-<tr><th>Command</th><th>Description</th></tr>
-<tr><td>CTRL_FORMAT</td><td>Create a physical format on the media. If <tt class="arg">buff</tt> is not null, it is pointer to the call-back function for progress notification.</td></tr>
-<tr><td>CTRL_POWER_IDLE</td><td>Put the device idle state. <tt>STA_NOINIT</tt> in status flag may not be set if the device would go active state by generic read/write function.</td></tr>
-<tr><td>CTRL_POWER_OFF</td><td>Put the device off state. Shut-down the power to the device and deinitialize the device interface if needed. <tt>STA_NOINIT</tt> in status flag must be set. The device goes active state by <tt>disk_initialize()</tt> function.</td></tr>
-<tr><td>CTRL_LOCK</td><td>Lock media eject mechanism.</td></tr>
-<tr><td>CTRL_UNLOCK</td><td>Unlock media eject mechanism.</td></tr>
-<tr><td>CTRL_EJECT</td><td>Eject media cartridge. <tt>STA_NOINIT</tt> and <tt>STA_NODISK</tt> in status flag are set after the function succeeded.</td></tr>
-<tr><td>MMC_GET_TYPE</td><td>Get card type. The type flags, bit0:MMCv3, bit1:SDv1, bit2:SDv2+ and bit3:LBA, is stored to a BYTE variable pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
-<tr><td>MMC_GET_CSD</td><td>Get CSD register into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
-<tr><td>MMC_GET_CID</td><td>Get CID register into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
-<tr><td>MMC_GET_OCR</td><td>Get OCR register into a 4-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
-<tr><td>MMC_GET_SDSTAT</td><td>Get SDSTATUS register into a 64-byte buffer pointed by <tt class="arg">buff</tt>. (SDC specific command)</td></tr>
-<tr><td>ATA_GET_REV</td><td>Get the revision string into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
-<tr><td>ATA_GET_MODEL</td><td>Get the model string into a 40-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
-<tr><td>ATA_GET_SN</td><td>Get the serial number string into a 20-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
-</table>
-</div>
-
-<p class="foot"><a href="../00index_e.html">Return</a></p>
-</body>
-</html>
+<!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 specific features and miscellaneous functions other than generic read/write.</p>
+<pre>
+DRESULT disk_ioctl (
+  BYTE <span class="arg">pdrv</span>,     <span class="c">/* [IN] Drive number */</span>
+  BYTE <span class="arg">cmd</span>,      <span class="c">/* [IN] Control command code */</span>
+  void* <span class="arg">buff</span>     <span class="c">/* [I/O] Parameter and data buffer */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>pdrv</dt>
+<dd>Physical drive number to identify the target device.</dd>
+<dt>cmd</dt>
+<dd>Command code.</dd>
+<dt>buff</dt>
+<dd>Pointer to the parameter depends on the command code. Do not care if no parameter to be passed.</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>An error occured.</dd>
+<dt>RES_PARERR</dt>
+<dd>The command code or parameter is invalid.</dd>
+<dt>RES_NOTRDY</dt>
+<dd>The device has not been initialized.</dd>
+</dl>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The FatFs module requires only five device independent commands described below.</p>
+<table class="lst">
+<caption>Standard ioctl command used by FatFs</caption>
+<tr><th>Command</th><th>Description</th></tr>
+<tr><td>CTRL_SYNC</td><td>Make sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. Nothing to do for this command if each write operation to the media is completed within the <tt>disk_write()</tt> function. Required at <tt>_FS_READONLY == 0</tt>.</td></tr>
+<tr><td>GET_SECTOR_COUNT</td><td>Returns number of available sectors on the drive into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. This command is used by only <tt>f_mkfs()</tt> and <tt>f_fdisk()</tt> function to determine the volume/partition size to be created. Required at <tt>_USE_MKFS == 1</tt> or <tt>_MULTI_PARTITION == 1</tt>.</td></tr>
+<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the media into the <tt>WORD</tt> variable pointed by <tt class="arg">buff</tt>. Valid return values of this command are 512, 1024, 2048 or 4096. This command is required at variable sector size configuration, <tt>_MAX_SS &gt; _MIN_SS</tt>. Never used at fixed sector size configuration, <tt>_MAX_SS == _MIN_SS</tt>, and it must work at that sector size.</td></tr>
+<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory in unit of sector into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk media. This command is used by only <tt>f_mkfs()</tt> function and it attempts to align data area to the erase block boundary. Required at <tt>_USE_MKFS == 1</tt>.</td></tr>
+<tr><td>CTRL_ERASE_SECTOR</td><td>Informs device that the data on the block of sectors specified by a <tt>DWORD</tt> array {&lt;start sector&gt;, &lt;end sector&gt;} pointed by <tt class="arg">buff</tt> is no longer needed and may be erased. The device would force erased the memory block. This is a command similar to Trim command of ATA device. When this feature is not supported or not a flash memory media, nothing to do for this command. The FatFs does not check the result code and the file function is not affected even if the sectors ware not erased well. This command is called on removing a cluster chain and <tt>f_mkfs()</tt> function. Required at <tt>_USE_ERASE == 1</tt>.</td></tr>
+</table>
+
+<p>FatFs never uses any device dependent command and user defined command. Following table shows an example of non-standard commands usable for some applications.</p>
+<table class="lst">
+<caption>Example of optional ioctl command</caption>
+<tr><th>Command</th><th>Description</th></tr>
+<tr><td>CTRL_FORMAT</td><td>Create a physical format on the media. If <tt class="arg">buff</tt> is not null, it is pointer to the call-back function for progress notification.</td></tr>
+<tr><td>CTRL_POWER_IDLE</td><td>Put the device idle state. <tt>STA_NOINIT</tt> in status flag may not be set if the device would go active state by generic read/write function.</td></tr>
+<tr><td>CTRL_POWER_OFF</td><td>Put the device off state. Shut-down the power to the device and deinitialize the device interface if needed. <tt>STA_NOINIT</tt> in status flag must be set. The device goes active state by <tt>disk_initialize()</tt> function.</td></tr>
+<tr><td>CTRL_LOCK</td><td>Lock media eject mechanism.</td></tr>
+<tr><td>CTRL_UNLOCK</td><td>Unlock media eject mechanism.</td></tr>
+<tr><td>CTRL_EJECT</td><td>Eject media cartridge. <tt>STA_NOINIT</tt> and <tt>STA_NODISK</tt> in status flag are set after the function succeeded.</td></tr>
+<tr><td>MMC_GET_TYPE</td><td>Get card type. The type flags, bit0:MMCv3, bit1:SDv1, bit2:SDv2+ and bit3:LBA, is stored to a BYTE variable pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
+<tr><td>MMC_GET_CSD</td><td>Get CSD register into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
+<tr><td>MMC_GET_CID</td><td>Get CID register into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
+<tr><td>MMC_GET_OCR</td><td>Get OCR register into a 4-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
+<tr><td>MMC_GET_SDSTAT</td><td>Get SDSTATUS register into a 64-byte buffer pointed by <tt class="arg">buff</tt>. (SDC specific command)</td></tr>
+<tr><td>ATA_GET_REV</td><td>Get the revision string into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
+<tr><td>ATA_GET_MODEL</td><td>Get the model string into a 40-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
+<tr><td>ATA_GET_SN</td><td>Get the serial number string into a 20-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
+</table>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 71 - 71
MiddleWare/FATFS/doc/en/dread.html → Third_Party/FATFS/doc/en/dread.html

@@ -1,71 +1,71 @@
-<!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 storage device.</p>
-<pre>
-DRESULT disk_read (
-  BYTE <span class="arg">pdrv</span>,     <span class="c">/* [IN] Physical drive number */</span>
-  BYTE* <span class="arg">buff</span>,    <span class="c">/* [OUT] Pointer to the read data buffer */</span>
-  DWORD <span class="arg">sector</span>,  <span class="c">/* [IN] Start sector number */</span>
-  UINT <span class="arg">count</span>     <span class="c">/* [IN] Number of sectros to read */</span>
-);
-</pre>
-</div>
-
-<div class="para arg">
-<h4>Parameters</h4>
-<dl class="par">
-<dt>pdrv</dt>
-<dd>Physical drive number to identify the target device.</dd>
-<dt>buff</dt>
-<dd>Pointer to the <em>byte array</em> to store the read data.</dd>
-<dt>sector</dt>
-<dd>Start sector number in logical block address (LBA).</dd>
-<dt>count</dt>
-<dd>Number of sectors to read. FatFs specifis it in range of from 1 to 128.</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 device has not been initialized.</dd>
-</dl>
-</div>
-
-
-<div class="para desc">
-<h4>Description</h4>
-<p>The memory address specified by <tt class="arg">buff</tt> is not that always aligned to word boundary because the type of argument is defined as <tt>BYTE*</tt>. The misaligned read/write request can occure at <a href="appnote.html#fs1">direct transfer</a>. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.</p>
-<ul>
-<li>Convert word transfer to byte transfer in this function. - Recommended.</li>
-<li>For <tt>f_read()</tt>, avoid long read request that includes a whole of sector. - Direct transfer will never occure.</li>
-<li>For <tt>f_read(fp, buff, btr, &amp;br)</tt>, make sure that <tt>(((UINT)buff &amp; 3) == (f_tell(fp) &amp; 3))</tt> is true. - Word aligned direct transfer is guaranteed.</li>
-</ul>
-<p>Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will not get good read throughput.</p>
-</div>
-
-
-<p class="foot"><a href="../00index_e.html">Return</a></p>
-</body>
-</html>
+<!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 storage device.</p>
+<pre>
+DRESULT disk_read (
+  BYTE <span class="arg">pdrv</span>,     <span class="c">/* [IN] Physical drive number */</span>
+  BYTE* <span class="arg">buff</span>,    <span class="c">/* [OUT] Pointer to the read data buffer */</span>
+  DWORD <span class="arg">sector</span>,  <span class="c">/* [IN] Start sector number */</span>
+  UINT <span class="arg">count</span>     <span class="c">/* [IN] Number of sectros to read */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameters</h4>
+<dl class="par">
+<dt>pdrv</dt>
+<dd>Physical drive number to identify the target device.</dd>
+<dt>buff</dt>
+<dd>Pointer to the <em>byte array</em> to store the read data.</dd>
+<dt>sector</dt>
+<dd>Start sector number in logical block address (LBA).</dd>
+<dt>count</dt>
+<dd>Number of sectors to read. FatFs specifis it in range of from 1 to 128.</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 device has not been initialized.</dd>
+</dl>
+</div>
+
+
+<div class="para desc">
+<h4>Description</h4>
+<p>The memory address specified by <tt class="arg">buff</tt> is not that always aligned to word boundary because the type of argument is defined as <tt>BYTE*</tt>. The misaligned read/write request can occure at <a href="appnote.html#fs1">direct transfer</a>. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.</p>
+<ul>
+<li>Convert word transfer to byte transfer in this function. - Recommended.</li>
+<li>For <tt>f_read()</tt>, avoid long read request that includes a whole of sector. - Direct transfer will never occure.</li>
+<li>For <tt>f_read(fp, buff, btr, &amp;br)</tt>, make sure that <tt>(((UINT)buff &amp; 3) == (f_tell(fp) &amp; 3))</tt> is true. - Word aligned direct transfer is guaranteed.</li>
+</ul>
+<p>Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will not get good read throughput.</p>
+</div>
+
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

+ 48 - 48
MiddleWare/FATFS/doc/en/dstat.html → Third_Party/FATFS/doc/en/dstat.html

@@ -1,48 +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 <span class="arg">pdrv</span>     <span class="c">/* [IN] Physical drive number */</span>
-);
-</pre>
-</div>
-
-<div class="para arg">
-<h4>Parameter</h4>
-<dl class="par">
-<dt>pdrv</dt>
-<dd>Physical drive number to identify the target device.</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_PROTECT</tt>.</p>
-<dl class="ret">
-<dt>STA_NOINIT</dt>
-<dd>Indicates that the device is not initialized. This flag is set on system reset, media removal or failure of <tt>disk_initialize()</tt> function. It is cleared on <tt>disk_initialize()</tt> function succeeded. Media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount feature will not work correctly. When media change detection feature is not supported, application program needs to de-initialize the file system object with <tt>f_mount()</tt> function after the media change.</dd>
-<dt>STA_NODISK</dt>
-<dd>Indicates that no medium in the drive. This is always cleared on fixed disk drive. Note that FatFs does not refer this flag.</dd>
-<dt>STA_PROTECT</dt>
-<dd>Indicates that the medium is write protected. This is always cleared on the drives without write protect feature. Not valid while no medium in the drive.</dd>
-</dl>
-</div>
-
-<p class="foot"><a href="../00index_e.html">Return</a></p>
-</body>
-</html>
+<!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 <span class="arg">pdrv</span>     <span class="c">/* [IN] Physical drive number */</span>
+);
+</pre>
+</div>
+
+<div class="para arg">
+<h4>Parameter</h4>
+<dl class="par">
+<dt>pdrv</dt>
+<dd>Physical drive number to identify the target device.</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_PROTECT</tt>.</p>
+<dl class="ret">
+<dt>STA_NOINIT</dt>
+<dd>Indicates that the device is not initialized. This flag is set on system reset, media removal or failure of <tt>disk_initialize()</tt> function. It is cleared on <tt>disk_initialize()</tt> function succeeded. Media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount feature will not work correctly. When media change detection feature is not supported, application program needs to de-initialize the file system object with <tt>f_mount()</tt> function after the media change.</dd>
+<dt>STA_NODISK</dt>
+<dd>Indicates that no medium in the drive. This is always cleared on fixed disk drive. Note that FatFs does not refer this flag.</dd>
+<dt>STA_PROTECT</dt>
+<dd>Indicates that the medium is write protected. This is always cleared on the drives without write protect feature. Not valid while no medium in the drive.</dd>
+</dl>
+</div>
+
+<p class="foot"><a href="../00index_e.html">Return</a></p>
+</body>
+</html>

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini